Freely position Swing elements
Wh开发者_如何学Goy are there these stupid layout managers which position my stuff. I can understand doing that on mobile platforms, where there're many different device sizes. But that's not my target. I want to freely position any component based on coordinates, like a TabbedPane, ScrollPane - where I want it.
Is there any layout-manager that let's me do what I want? Like it is common with Qt Designer, WPF, WindowsForms, and so on? Like it has to be?
Layout managers give you great flexibly, even if you have a fixed sized frame.
I would strongly suggest using them. Checkout the visual guide to get an idea of which ones might be useful to you. Also, you can layer different managers to get additional effects:
http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html
if you want to use absolute positions:
myPanel.setLayout(null);
JButton myButton = new JButton(myPanel);
myButton.setBounds(left, top, width, height);
the response is :
you should use
JFrame frame = new JFrame("Laying Out Components Using Absolute Coordinate");
精彩评论