我正在java中尝试以下代码,但它似乎不适用于某种奇怪的时尚:
JFrame myFrame = new JFrame("Test Frame");
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JFrame.setLayout(new GridLayout());
JPanel myPanel = new JPanel();
myPanel.setLayout(new BorderLayout());
myFrame.add(myPanel);
JButton firstButton = new JButton();
myPanel.add(firstButton);
JButton secondButton = new JButton();
myPanel.remove(firstButton);
myPanel.add(secondButton);
myFrame.repaint();
我究竟做错了什么?