I have been stuck in this for a while. The problem is that I want to shift my button to the right side of my screen, but when I use borderlayout.east it removes the other button that I created. Can anyone explain why it does so, and how do I fix this problem?
public static void main(String args[]){
GUI();
}
public static void GUI(){
handle handle = new handle();
JButton buy[] = new JButton[8];
_panel.setLayout(new BorderLayout());
for(int i = 0; i < buy.length; i++){
buy[i] = new JButton("Buy");
_panel.add(buy[i],BorderLayout.EAST);
}
_panel.setPreferredSize(new Dimension(600,600));
//_panel.add(buy, BorderLayout.EAST);
_frame.add(_panel);
_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
_frame.setLocation(500, 100);
_frame.setResizable(false);
_frame.getContentPane();
_frame.pack();
_frame.setVisible(true);
}
}