一开始我弄了一个按钮框,代码为
import javax.swing.JButton;
import javax.swing.JFrame;
public class TestGUI {
public static void main(String[] args) {
JFrame f = new JFrame("LoL");
f.setSize(400, 300);
f.setLocation(200, 200);
f.setLayout(null);
JButton b = new JButton("战舰联盟,点击进入游戏");
b.setBounds(50, 50, 280, 30);
f.add(b);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
然后另一个界面为下拉框,代码为
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class TestGUI {
public static void main(String[] args) {
JFrame f = new JFrame("LoL");
f.setSize(400, 300);
f.setLocation(580, 240);
f.setLayout(null);
//下拉框出现的条目
String[] heros = new String[] { "卡特琳娜", "库奇" };
JComboBox cb = new JComboBox(heros);
cb.setBounds(50, 50, 80, 30);
f.add(cb);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
请问在这两个代码之间加什么能点击“战舰联盟,点击进入游戏”切换到下拉框的界面,谢谢。