关于JAVA对话框程序的问题。怎么办?
"改了。。。package component;IMPORT java。awt。BorderLayout;IMPORT java。awt。Dimension;IMPORT java。awt。GridLayout;IMPORT java。 awt。Toolkit;IMPORT java。awt。event。ActionEvent;IMPORT java。awt。event。ActionListener;IMPORT javax。 swing。ButtonGroup;IMPORT javax。swing。JButton;IMPORT javax。swing。JComboBox;IMPORT...全部
"改了。。。package component;IMPORT java。awt。BorderLayout;IMPORT java。awt。Dimension;IMPORT java。awt。GridLayout;IMPORT java。
awt。Toolkit;IMPORT java。awt。event。ActionEvent;IMPORT java。awt。event。ActionListener;IMPORT javax。
swing。ButtonGroup;IMPORT javax。swing。JButton;IMPORT javax。swing。JComboBox;IMPORT javax。swing。JDialog;IMPORT javax。
swing。JFrame;IMPORT javax。swing。JLabel;IMPORT javax。swing。JPanel;IMPORT javax。swing。JRadioButton;@SuppressWarnings("serial")public class Solve extends JFrame { Dialog dialog; @SuppressWarnings("deprecation") Solve() { setSize(400, 300); setResizable(false); setDefaultCloseOperation(JFrame。
EXIT_ON_CLOSE); Dimension scrsize = Toolkit。getDefaultToolkit()。getScreenSize(); setLocation((scrsize。
width - 300) / 2, (scrsize。height - 150) / 2); add(); show(); } public void add() { JLabel jlabel = new JLabel("请输入你所选取的问题:"); final JComboBox jcombobox = new JComboBox(); JButton jbutton = new JButton("确定"); JPanel jpanel1 = new JPanel(new GridLayout(2, 1, 0, 4)); JPanel jpanel2 = new JPanel(); add(jpanel1, BorderLayout。
NORTH); add(jpanel2, BorderLayout。SOUTH); jpanel1。add(jlabel, BorderLayout。NORTH); jpanel1。add(jcombobox, BorderLayout。
CENTER); jpanel2。add(jbutton); jcombobox。addItem("没方法开机"); jcombobox。addItem("没方法连接网络(互联网)"); jcombobox。
addItem("没方法关电脑"); jbutton。addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { int i = jcombobox。
getSelectedIndex(); String resolveDesc = ""; switch(i){ case 0: resolveDesc = "请检查电源是不是接好"; break; case 1: resolveDesc = "请检查是不是是机箱静电"; break; case 2 : resolveDesc = "请检查硬件是不是有松动"; break; default: resolveDesc = "我也不知道要怎样弄才好啊。
。。"; } dialog = new Dialog(resolveDesc); } }); } class Dialog extends JDialog { @SuppressWarnings("deprecation") Dialog(String resolveDesc) { setSize(350, 200); setResizable(false); Dimension scrsize = Toolkit。
getDefaultToolkit()。getScreenSize(); setLocation((scrsize。width - 250) / 2, (scrsize。height - 100) / 2); JLabel jlabel = new JLabel("处理方法:" resolveDesc); JButton jbutton = new JButton("好的,我去试试"); JPanel jpanel1 = new JPanel(new GridLayout(3, 1, 4, 4)); JPanel jpanel2 = new JPanel(); JPanel jpanel3 = new JPanel(); add(jpanel1, BorderLayout。
NORTH); add(jpanel2); add(jpanel3); jpanel1。add(jlabel); jpanel2。add(jbutton); jpanel3。add(jbutton); jbutton。
addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { // new Dialog2(); } }); show(); } } public static void main(String[] args){ new Solve(); } }"。
收起