此片介绍的是电阻计算器的界面和一些控制类的设计。
import java.awt.Color;
/**
* This class defines some constant values and objects
* such as color codes, color objects and code for resistor
* types.
*/
public class Defines
{
//----------------------------------------------------------------------//
public static final int MAIN_TYPE_COLOR_BAND = 100;
public static final int MAIN_TYPE_SURFACE_MNT = 200;
public static final int SUBTYPE_THREE_BAND = 101;
public static final int SUBTYPE_FOUR_BAND = 102;
public static final int SUBTYPE_FIVE_BAND = 103;
public static final int SUBTYPE_E24_THREE_NUM = 201;
public static final int SUBTYPE_E24_FOUR_NUM = 202;
public static final int SUBTYPE_E96 = 203;
public static final String _SUBTYPE_THREE_BAND = "三色环电阻";
public static final String _SUBTYPE_FOUR_BAND = "四色环电阻";
public static final String _SUBTYPE_FIVE_BAND = "五色环电阻";
public static final String _SUBTYPE_E24_THREE_NUMS = "E24 三位数标称法";
public static final String _SUBTYPE_E24_FOUR_NUMS = "E24 四位数标称法";
public static final String _SUBTYPE_E96 = "E96 标称法";
//----------------------------------------------------------------------//
/*
* Constant color objects
*/
public static final Color BLACK = Color.BLACK;
public static final Color BROWN = new Color(133,66,0);
public static final Color RED = Color.RED;
public static final Color ORANGE = Color.ORANGE;
public static final Color YELLOW = Color.YELLOW;
public static final Color GREEN = Color.GREEN;
public static final Color BLUE = Color.BLUE;
public static final Color PURPLE = new Color(90,0,173);
public static final Color GRAY = Color.GRAY;
public static final Color WHITE = Color.WHITE;
public static final Color SILVER = new Color(192,192,192);
public static final Color GOLD = new Color(255,255,153);
//----------------------------------------------------------------------//
/*
* Color code
*/
public static final int BLACK_CODE = 0;
public static final int BROWN_CODE = 1;
public static final int RED_CODE = 2;
public static final int ORANGE_CODE = 3;
public static final int YELLOW_CODE = 4;
public static final int GREEN_CODE = 5;
public static final int BLUE_CODE = 6;
public static final int PURPLE_CODE = 7;
public static final int GRAY_CODE = 8;
public static final int WHITE_CODE = 9;
public static final int SILVER_CODE = 10;
public static final int GOLD_CODE = 11;
public static final int THREE_BANDS = 3;
public static final int FOUR_BANDS = 4;
public static final int FIVE_BANDS = 5;
//----------------------------------------------------------------------//
}
import java.awt.Color;
public class ResistorAppPanel {
private JFrame frame;
private ControlClass ctrl = new ControlClass();
private JTextField valDisp;
private JTextField devDisp;
private JTextField paramDisp;
private JTextField valDisp_2;
private JTextField devDisp_2;
private JSpinner inNumBands;
private ButtonGroup BtnGroup = new ButtonGroup();
private JRadioButton selBands[] = new JRadioButton[5];
private JTextField colorDisp[] = new JTextField[5];
private JTextField colDisp_1;
private JTextField colDisp_2;
private JTextField colDisp_3;
private JTextField colDisp_4;
private JTextField colDisp_5;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ResistorAppPanel window = new ResistorAppPanel();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public ResistorAppPanel() {
initialize();
}
/**
* Set color display
* @param _color Color code
*/
public void setColorDisp(int _color)
{
int i;
for (i = 0;i < 5;i++)
{
if(selBands[i].isSelected())
{
colorDisp[i].setBackground(getColor(_color));
}
}
}
/**
* Translate color code to color object
* @param _code Color code
* @return Color object
*/
public Color getColor(int _code)
{
Color col = null;
switch(_code)
{
case Defines.BLACK_CODE:
col = Defines.BLACK;
break;
case Defines.BROWN_CODE:
col = Defines.BROWN;
break;
case Defines.RED_CODE:
col = Defines.RED;
break;
case Defines.ORANGE_CODE:
col = Defines.ORANGE;
break;
case Defines.YELLOW_CODE:
col = Defines.YELLOW;
break;
case Defines.GREEN_CODE:
col = Defines.GREEN;
break;
case Defines.BLUE_CODE:
col = Defines.BLUE;
break;
case Defines.PURPLE_CODE:
col = Defines.PURPLE;
break;
case Defines.GRAY_CODE:
col = Defines.GRAY;
break;
case Defines.WHITE_CODE:
col = Defines.WHITE;
break;
case Defines.SILVER_CODE:
col = Defines.SILVER;
break;
case Defines.GOLD_CODE:
col = Defines.GOLD;
break;
default:break;
}
return col;
}
/**
* Reset pannel
*/
public void reset()
{
int i;
Color bg = new Color(255,255,255);
valDisp.setText("");
devDisp.setText("");
for (i = 0;i < 5;i++)
{
colorDisp[i].setBackground(bg);
}
};
/**
* Initialize the contents of the frame.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initialize() {
frame = new JFrame();
frame.setResizable(false);
frame.setBounds(100, 100, 782, 533);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 753, GroupLayout.PREFERRED_SIZE)
.addContainerGap(13, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 477, GroupLayout.PREFERRED_SIZE)
.addContainerGap(18, Short.MAX_VALUE))
);
JPanel panel = new JPanel();
tabbedPane.addTab("\u8272\u73AF\u7535\u963B", null, panel, null);
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setBounds(10, 10, 356, 53);
layeredPane.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JLayeredPane layeredPane_1 = new JLayeredPane();
layeredPane_1.setBounds(10, 73, 356, 229);
layeredPane_1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JLayeredPane layeredPane_2 = new JLayeredPane();
layeredPane_2.setBounds(376, 10, 362, 100);
layeredPane_2.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JLayeredPane layeredPane_3 = new JLayeredPane();
layeredPane_3.setBounds(376, 120, 362, 318);
layeredPane_3.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JButton black = new JButton("New button");
black.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.BLACK_CODE);
}
});
black.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Black.png"));
JButton brown = new JButton("New button");
brown.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.BROWN_CODE);
}
});
brown.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Brown.png"));
JButton red = new JButton("New button");
red.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.RED_CODE);
}
});
red.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Red.png"));
JButton orange = new JButton("New button");
orange.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.ORANGE_CODE);
}
});
orange.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Orange.png"));
JButton yellow = new JButton("New button");
yellow.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.YELLOW_CODE);
}
});
yellow.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Yellow.png"));
JButton green = new JButton("New button");
green.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.GREEN_CODE);
}
});
green.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Green.png"));
JButton blue = new JButton("New button");
blue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.BLUE_CODE);
}
});
blue.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Blue.png"));
JButton purple = new JButton("New button");
purple.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.PURPLE_CODE);
}
});
purple.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Purple.png"));
JButton gray = new JButton("New button");
gray.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.GRAY_CODE);
}
});
gray.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Grey.png"));
JButton white = new JButton("New button");
white.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.WHITE_CODE);
}
});
white.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\White.png"));
JButton silver = new JButton("New button");
silver.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.SILVER_CODE);
}
});
silver.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Silver.png"));
JButton gold = new JButton("New button");
gold.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColorDisp(Defines.GOLD_CODE);
}
});
gold.setIcon(new ImageIcon("E:\\JAVA Program\\\u7535\u963B\u8BA1\u7B97\u5668\\\u989C\u8272\u56FE\u7247\\Gold.png"));
JLabel lblNewLabel_11 = new JLabel("\u9009\u62E9\u8272\u73AF\u989C\u8272");
lblNewLabel_11.setFont(new Font("宋体", Font.PLAIN, 20));
GroupLayout gl_layeredPane_3 = new GroupLayout(layeredPane_3);
gl_layeredPane_3.setHorizontalGroup(
gl_layeredPane_3.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_3.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel_11)
.addGroup(gl_layeredPane_3.createSequentialGroup()
.addComponent(black, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(brown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(red, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(orange, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_3.createSequentialGroup()
.addComponent(yellow, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(green, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(blue, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(purple, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_3.createSequentialGroup()
.addComponent(gray, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(white, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(silver, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(gold, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(16, Short.MAX_VALUE))
);
gl_layeredPane_3.setVerticalGroup(
gl_layeredPane_3.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_3.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel_11)
.addGap(18)
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.LEADING)
.addComponent(black, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.BASELINE)
.addComponent(brown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(red, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(orange, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.BASELINE)
.addComponent(yellow, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(green, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.BASELINE)
.addComponent(blue, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(purple, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_layeredPane_3.createParallelGroup(Alignment.BASELINE)
.addComponent(gray, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(white, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(silver, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(gold, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addContainerGap(34, Short.MAX_VALUE))
);
layeredPane_3.setLayout(gl_layeredPane_3);
JLabel lblNewLabel_2 = new JLabel("\u7535\u963B\u503C");
lblNewLabel_2.setFont(new Font("宋体", Font.PLAIN, 20));
valDisp = new JTextField();
valDisp.setEditable(false);
valDisp.setFont(new Font("宋体", Font.PLAIN, 20));
valDisp.setColumns(10);
JLabel label_1 = new JLabel("\u8BEF\u5DEE\u503C");
label_1.setFont(new Font("宋体", Font.PLAIN, 20));
devDisp = new JTextField();
devDisp.setEditable(false);
devDisp.setFont(new Font("宋体", Font.PLAIN, 20));
devDisp.setColumns(10);
JLabel lblNewLabel_3 = new JLabel("\u6B27");
lblNewLabel_3.setFont(new Font("宋体", Font.PLAIN, 20));
JLabel label = new JLabel("\u6B27");
label.setFont(new Font("宋体", Font.PLAIN, 20));
GroupLayout gl_layeredPane_2 = new GroupLayout(layeredPane_2);
gl_layeredPane_2.setHorizontalGroup(
gl_layeredPane_2.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_2.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_2.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_layeredPane_2.createSequentialGroup()
.addComponent(lblNewLabel_2)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(valDisp, GroupLayout.PREFERRED_SIZE, 216, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_2.createSequentialGroup()
.addComponent(label_1, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(devDisp)))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_layeredPane_2.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel_3)
.addComponent(label, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addContainerGap(40, Short.MAX_VALUE))
);
gl_layeredPane_2.setVerticalGroup(
gl_layeredPane_2.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_2.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_2.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_2)
.addComponent(valDisp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_3))
.addGap(18)
.addGroup(gl_layeredPane_2.createParallelGroup(Alignment.BASELINE)
.addComponent(devDisp, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addComponent(label_1, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
.addComponent(label, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layeredPane_2.setLayout(gl_layeredPane_2);
JLabel lblNewLabel_1 = new JLabel("\u9009\u62E9\u8272\u73AF");
lblNewLabel_1.setFont(new Font("宋体", Font.PLAIN, 20));
colDisp_1 = new JTextField();
colDisp_1.setEditable(false);
colDisp_1.setFont(new Font("宋体", Font.PLAIN, 20));
colDisp_1.setColumns(10);
colDisp_2 = new JTextField();
colDisp_2.setEditable(false);
colDisp_2.setFont(new Font("宋体", Font.PLAIN, 20));
colDisp_2.setColumns(10);
colDisp_3 = new JTextField();
colDisp_3.setEditable(false);
colDisp_3.setFont(new Font("宋体", Font.PLAIN, 20));
colDisp_3.setColumns(10);
colDisp_4 = new JTextField();
colDisp_4.setEditable(false);
colDisp_4.setFont(new Font("宋体", Font.PLAIN, 20));
colDisp_4.setColumns(10);
colDisp_5 = new JTextField();
colDisp_5.setEditable(false);
colDisp_5.setFont(new Font("宋体", Font.PLAIN, 20));
colDisp_5.setColumns(10);
JRadioButton selBand_1 = new JRadioButton("\u9009\u62E9\u7B2C\u4E00\u8272\u73AF");
selBand_1.setFont(new Font("宋体", Font.PLAIN, 20));
JRadioButton selBand_2 = new JRadioButton("\u9009\u62E9\u7B2C\u4E8C\u8272\u73AF");
selBand_2.setFont(new Font("宋体", Font.PLAIN, 20));
JRadioButton selBand_3 = new JRadioButton("\u9009\u62E9\u7B2C\u4E09\u8272\u73AF");
selBand_3.setFont(new Font("宋体", Font.PLAIN, 20));
JRadioButton selBand_4 = new JRadioButton("\u9009\u62E9\u7B2C\u56DB\u8272\u73AF");
selBand_4.setFont(new Font("宋体", Font.PLAIN, 20));
JRadioButton selBand_5 = new JRadioButton("\u9009\u62E9\u7B2C\u4E94\u8272\u73AF");
selBand_5.setFont(new Font("宋体", Font.PLAIN, 20));
GroupLayout gl_layeredPane_1 = new GroupLayout(layeredPane_1);
gl_layeredPane_1.setHorizontalGroup(
gl_layeredPane_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_1.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_layeredPane_1.createSequentialGroup()
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.LEADING)
.addComponent(selBand_1)
.addComponent(selBand_2)
.addComponent(selBand_3)
.addComponent(selBand_4)
.addComponent(selBand_5))
.addGap(18)
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.TRAILING, false)
.addComponent(colDisp_2, Alignment.LEADING)
.addComponent(colDisp_1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
.addComponent(colDisp_3, Alignment.LEADING)
.addComponent(colDisp_4, Alignment.LEADING)
.addComponent(colDisp_5, Alignment.LEADING))
.addContainerGap(67, Short.MAX_VALUE))
.addGroup(gl_layeredPane_1.createSequentialGroup()
.addComponent(lblNewLabel_1)
.addContainerGap(264, Short.MAX_VALUE))))
);
gl_layeredPane_1.setVerticalGroup(
gl_layeredPane_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_1.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.BASELINE)
.addComponent(selBand_1)
.addComponent(colDisp_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.BASELINE)
.addComponent(selBand_2)
.addComponent(colDisp_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.BASELINE)
.addComponent(colDisp_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(selBand_3))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.BASELINE)
.addComponent(colDisp_4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(selBand_4))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_layeredPane_1.createParallelGroup(Alignment.BASELINE)
.addComponent(colDisp_5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(selBand_5))
.addGap(145))
);
layeredPane_1.setLayout(gl_layeredPane_1);
panel.setLayout(null);
JLabel lblNewLabel = new JLabel("\u9009\u62E9\u8272\u73AF\u6570");
lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 20));
JSpinner selNumBands = new JSpinner();
inNumBands = selNumBands;
/*
* When user choose a particular number of color bands from spinner,
* enable the corresponding number of color bands for selection.
*/
selNumBands.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
if(inNumBands.getValue().toString().equals("3"))
{
selBands[3].setEnabled(false);
selBands[4].setEnabled(false);
ctrl.SetMainType(Defines.MAIN_TYPE_COLOR_BAND);
ctrl.SetSubtypeCode(Defines.SUBTYPE_THREE_BAND);
}
else if(inNumBands.getValue().toString().equals("4"))
{
if(!selBands[3].isEnabled())
{
selBands[3].setEnabled(true);
}
if(selBands[4].isEnabled())
{
selBands[4].setEnabled(false);
}
ctrl.SetMainType(Defines.MAIN_TYPE_COLOR_BAND);
ctrl.SetSubtypeCode(Defines.SUBTYPE_FOUR_BAND);
}
else if(inNumBands.getValue().toString().equals("5"))
{
if(!selBands[3].isEnabled())
{
selBands[3].setEnabled(true);
}
if(!selBands[4].isEnabled())
{
selBands[4].setEnabled(true);
}
ctrl.SetMainType(Defines.MAIN_TYPE_COLOR_BAND);
ctrl.SetSubtypeCode(Defines.SUBTYPE_FIVE_BAND);
}
}
});
//--------------------------------------------------------------------------------//
selNumBands.setModel(new SpinnerNumberModel(3, 3, 5, 1));
selNumBands.setFont(new Font("宋体", Font.PLAIN, 20));
GroupLayout gl_layeredPane = new GroupLayout(layeredPane);
gl_layeredPane.setHorizontalGroup(
gl_layeredPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(selNumBands, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
.addContainerGap(715, Short.MAX_VALUE))
);
gl_layeredPane.setVerticalGroup(
gl_layeredPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel)
.addComponent(selNumBands, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(81, Short.MAX_VALUE))
);
layeredPane.setLayout(gl_layeredPane);
panel.add(layeredPane);
panel.add(layeredPane_2);
panel.add(layeredPane_1);
panel.add(layeredPane_3);
JLayeredPane layeredPane_4 = new JLayeredPane();
layeredPane_4.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
layeredPane_4.setBounds(10, 312, 356, 126);
panel.add(layeredPane_4);
JButton calBtn = new JButton("\u8BA1\u7B97\u963B\u503C");
calBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int i;
Color col[] = new Color[5];
for (i = 0;i < 5;i++)
{
col[i] = colorDisp[i].getBackground();
}
ctrl.setParam(col);
if(ctrl.checkParam())
{
valDisp.setText(Double.toString(ctrl.calculate()));
devDisp.setText(Double.toString(ctrl.calDev()));
}
else
{
JOptionPane.showMessageDialog(null, "输入参数有误!", "错误",JOptionPane.ERROR_MESSAGE);
}
}
});
calBtn.setFont(new Font("宋体", Font.PLAIN, 20));
calBtn.setBounds(10, 10, 178, 46);
layeredPane_4.add(calBtn);
JButton resetBtn = new JButton("\u91CD\u7F6E\u53C2\u6570");
resetBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ctrl.reset();
reset();
}
});
resetBtn.setFont(new Font("宋体", Font.PLAIN, 20));
resetBtn.setBounds(10, 66, 178, 46);
layeredPane_4.add(resetBtn);
JButton closeBtn = new JButton("\u5173\u95ED");
closeBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
frame.dispose();
}
});
closeBtn.setFont(new Font("宋体", Font.PLAIN, 20));
closeBtn.setBounds(198, 10, 148, 102);
layeredPane_4.add(closeBtn);
JPanel panel_1 = new JPanel();
tabbedPane.addTab("\u8D34\u7247\u7535\u963B", null, panel_1, null);
JLayeredPane layeredPane_5 = new JLayeredPane();
layeredPane_5.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JLayeredPane layeredPane_6 = new JLayeredPane();
layeredPane_6.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JLayeredPane layeredPane_7 = new JLayeredPane();
layeredPane_7.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
JLayeredPane layeredPane_8 = new JLayeredPane();
layeredPane_8.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
GroupLayout gl_panel_1 = new GroupLayout(panel_1);
gl_panel_1.setHorizontalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(layeredPane_6, GroupLayout.PREFERRED_SIZE, 498, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addComponent(layeredPane_8, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addComponent(layeredPane_7, GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)))
.addComponent(layeredPane_5, GroupLayout.DEFAULT_SIZE, 728, Short.MAX_VALUE))
.addContainerGap())
);
gl_panel_1.setVerticalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addContainerGap()
.addComponent(layeredPane_5, GroupLayout.PREFERRED_SIZE, 53, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addComponent(layeredPane_6, GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(layeredPane_7, GroupLayout.PREFERRED_SIZE, 106, GroupLayout.PREFERRED_SIZE)
.addGap(10)
.addComponent(layeredPane_8, GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)))
.addContainerGap())
);
JButton calBtn_2 = new JButton("\u8BA1\u7B97\u963B\u503C");
calBtn_2.setFont(new Font("宋体", Font.PLAIN, 20));
JButton resetBtn_2 = new JButton("\u91CD\u7F6E\u53C2\u6570");
resetBtn_2.setFont(new Font("宋体", Font.PLAIN, 20));
JButton closeBtn_2 = new JButton("\u5173\u95ED");
closeBtn_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
}
});
closeBtn_2.setFont(new Font("宋体", Font.PLAIN, 20));
GroupLayout gl_layeredPane_8 = new GroupLayout(layeredPane_8);
gl_layeredPane_8.setHorizontalGroup(
gl_layeredPane_8.createParallelGroup(Alignment.TRAILING)
.addGroup(Alignment.LEADING, gl_layeredPane_8.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_8.createParallelGroup(Alignment.LEADING)
.addComponent(calBtn_2, GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
.addComponent(resetBtn_2, GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
.addComponent(closeBtn_2, GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE))
.addContainerGap())
);
gl_layeredPane_8.setVerticalGroup(
gl_layeredPane_8.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_8.createSequentialGroup()
.addContainerGap()
.addComponent(calBtn_2, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(resetBtn_2, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(closeBtn_2, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addContainerGap(12, Short.MAX_VALUE))
);
layeredPane_8.setLayout(gl_layeredPane_8);
JLabel lblNewLabel_7 = new JLabel("\u963B\u503C");
lblNewLabel_7.setFont(new Font("宋体", Font.PLAIN, 20));
valDisp_2 = new JTextField();
valDisp_2.setEditable(false);
valDisp_2.setFont(new Font("宋体", Font.PLAIN, 20));
valDisp_2.setColumns(10);
JLabel lblNewLabel_8 = new JLabel("\u6B27");
lblNewLabel_8.setFont(new Font("宋体", Font.PLAIN, 20));
JLabel lblNewLabel_9 = new JLabel("\u8BEF\u5DEE");
lblNewLabel_9.setFont(new Font("宋体", Font.PLAIN, 20));
devDisp_2 = new JTextField();
devDisp_2.setEditable(false);
devDisp_2.setFont(new Font("宋体", Font.PLAIN, 20));
devDisp_2.setColumns(10);
JLabel lblNewLabel_10 = new JLabel("\u6B27");
lblNewLabel_10.setFont(new Font("宋体", Font.PLAIN, 20));
GroupLayout gl_layeredPane_7 = new GroupLayout(layeredPane_7);
gl_layeredPane_7.setHorizontalGroup(
gl_layeredPane_7.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_7.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_7.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_7.createSequentialGroup()
.addComponent(lblNewLabel_7)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(valDisp_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(lblNewLabel_8))
.addGroup(gl_layeredPane_7.createSequentialGroup()
.addComponent(lblNewLabel_9)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(devDisp_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(lblNewLabel_10)))
.addContainerGap(26, Short.MAX_VALUE))
);
gl_layeredPane_7.setVerticalGroup(
gl_layeredPane_7.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_7.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_7.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_7)
.addComponent(valDisp_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_8))
.addGap(18)
.addGroup(gl_layeredPane_7.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_9)
.addComponent(devDisp_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_10))
.addContainerGap(30, Short.MAX_VALUE))
);
layeredPane_7.setLayout(gl_layeredPane_7);
JButton seven = new JButton("7");
seven.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"7");
}
});
seven.setFont(new Font("宋体", Font.PLAIN, 30));
JButton four = new JButton("4");
four.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"4");
}
});
four.setFont(new Font("宋体", Font.PLAIN, 30));
JButton one = new JButton("1");
one.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"1");
}
});
one.setFont(new Font("宋体", Font.PLAIN, 30));
JButton zero = new JButton("0");
zero.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"0");
}
});
zero.setFont(new Font("宋体", Font.PLAIN, 30));
JButton eight = new JButton("8");
eight.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"8");
}
});
eight.setFont(new Font("宋体", Font.PLAIN, 30));
JButton five = new JButton("5");
five.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"5");
}
});
five.setFont(new Font("宋体", Font.PLAIN, 30));
JButton two = new JButton("2");
two.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"2");
}
});
two.setFont(new Font("宋体", Font.PLAIN, 30));
JButton nine = new JButton("9");
nine.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"9");
}
});
nine.setFont(new Font("宋体", Font.PLAIN, 30));
JButton six = new JButton("6");
six.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"6");
}
});
six.setFont(new Font("宋体", Font.PLAIN, 30));
JButton three = new JButton("3");
three.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"3");
}
});
three.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnR = new JButton("R");
btnR.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
paramDisp.setText(paramDisp.getText()+"R");
}
});
btnR.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnA = new JButton("A");
btnA.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnB = new JButton("B");
btnB.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnC = new JButton("C");
btnC.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnD = new JButton("D");
btnD.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnE = new JButton("E");
btnE.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnF = new JButton("F");
btnF.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnG = new JButton("G");
btnG.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnH = new JButton("H");
btnH.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnX = new JButton("X");
btnX.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnY = new JButton("Y");
btnY.setFont(new Font("宋体", Font.PLAIN, 30));
JButton btnZ = new JButton("Z");
btnZ.setFont(new Font("宋体", Font.PLAIN, 30));
GroupLayout gl_layeredPane_6 = new GroupLayout(layeredPane_6);
gl_layeredPane_6.setHorizontalGroup(
gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(seven, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(eight, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(four, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(five, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(one, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(two, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addComponent(zero, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(nine, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnA, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnE, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnX, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(six, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnB, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnF, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnY, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(three, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnC, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnG, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addComponent(btnR, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnD, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnH, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(btnZ, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(16, Short.MAX_VALUE))
);
gl_layeredPane_6.setVerticalGroup(
gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addContainerGap()
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addComponent(seven, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(eight, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(nine, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnA, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnE, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnX, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addComponent(four, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(five, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(six, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnB, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnF, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnY, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_layeredPane_6.createSequentialGroup()
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addComponent(one, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(two, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(three, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnC, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnG, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_layeredPane_6.createParallelGroup(Alignment.LEADING)
.addComponent(btnH, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnD, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btnR, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(zero, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addComponent(btnZ, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(19, Short.MAX_VALUE))
);
layeredPane_6.setLayout(gl_layeredPane_6);
JLabel lblNewLabel_4 = new JLabel("\u9009\u62E9\u7535\u963B\u7C7B\u578B");
lblNewLabel_4.setFont(new Font("宋体", Font.PLAIN, 20));
JComboBox selType = new JComboBox();
selType.setFont(new Font("宋体", Font.PLAIN, 20));
selType.setModel(new DefaultComboBoxModel(new String[] {"", "E24", "E96"}));
JLabel lblNewLabel_5 = new JLabel("\u9009\u62E9\u53C2\u6570\u4F4D\u6570");
lblNewLabel_5.setFont(new Font("宋体", Font.PLAIN, 20));
JSpinner selNumParam = new JSpinner();
selNumParam.setModel(new SpinnerNumberModel(3, 3, 4, 1));
selNumParam.setFont(new Font("宋体", Font.PLAIN, 20));
JLabel lblNewLabel_6 = new JLabel("\u53C2\u6570");
lblNewLabel_6.setFont(new Font("宋体", Font.PLAIN, 20));
paramDisp = new JTextField();
paramDisp.setEditable(false);
paramDisp.setFont(new Font("宋体", Font.PLAIN, 20));
paramDisp.setColumns(10);
GroupLayout gl_layeredPane_5 = new GroupLayout(layeredPane_5);
gl_layeredPane_5.setHorizontalGroup(
gl_layeredPane_5.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_5.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel_4)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(selType, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lblNewLabel_5)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(selNumParam, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lblNewLabel_6)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(paramDisp, GroupLayout.PREFERRED_SIZE, 144, GroupLayout.PREFERRED_SIZE)
.addContainerGap(80, Short.MAX_VALUE))
);
gl_layeredPane_5.setVerticalGroup(
gl_layeredPane_5.createParallelGroup(Alignment.LEADING)
.addGroup(gl_layeredPane_5.createSequentialGroup()
.addGap(10)
.addGroup(gl_layeredPane_5.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_4)
.addComponent(selType, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_5)
.addComponent(selNumParam, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_6)
.addComponent(paramDisp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(11, Short.MAX_VALUE))
);
layeredPane_5.setLayout(gl_layeredPane_5);
panel_1.setLayout(gl_panel_1);
frame.getContentPane().setLayout(groupLayout);
BtnGroup.add(selBand_1);
BtnGroup.add(selBand_2);
BtnGroup.add(selBand_3);
BtnGroup.add(selBand_4);
BtnGroup.add(selBand_5);
selBands[0] = selBand_1;
selBands[1] = selBand_2;
selBands[2] = selBand_3;
selBands[3] = selBand_4;
selBands[4] = selBand_5;
selBands[3].setEnabled(false);
selBands[4].setEnabled(false);
colorDisp[0] = colDisp_1;
colorDisp[1] = colDisp_2;
colorDisp[2] = colDisp_3;
colorDisp[3] = colDisp_4;
colorDisp[4] = colDisp_5;
}
}
以下是电阻计算器的操作界面效果。