sixchoicepanel.java~11~

来自「Jbuilder100个例子 都是经典例子 对大家学习Jbuilder非常有帮助」· JAVA~11~ 代码 · 共 45 行

JAVA~11~
45
字号
package jpanel;import java.awt.*;import javax.swing.*;/** * Title: * Description: * Copyright:    Copyright (c) 2001 * Company: * @author * @version 1.0 */public class SixChoicePanel extends JPanel {  GridLayout gridLayout1 = new GridLayout();  public SixChoicePanel(String title, String[] buttonLabels) {    try {      jbInit(title,buttonLabels);    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit(String title,String[] buttonLabels) throws Exception {    gridLayout1.setRows(3);    gridLayout1.setColumns(2);    this.setLayout(gridLayout1);    setBorder(BorderFactory.createTitledBorder(title));    ButtonGroup group = new ButtonGroup();    JRadioButton option;    int halfLength = buttonLabels.length/2;  // Assumes even length    for(int i=0; i<halfLength; i++) {      option = new JRadioButton(buttonLabels[i]);      group.add(option);      add(option);      option = new JRadioButton(buttonLabels[i+halfLength]);      group.add(option);      add(option);    }    pack();    setVisible(true);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?