首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将按钮添加到JDesktopPane

将按钮添加到JDesktopPane
EN

Stack Overflow用户
提问于 2014-03-26 01:01:07
回答 1查看 916关注 0票数 0

我有一个来自swing的问题,我有两个表单,第一个表单用于MDI,第二个表单用于登录,我希望当用户输入正确的密码和用户名时,用户可以登录到MDI的表单。MDI窗体使用jform和登录窗体使用jinternalframe,我定义了JDesktopPane并将登录添加到其中,但我想使用jframe中的按钮(MDI窗体),当我向JDesktopPane添加按钮时,它可以添加,但我不能设置按钮的位置。请告诉我如何设置我的jinternalframe和按钮的位置?

这是我的代码:

代码语言:javascript
复制
     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);

诚挚的问候

EN

回答 1

Stack Overflow用户

发布于 2014-03-26 01:05:16

请参见下面的方法,//在使用下面的方法之前,不要忘记将布局属性设置为null

代码语言:javascript
复制
public void setBounds(int x, int y, int width, int height)

移动此组件并调整其大小。左上角的新位置由x和y指定,新大小由width和height指定。此方法更改与布局相关的信息,因此会使组件层次结构无效。

代码语言:javascript
复制
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 component
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22641493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档