象这样没有main方法如何运行?public class Earning extends JDialog {
JPanel panel1 = new JPanel();
JLabel jLabel17 = new JLabel();
public Earning(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
} public Earning() {
this(new Frame(), "Earning", false);
this.setSize(600,620);
} private void jbInit() throws Exception {
panel1.setLayout(null);
jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD | Font.ITALIC, 25));
jLabel1.setForeground(Color.red);
colnames2.add(colnames1);
jTable1 = Mytable.maketable(colnames2, colnames); //显示内容
jScrollPane1.getViewport().add(jTable1);//把表装入容器
} public void jButton1_actionPerformed(ActionEvent e) {
String str1=jComboBox1.getSelectedItem().toString()+"-"+jComboBox2.getSelectedItem().toString()+"-"+jComboBox3.getSelectedItem().toString();
String str2=jComboBox4.getSelectedItem().toString()+"-"+jComboBox5.getSelectedItem().toString()+"-"+jComboBox6.getSelectedItem().toString();
Vector vector=new Vector();//用来接收查询结果
Vector vector2=new Vector();
vector= SelectEarning.findAll(jTextField1.getText());//接收返回的结果
if(vector.size()==0){
JOptionPane.showMessageDialog(this, "没有商品的销售信息", "提示",
JOptionPane.ERROR_MESSAGE);
return;
}
double allMoney=0;//用于计算总金额
int i=0;
while(i<vector.size()){
Vector vector1=new Vector();
vector1=(Vector) vector.get(i);
System.out.println(vector1.get(4).toString().substring(0,10));
System.out.println(str1);
System.out.println(SelectEarning.charbj(vector1.get(4).toString().substring(0,10),str1));
System.out.println(SelectEarning.charbj(str2,vector1.get(4).toString().substring(0,10)));
if(SelectEarning.charbj(vector1.get(4).toString().substring(0,10),str1) && SelectEarning.charbj(str2, vector1.get(4).toString())){
Vector vector3=new Vector();
int j=0;
while(j<6){
vector3.add(vector1.get(j).toString());
j++;
}
Double money=new Double(vector1.get(5).toString());
allMoney+=money;
vector2.add(vector3);
}
i++;
}
if(vector2.size()==0){
JOptionPane.showMessageDialog(this, "没有商品的销售信息", "提示",
JOptionPane.ERROR_MESSAGE);
return;
} jLabel12.setText(str1);
jLabel14.setText(str2);
Double allMon =new Double(allMoney);
jLabel16.setText(allMon.toString());
jTable1 = Mytable.maketable(vector2, colnames); //显示内容
jScrollPane1.getViewport().add(jTable1);//把表装入容器
}
}
class Earning_jButton1_actionAdapter implements ActionListener {
private Earning adaptee;
Earning_jButton1_actionAdapter(Earning adaptee) {
this.adaptee = adaptee;
} public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
JPanel panel1 = new JPanel();
JLabel jLabel17 = new JLabel();
public Earning(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
} public Earning() {
this(new Frame(), "Earning", false);
this.setSize(600,620);
} private void jbInit() throws Exception {
panel1.setLayout(null);
jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD | Font.ITALIC, 25));
jLabel1.setForeground(Color.red);
colnames2.add(colnames1);
jTable1 = Mytable.maketable(colnames2, colnames); //显示内容
jScrollPane1.getViewport().add(jTable1);//把表装入容器
} public void jButton1_actionPerformed(ActionEvent e) {
String str1=jComboBox1.getSelectedItem().toString()+"-"+jComboBox2.getSelectedItem().toString()+"-"+jComboBox3.getSelectedItem().toString();
String str2=jComboBox4.getSelectedItem().toString()+"-"+jComboBox5.getSelectedItem().toString()+"-"+jComboBox6.getSelectedItem().toString();
Vector vector=new Vector();//用来接收查询结果
Vector vector2=new Vector();
vector= SelectEarning.findAll(jTextField1.getText());//接收返回的结果
if(vector.size()==0){
JOptionPane.showMessageDialog(this, "没有商品的销售信息", "提示",
JOptionPane.ERROR_MESSAGE);
return;
}
double allMoney=0;//用于计算总金额
int i=0;
while(i<vector.size()){
Vector vector1=new Vector();
vector1=(Vector) vector.get(i);
System.out.println(vector1.get(4).toString().substring(0,10));
System.out.println(str1);
System.out.println(SelectEarning.charbj(vector1.get(4).toString().substring(0,10),str1));
System.out.println(SelectEarning.charbj(str2,vector1.get(4).toString().substring(0,10)));
if(SelectEarning.charbj(vector1.get(4).toString().substring(0,10),str1) && SelectEarning.charbj(str2, vector1.get(4).toString())){
Vector vector3=new Vector();
int j=0;
while(j<6){
vector3.add(vector1.get(j).toString());
j++;
}
Double money=new Double(vector1.get(5).toString());
allMoney+=money;
vector2.add(vector3);
}
i++;
}
if(vector2.size()==0){
JOptionPane.showMessageDialog(this, "没有商品的销售信息", "提示",
JOptionPane.ERROR_MESSAGE);
return;
} jLabel12.setText(str1);
jLabel14.setText(str2);
Double allMon =new Double(allMoney);
jLabel16.setText(allMon.toString());
jTable1 = Mytable.maketable(vector2, colnames); //显示内容
jScrollPane1.getViewport().add(jTable1);//把表装入容器
}
}
class Earning_jButton1_actionAdapter implements ActionListener {
private Earning adaptee;
Earning_jButton1_actionAdapter(Earning adaptee) {
this.adaptee = adaptee;
} public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
一个项目是必须有main()方法的。
如果一个单独的Java文件需要运行仍然需要有主方法,没有则不能运行。