0

I am making a simple GUI in swing. I have a JInternalFrame and in this frame I have added two button but their size is beyond my expectation. I want to see these button in my size but their size is not getting changed. I have also use setSized() funtionj. Here the output-output of program

this is my code

/*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);
MANOJ GOPI
  • 1,279
  • 10
  • 31
  • 1
    And your question is? Consider providing a [runnable example](https://stackoverflow.com/help/mcve) which demonstrates your problem. This will result in less confusion and better responses – MadProgrammer Jan 31 '15 at 09:58
  • 1
    See [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/q/7229226/418556) (Yes.) The size of a button can be changed by changing the font size, or setting a margin. – Andrew Thompson Jan 31 '15 at 12:42
  • 1
    ..of course `signframe.setLayout(new GridLayout(3, 1,5,6));` the `GridLayout` will stretch components to fill the space available, but post an MCVE as suggested by @MadProgrammer. – Andrew Thompson Jan 31 '15 at 12:45
  • Also consider `JComponent.sizeVariant`, seen [here](http://stackoverflow.com/a/14599176/230513). – trashgod Jan 31 '15 at 13:46

0 Answers0