import java.awt.*; import javax.swing.*; public class JBoxDemo { public static void main(String[] a
importjava.awt.*;importjavax.swing.*;publicclassJBoxDemo{publicstaticvoidmain(String[...
import java.awt.*;
import javax.swing.*;
public class JBoxDemo
{
public static void main(String[] args)
{
JFrame frame=new JFrame("JCBD");
frame.setSize(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPanel=frame.getContentPane();
contentPanel.add(createJpanel());
frame.setVisible(true);
}
public static JPanel createJpanel()
{
JPanel panel=new JPanel();
String items[]={"请从下拉列表选择","星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
JComboBox comboBox=new JComboBox(items);
comboBox.setEditable(true);
panel.add(new JLabel("可编辑组合库康:"));
panel.add(comboBox);
panel.setVisible(true);
return panel;
}
}
这段代码有什么不妥
import java.awt.*;
import javax.swing.*;
public class JBoxDemo extends JPanel
{
public static void main (String[] args)
{
JFrame frame=new JFrame("JCBD");
frame.setSize(400,400);
frame.setDefaultCloseOperation
(JFrame.EXIT_ON_CLOSE);
Container
contentPanel=frame.getContentPane
();
JBoxDemo box=new JBoxDemo();
contentPanel.add(box.createJpanel());
frame.setVisible(true);
}
public JPanel createJpanel ()
{
JPanel panel=new JPanel();
String items[]={"请从下拉列表选择","星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
JComboBox comboBox=new JComboBox(items);
comboBox.setEditable(true);
panel.add(new JLabel("可编辑组合库康:"));
panel.add(comboBox);
panel.setVisible(true);
return panel;
}
}
这应该是最佳答案 展开
import javax.swing.*;
public class JBoxDemo
{
public static void main(String[] args)
{
JFrame frame=new JFrame("JCBD");
frame.setSize(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPanel=frame.getContentPane();
contentPanel.add(createJpanel());
frame.setVisible(true);
}
public static JPanel createJpanel()
{
JPanel panel=new JPanel();
String items[]={"请从下拉列表选择","星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
JComboBox comboBox=new JComboBox(items);
comboBox.setEditable(true);
panel.add(new JLabel("可编辑组合库康:"));
panel.add(comboBox);
panel.setVisible(true);
return panel;
}
}
这段代码有什么不妥
import java.awt.*;
import javax.swing.*;
public class JBoxDemo extends JPanel
{
public static void main (String[] args)
{
JFrame frame=new JFrame("JCBD");
frame.setSize(400,400);
frame.setDefaultCloseOperation
(JFrame.EXIT_ON_CLOSE);
Container
contentPanel=frame.getContentPane
();
JBoxDemo box=new JBoxDemo();
contentPanel.add(box.createJpanel());
frame.setVisible(true);
}
public JPanel createJpanel ()
{
JPanel panel=new JPanel();
String items[]={"请从下拉列表选择","星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
JComboBox comboBox=new JComboBox(items);
comboBox.setEditable(true);
panel.add(new JLabel("可编辑组合库康:"));
panel.add(comboBox);
panel.setVisible(true);
return panel;
}
}
这应该是最佳答案 展开
3个回答
展开全部
panel.setVisible(true);
comboBox.setEditable(true);
没必要写,因为默认就是true
import java.awt.*;
import javax.swing.*;
public class BoxDemo extends JPanel {
public static void main(String[] args) {
JFrame frame = new JFrame("JCBD");
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPanel = frame.getContentPane();
BoxDemo box = new BoxDemo();
contentPanel.add(box.createJpanel());
frame.setVisible(true);
}
public JPanel createJpanel() {
JPanel panel = new JPanel();
String items[] = { "请从下拉列表选择", "星期一", "星期二", "星期三", "星期四", "星期五",
"星期六", "星期日" };
JComboBox comboBox = new JComboBox(items);
panel.add(new JLabel("可编辑组合库康:"));
panel.add(comboBox);
return panel;
}
}
comboBox.setEditable(true);
没必要写,因为默认就是true
import java.awt.*;
import javax.swing.*;
public class BoxDemo extends JPanel {
public static void main(String[] args) {
JFrame frame = new JFrame("JCBD");
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPanel = frame.getContentPane();
BoxDemo box = new BoxDemo();
contentPanel.add(box.createJpanel());
frame.setVisible(true);
}
public JPanel createJpanel() {
JPanel panel = new JPanel();
String items[] = { "请从下拉列表选择", "星期一", "星期二", "星期三", "星期四", "星期五",
"星期六", "星期日" };
JComboBox comboBox = new JComboBox(items);
panel.add(new JLabel("可编辑组合库康:"));
panel.add(comboBox);
return panel;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询