Am writing a code on swings and am using null layout so that i can put j components anywhere i like by using set Bounds But when i maximize the J Frame my components will be static.
How can i make components to move automatically. Please help me its important.
And i have to use null layout only cant use any other layout because i have to put so many components to there specific place.
public class ScreenResize extends JFrame{
private static JButton b;
ScreenResize(){
JFrame.setDefaultLookAndFeelDecorated(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
int frameWidth = 200;
int frameHeight = 100;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((int) screenSize.getWidth() - frameWidth, 0, frameWidth, frameHeight);
setVisible(true);
b=new JButton();
b.setBounds(50,50,40,20);
add(b);
}
public static void main(String[] args) {
new ScreenResize();
}
}
Thanks.