selectPanel.add(selectLabel); modePanel.add(briefness); modePanel.add(medium); modePanel.add(difficulty);
northPanel.add(\northPanel.add(\foodPanel = new JPanel();
foodPanel.setLayout(new BorderLayout()); foodColorPanel = new JPanel(); foodSelectPanel = new JPanel(); foodLabel = new JLabel(\食物颜色\foodLabel.setForeground(Color.red); foodBlue = new JRadioButton(\蓝\
foodRed = new JRadioButton(\红\foodGreen = new JRadioButton(\绿\foodYellow = new JRadioButton(\黄\foodOrange = new JRadioButton(\橙\bg2 = new ButtonGroup(); bg2.add(foodBlue); bg2.add(foodRed); bg2.add(foodGreen); bg2.add(foodYellow); bg2.add(foodOrange);
foodColorPanel.add(foodLabel); foodSelectPanel.add(foodBlue); foodSelectPanel.add(foodRed); foodSelectPanel.add(foodGreen); foodSelectPanel.add(foodYellow); foodSelectPanel.add(foodOrange); foodPanel.add(\foodPanel.add(\headPanel = new JPanel();
headPanel.setLayout(new BorderLayout());
headColorPanel = new JPanel(); headSelectPanel = new JPanel(); headLabel = new JLabel(\蛇头颜色\headLabel.setForeground(Color.red); headBlue = new JRadioButton(\蓝\
headRed = new JRadioButton(\红\headGreen = new JRadioButton(\绿\headYellow = new JRadioButton(\黄\headOrange = new JRadioButton(\橙\bg3 = new ButtonGroup(); bg3.add(headBlue); bg3.add(headRed); bg3.add(headGreen); bg3.add(headYellow); bg3.add(headOrange);
headPanel.add(headLabel);
headColorPanel.add(headLabel); headSelectPanel.add(headBlue); headSelectPanel.add(headRed); headSelectPanel.add(headGreen); headSelectPanel.add(headYellow); headSelectPanel.add(headOrange); headPanel.add(\headPanel.add(\bodyPanel = new JPanel();
bodyPanel.setLayout(new BorderLayout()); bodyColorPanel = new JPanel(); bodySelectPanel = new JPanel(); bodyLabel = new JLabel(\蛇身颜色\bodyLabel.setForeground(Color.red); bodyRed = new JRadioButton(\红\
bodyGreen = new JRadioButton(\绿\bodyBlue = new JRadioButton(\蓝\bodyYellow = new JRadioButton(\黄\bodyOrange = new JRadioButton(\橙\
bg4 = new ButtonGroup(); bg4.add(bodyRed); bg4.add(bodyGreen); bg4.add(bodyBlue); bg4.add(bodyYellow); bg4.add(bodyOrange);
bodyPanel.add(bodyLabel);
bodyColorPanel.add(bodyLabel); bodySelectPanel.add(bodyRed); bodySelectPanel.add(bodyGreen); bodySelectPanel.add(bodyBlue); bodySelectPanel.add(bodyYellow); bodySelectPanel.add(bodyOrange); bodyPanel.add(\bodyPanel.add(\centerPanel.add(\centerPanel.add(\centerPanel.add(\showPanel = new JPanel(); defaultPanel = new JPanel(); buttonPanel = new JPanel();
showGrid = new JRadioButton(\显示网格\cancelGrid = new JRadioButton(\取消网格\
bg5 = new ButtonGroup(); bg5.add(showGrid); bg5.add(cancelGrid);
defaultButton = new JButton(\默认设置\confirm = new JButton(\确定\cancel = new JButton(\取消\showPanel.add(showGrid); showPanel.add(cancelGrid); defaultPanel.add(defaultButton); buttonPanel.add(confirm); buttonPanel.add(cancel);
southPanel.add(\southPanel.add(\southPanel.add(\
briefness.setSelected(true); foodBlue.setSelected(true); headBlue.setSelected(true); bodyRed.setSelected(true); cancelGrid.setSelected(true);
this.add(\this.add(\this.add(\
Toolkit tok = Toolkit.getDefaultToolkit(); int width = tok.getScreenSize().width; int height = tok.getScreenSize().height;
this.setBounds((width - 260) / 2, (height - 370) / 2, 260, 405); this.setTitle(\游戏设置\this.setResizable(false);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
defaultButton .addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { briefness.setSelected(true); foodBlue.setSelected(true); headBlue.setSelected(true); bodyRed.setSelected(true); cancelGrid.setSelected(true); } });
confirm.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (briefness.isSelected()) {
相关推荐: