Java中Swing编程的小问题
packagecom;importjava.awt.*;importjavax.swing.*;publicclassUseCase1extendsJFrame{priv...
package com;
import java.awt.*;
import javax.swing.*;
public class UseCase1 extends JFrame{
private static final long serialVersionUID=1L;
private JComboBox<String> comboBox;
public UseCase1(){
super();..................................这里
setVisible(true);
setSize(800,700);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
comboBox=new JComboBox<>();
comboBox.addItem("红");
comboBox.addItem("黄");
comboBox.addItem("蓝");
comboBox.addItem("黑");
Container c=getContentPane();
c.add(comboBox,BorderLayout.NORTH);
final JPanel panel=new JPanel();
c.add(panel,BorderLayout.CENTER);
final JCheckBox checkBox=new JCheckBox();
checkBox.setText("男");
panel.add(checkBox);
final JCheckBox checkBox1=new JCheckBox();
checkBox1.setText("女");
panel.add(checkBox1);
final JPanel panel_1=new JPanel();
c.add(panel_1,BorderLayout.SOUTH);
final JButton okButton=new JButton("确定");
final JButton button1=new JButton("取消");
panel_1.add(okButton);
panel_1.add(button1);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new UseCase1();
}
}
为什么运行起来必须点窗口最大化才显示的出来呢
还有那个SUPER()加与不加好像没什么变化啊 展开
import java.awt.*;
import javax.swing.*;
public class UseCase1 extends JFrame{
private static final long serialVersionUID=1L;
private JComboBox<String> comboBox;
public UseCase1(){
super();..................................这里
setVisible(true);
setSize(800,700);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
comboBox=new JComboBox<>();
comboBox.addItem("红");
comboBox.addItem("黄");
comboBox.addItem("蓝");
comboBox.addItem("黑");
Container c=getContentPane();
c.add(comboBox,BorderLayout.NORTH);
final JPanel panel=new JPanel();
c.add(panel,BorderLayout.CENTER);
final JCheckBox checkBox=new JCheckBox();
checkBox.setText("男");
panel.add(checkBox);
final JCheckBox checkBox1=new JCheckBox();
checkBox1.setText("女");
panel.add(checkBox1);
final JPanel panel_1=new JPanel();
c.add(panel_1,BorderLayout.SOUTH);
final JButton okButton=new JButton("确定");
final JButton button1=new JButton("取消");
panel_1.add(okButton);
panel_1.add(button1);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new UseCase1();
}
}
为什么运行起来必须点窗口最大化才显示的出来呢
还有那个SUPER()加与不加好像没什么变化啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询