
下面的Java代码窗口缩放后,布局就会变化,怎样才能让布局不随窗口的缩放而变化
import...(省略)publicclassJPanelTestextendsJFrame{JLabelbl1,bl2,bl3;JButtonsave,send;JP...
import...(省略)
public class JPanelTest extends JFrame{
JLabel bl1,bl2,bl3;
JButton save,send;
JPanel p1,p2,p3;
JTextField t1,t2,t3;
JTextArea t;
public JPanelTest() {
super("电子邮件");
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
init();
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(p1);
c.add(p2);
c.add(t);
c.add(new JScrollPane(t));
c.add(p3);
this.setBounds(250,200,500,450);
this.setResizable(false);
this.setVisible(true);
}
void init(){
...(省略) }
String getFileText(){
...(省略) }
public static void main(String[] args) {
new JPanelTest();
}
} 展开
public class JPanelTest extends JFrame{
JLabel bl1,bl2,bl3;
JButton save,send;
JPanel p1,p2,p3;
JTextField t1,t2,t3;
JTextArea t;
public JPanelTest() {
super("电子邮件");
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
init();
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(p1);
c.add(p2);
c.add(t);
c.add(new JScrollPane(t));
c.add(p3);
this.setBounds(250,200,500,450);
this.setResizable(false);
this.setVisible(true);
}
void init(){
...(省略) }
String getFileText(){
...(省略) }
public static void main(String[] args) {
new JPanelTest();
}
} 展开
2个回答
展开全部
那你直接不让缩放窗口就可以了...其他的布局也会变化
frame.setResizable(false);
frame.setResizable(false);
更多追问追答
追问
我想要这种效果,但不知道怎么才能让窗口缩放过程中保持布局不变
追答
布局不变指的是样式不变还是大小不变,样式不变的话其余两种布局:BorderLayout和
GridLayout都行,大小不变就不行了..
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询