1 Lỗi không run được file Tue Nov 06, 2012 9:34 pm
1101817
Vịt mới lớn
code 1 cua minh bi loi chay hog duoc,minh copy no wa cai class khac sua ten lai lam code 2 ,code 2 chay duoc ..hog hieu bi loi j mong BQT giai thich dum minh thanks BQT nhiu
code 1 :
public class JCombox{
private JFrame frame;
private JComboBox com;
private final String[] thang={"1","2","3","4","5","6","7","8","9","10","11","12"};
public JCombox(){
frame = new JFrame();
com = new JComboBox(thang);
label = new JLabel("Thang");
frame.add(label);
frame.setTitle("JCombox example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,500);
frame.setLayout(new FlowLayout());
frame.add(com);
frame.setVisible(true);
}
public static void main(String[] args){
JCombox cb = new JCombox();
}
}
code 2:
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.*;
/**
*
* @author Administrator
*/
public class test {
private JFrame frame;
private JComboBox com;
private JLabel label;
private final String[] thang={"1","2","3","4","5","6","7","8","9","10","11","12"};
public test(){
frame = new JFrame();
com = new JComboBox(thang);
label = new JLabel("Thang");
frame.add(label);
frame.setTitle("JCombox example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,500);
frame.setLayout(new FlowLayout());
frame.add(com);
frame.setVisible(true);
}
public static void main(String[] args){
test cb = new test();
}
}
code 1 :
public class JCombox{
private JFrame frame;
private JComboBox com;
private final String[] thang={"1","2","3","4","5","6","7","8","9","10","11","12"};
public JCombox(){
frame = new JFrame();
com = new JComboBox(thang);
label = new JLabel("Thang");
frame.add(label);
frame.setTitle("JCombox example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,500);
frame.setLayout(new FlowLayout());
frame.add(com);
frame.setVisible(true);
}
public static void main(String[] args){
JCombox cb = new JCombox();
}
}
code 2:
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.*;
/**
*
* @author Administrator
*/
public class test {
private JFrame frame;
private JComboBox com;
private JLabel label;
private final String[] thang={"1","2","3","4","5","6","7","8","9","10","11","12"};
public test(){
frame = new JFrame();
com = new JComboBox(thang);
label = new JLabel("Thang");
frame.add(label);
frame.setTitle("JCombox example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,500);
frame.setLayout(new FlowLayout());
frame.add(com);
frame.setVisible(true);
}
public static void main(String[] args){
test cb = new test();
}
}