0
How to position components i.e. buttons on jframe ?
3 odpowiedzi
+ 1
I typically use JPanels and BorderLayout..
I make my JFrame. then I make my Panels.. then I add them to my frame. I add my buttons to my panels.. for instance, if I wanted my button on the bottom, I would do something like this..
Button mybutton = new Button("Click Me");
JFrame win = new JFrame();
JPanel bottom = new JPanel();
win.add(bottom, BorderLayout.PAGE_END);
Then I would add my button to the bottom panel
bottom.add(mybutton);
0
Thank you very much for you time. i have used the same method yours.However I have three buttons and one label. I want my three buttons to show under the label. So I would like the label to show at the top of the screen and the buttons underneath. I have tried the Borderlayout, GridBagLayout and FlowLayout but none seem to be working
0
there are two ways to set a component :
1. using Functn setBounds(x,y,width,height);
2. Using Graphical method . just by dragging component to desired location
Graphical method can be implemented using Netbeans IDE it is preinstalled plugin
whereas in eclipse u need to install the plugin .