我有一个来自swing的问题,我有两个表单,第一个表单用于MDI,第二个表单用于登录,我希望当用户输入正确的密码和用户名时,用户可以登录到MDI的表单。MDI窗体使用jform和登录窗体使用jinternalframe,我定义了JDesktopPane并将登录添加到其中,但我想使用jframe中的按钮(MDI窗体),当我向JDesktopPane添加按钮时,它可以添加,但我不能设置按钮的位置。请告诉我如何设置我的jinternalframe和按钮的位置?
这是我的代码:
Login frame = new Login();
frame.setVisible(true);
desktop=new JDesktopPane();
desktop.add(frame,BorderLayout.CENTER);
setContentPane(desktop);
frame.setSelected(true);
frame.setLocation(500, 200);
FlowLayout flo = new FlowLayout();
desktop.setLayout(flo);
JButton buttonSaveCustumer = new JButton("Create Customer");
buttonSaveCustumer.setLocation(70, 80);
this.add(buttonSaveCustumer);诚挚的问候
发布于 2014-03-26 01:05:16
请参见下面的方法,//在使用下面的方法之前,不要忘记将布局属性设置为null
public void setBounds(int x, int y, int width, int height)移动此组件并调整其大小。左上角的新位置由x和y指定,新大小由width和height指定。此方法更改与布局相关的信息,因此会使组件层次结构无效。
Parameters:
x - the new x-coordinate of this component
y - the new y-coordinate of this component
width - the new width of this component
height - the new height of this componenthttps://stackoverflow.com/questions/22641493
复制相似问题