java JInternalFrame中的自定义大小按钮

时间:2015-01-31 09:56:14

标签: java swing jinternalframe

我正在制作一个简单的GUI。我有一个JInternalFrame,在这个框架中我添加了两个按钮,但它们的大小超出了我的预期。我想在我的尺寸上看到这些按钮,但它们的尺寸没有改变。我还使用了setSized() funtionj。输出 - output of program

这是我的代码

/*making of sign in headerFrame and all its dimension and size and location are initialized here*/
 JInternalFrame signframe=new JInternalFrame("signframe", false, false, false, false);
 signframe.setLayout(new GridLayout(3, 1,5,6));
 signframe.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
 signframe.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
 BasicInternalFrameTitlePane signtitlePane =
         (BasicInternalFrameTitlePane) ((BasicInternalFrameUI) signframe.getUI()).getNorthPane();  
 signframe.remove(signtitlePane);
 signframe.setBorder(null);
 signframe.setBackground(Color.ORANGE);
 signframe.setSize(250, 150);
 //end of the sign frame

 //location of the sign frame in the screen
 signframe.setLocation(30,60);

 //make the gui for the Sign frame
 //make sign button for the sign frame
 JButton signbutton=new JButton("SIGN IN");
 signbutton.setSize(20, 20);
 JButton signbutton2=new JButton("SIGN IN2");
 signbutton.setSize(20, 20);
 signbutton.resize(30, 40);
 signbutton2.setPreferredSize(getSize());

 //add action lister to the sign in button
 signbutton.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

    }
});


 //adding the signbutton to signframe
 signframe.add(signbutton);
 signframe.add(signbutton2);

 //making the sign frame visible
 signframe.setVisible(true);
 //adding the sign frame into the destop pane
 desktoppane.add(signframe);


 //should be in the ends
 c.add(desktoppane);
 setVisible(true);

0 个答案:

没有答案