GUI没有显示,当我从CMD运行它时,它不会给我一个错误。在CMD中,我输入javac NewJPanel.java
,然后输入java NewJPanel
,然后它就不会弹出任何窗口。
/**
*
* @author Kevin
*/
import java.awt.*;
public class NewJPanel extends javax.swing.JPanel {
NewJPanel(){
setVisible(true);
setSize(300,400);
}
/**
* Creates new form NewJPanel
*/
public static void main(String[] args) {
new NewJPanel();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
lblDH1 = new javax.swing.JLabel();
lblDM1 = new javax.swing.JLabel();
lblDN1 = new javax.swing.JLabel();
lblDH2 = new javax.swing.JLabel();
lblDM2 = new javax.swing.JLabel();
lblDN2 = new javax.swing.JLabel();
lblDH3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
tfDH3 = new javax.swing.JTextArea();
jScrollPane4 = new javax.swing.JScrollPane();
tfDN2 = new javax.swing.JTextArea();
jScrollPane5 = new javax.swing.JScrollPane();
tfDM3 = new javax.swing.JTextArea();
jScrollPane6 = new javax.swing.JScrollPane();
tfDN3 = new javax.swing.JTextArea();
jScrollPane7 = new javax.swing.JScrollPane();
tfDN1 = new javax.swing.JTextArea();
jScrollPane8 = new javax.swing.JScrollPane();
tfTV1 = new javax.swing.JTextArea();
btnCalcular = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jScrollPane10 = new javax.swing.JScrollPane();
jTextArea10 = new javax.swing.JTextArea();
jScrollPane11 = new javax.swing.JScrollPane();
tfTV3 = new javax.swing.JTextArea();
jScrollPane12 = new javax.swing.JScrollPane();
tfPH = new javax.swing.JTextArea();
lblDM3 = new javax.swing.JLabel();
lblDN3 = new javax.swing.JLabel();
lblTV1 = new javax.swing.JLabel();
lblTV3 = new javax.swing.JLabel();
lblPH = new javax.swing.JLabel();
jScrollPane13 = new javax.swing.JScrollPane();
tfDH1 = new javax.swing.JTextArea();
jScrollPane14 = new javax.swing.JScrollPane();
tfDM1 = new javax.swing.JTextArea();
jScrollPane15 = new javax.swing.JScrollPane();
tfDH2 = new javax.swing.JTextArea();
jScrollPane16 = new javax.swing.JScrollPane();
tfDM2 = new javax.swing.JTextArea();
lblTN = new javax.swing.JLabel();
jScrollPane19 = new javax.swing.JScrollPane();
tfTN = new javax.swing.JTextArea();
lblDH1.setText("Deportdos Hombres Vuelo #1");
lblDH1.setName("lblDH1"); // NOI18N
lblDM1.setText("Deportados Mujeres Vuelo #1");
lblDM1.setName("lblDM1"); // NOI18N
lblDN1.setText("Deportados Ninos Vuelo #1");
lblDN1.setName("lblDN1"); // NOI18N
lblDH2.setText("Deportados Hombres Vuelo #2");
lblDH2.setName("lblDH2"); // NOI18N
lblDM2.setText("Deportados Mujeres Vuelo #2");
lblDM2.setName("lblDM2"); // NOI18N
lblDN2.setText("Deportados Ninos Vuelo #2");
lblDN2.setName("lblDN2"); // NOI18N
lblDH3.setText("Deportados Hombres Vuelo #3");
jScrollPane1.setPreferredSize(new java.awt.Dimension(100, 96));
tfDH3.setColumns(20);
tfDH3.setRows(5);
jScrollPane1.setViewportView(tfDH3);
jScrollPane4.setPreferredSize(new java.awt.Dimension(100, 96));
tfDN2.setColumns(20);
tfDN2.setRows(5);
tfDN2.setName("tfDN2"); // NOI18N
jScrollPane4.setViewportView(tfDN2);
jScrollPane5.setPreferredSize(new java.awt.Dimension(100, 96));
tfDM3.setColumns(20);
tfDM3.setRows(5);
jScrollPane5.setViewportView(tfDM3);
jScrollPane6.setPreferredSize(new java.awt.Dimension(100, 96));
tfDN3.setColumns(20);
tfDN3.setRows(5);
jScrollPane6.setViewportView(tfDN3);
jScrollPane7.setPreferredSize(new java.awt.Dimension(100, 96));
tfDN1.setColumns(20);
tfDN1.setRows(5);
tfDN1.setName("tfDN1"); // NOI18N
jScrollPane7.setViewportView(tfDN1);
jScrollPane8.setPreferredSize(new java.awt.Dimension(100, 96));
tfTV1.setEditable(false);
tfTV1.setColumns(20);
tfTV1.setRows(5);
jScrollPane8.setViewportView(tfTV1);
btnCalcular.setText("Calcular");
btnCalcular.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCalcularActionPerformed(evt);
}
});
jLabel10.setText("Llegaron menos de 8 ninos en el vuelo 1");
jLabel11.setText("Llegaron menos de 8 ninos en el vuelo 2");
jLabel12.setText("Llegaron menos de 8 ninos en el vuelo 3");
jScrollPane10.setPreferredSize(new java.awt.Dimension(100, 96));
jTextArea10.setEditable(false);
jTextArea10.setColumns(20);
jTextArea10.setRows(5);
jScrollPane10.setViewportView(jTextArea10);
jScrollPane11.setPreferredSize(new java.awt.Dimension(100, 96));
tfTV3.setEditable(false);
tfTV3.setColumns(20);
tfTV3.setRows(5);
jScrollPane11.setViewportView(tfTV3);
jScrollPane12.setPreferredSize(new java.awt.Dimension(100, 96));
tfPH.setEditable(false);
tfPH.setColumns(20);
tfPH.setRows(5);
jScrollPane12.setViewportView(tfPH);
lblDM3.setText("Deportados Mujeres Vuelo #3");
lblDN3.setText("Deportados Ninos Vuelo #3");
lblTV1.setText("Total Deportados Vuelo #1");
lblTV3.setText("Total Deportados Vuelo #3");
lblPH.setText("Porcentaje de Deportados");
jScrollPane13.setPreferredSize(new java.awt.Dimension(100, 96));
tfDH1.setColumns(20);
tfDH1.setRows(5);
tfDH1.setName("tfDH1"); // NOI18N
jScrollPane13.setViewportView(tfDH1);
jScrollPane14.setPreferredSize(new java.awt.Dimension(100, 96));
tfDM1.setColumns(20);
tfDM1.setRows(5);
tfDM1.setName("tfDM1"); // NOI18N
jScrollPane14.setViewportView(tfDM1);
jScrollPane15.setPreferredSize(new java.awt.Dimension(100, 96));
tfDH2.setColumns(20);
tfDH2.setRows(5);
tfDH2.setName("tfDH1"); // NOI18N
jScrollPane15.setViewportView(tfDH2);
jScrollPane16.setPreferredSize(new java.awt.Dimension(100, 96));
tfDM2.setColumns(20);
tfDM2.setRows(5);
tfDM2.setName("tfDM2"); // NOI18N
jScrollPane16.setViewportView(tfDM2);
lblTN.setText("Grupo con Mayor Numero de Deportados");
jScrollPane19.setPreferredSize(new java.awt.Dimension(100, 96));
tfTN.setEditable(false);
tfTN.setColumns(20);
tfTN.setRows(5);
jScrollPane19.setViewportView(tfTN);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane15, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(70, 70, 70)
.addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblTN)
.addComponent(jScrollPane19, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(5, 5, 5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jLabel11)
.addComponent(jLabel10)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE)
.addComponent(btnCalcular, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(97, 97, 97))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblDH1)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDM1)
.addComponent(lblDH2)
.addComponent(lblDM2)
.addComponent(lblDN2)
.addComponent(lblDN1)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane14, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(70, 70, 70)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPH)
.addComponent(lblTV3)
.addComponent(lblTV1)
.addComponent(lblDM3)
.addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDH3)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDN3)))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(70, 70, 70)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel15)
.addGap(112, 112, 112)
.addComponent(btnCalcular, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(88, 88, 88))
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDH1)
.addComponent(lblDH3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblDM1)
.addComponent(lblDM3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDN1)
.addComponent(lblDN3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDH2)
.addComponent(lblTV1)))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel10)
.addGap(91, 91, 91)
.addComponent(jLabel11)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblDM2)
.addComponent(lblTV3)))
.addComponent(jScrollPane15, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDN2)
.addComponent(lblPH))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(6, 6, 6)
.addComponent(lblTN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane19, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(121, Short.MAX_VALUE))
);
}// </editor-fold>
private void btnCalcularActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
btnCalcularActionPerformed(evt);
if (evt.getSource()== btnCalcular)
{
Migracion dia = new Migracion();
Vuelo vuelo1 = new Vuelo();
Vuelo vuelo2 = new Vuelo();
Vuelo vuelo3 = new Vuelo();
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
int g=0;
int h=0;
int i=0;
a=Integer.parseInt(tfDH1.getText());
b=Integer.parseInt(tfDM1.getText());
c=Integer.parseInt(tfDN1.getText());
d=Integer.parseInt(tfDH2.getText());
e=Integer.parseInt(tfDM2.getText());
f=Integer.parseInt(tfDN2.getText());
g=Integer.parseInt(tfDH3.getText());
h=Integer.parseInt(tfDM3.getText());
i=Integer.parseInt(tfDN3.getText());
dia.setMigra1(a, b, c);
vuelo1.setNHombres(a);
vuelo1.setNMujeres(b);
vuelo1.setNNinos(c);
dia.setMigra2(d, e, f);
vuelo2.setNHombres(d);
vuelo2.setNMujeres(e);
vuelo2.setNNinos(f);
dia.setMigra3(g, h, i);
vuelo3.setNHombres(g);
vuelo3.setNMujeres(h);
vuelo3.setNNinos(i);
int dm=0;
int dh=0;
int dn=0;
String z1;
String y;
dh=vuelo1.getNNinos();
dm=vuelo1.getNHombres();
dn=vuelo1.getNMujeres();
z1=vuelo1.total(dh, dm, dn);
y=vuelo3.total(g, h, i);
jTextArea10.setText(String.valueOf(z1));
tfTV3.setText(String.valueOf(y));
String a1="", a2="", a3="";
a1=vuelo1.advertencia(c);
a2=vuelo2.advertencia(f);
a2=vuelo3.advertencia(i);
if (a1!=" "){
jLabel10.setText("Llegaron Menos de 8 Ninos en el Vuelo 1");
}
if (a2!=" "){
jLabel11.setText("Llegaron Menos de 8 Ninos en el Vuelo 1");
}
if (a3!=" "){
jLabel12.setText("Llegaron Menos de 8 Ninos en el Vuelo 1");
}
tfPH.setText(dia.getPorcentaje());
tfTN.setText(dia.getMayoria());
}
}
// Variables declaration - do not modify
private javax.swing.JButton btnCalcular;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel15;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane10;
private javax.swing.JScrollPane jScrollPane11;
private javax.swing.JScrollPane jScrollPane12;
private javax.swing.JScrollPane jScrollPane13;
private javax.swing.JScrollPane jScrollPane14;
private javax.swing.JScrollPane jScrollPane15;
private javax.swing.JScrollPane jScrollPane16;
private javax.swing.JScrollPane jScrollPane19;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JTextArea jTextArea10;
private javax.swing.JLabel lblDH1;
private javax.swing.JLabel lblDH2;
private javax.swing.JLabel lblDH3;
private javax.swing.JLabel lblDM1;
private javax.swing.JLabel lblDM2;
private javax.swing.JLabel lblDM3;
private javax.swing.JLabel lblDN1;
private javax.swing.JLabel lblDN2;
private javax.swing.JLabel lblDN3;
private javax.swing.JLabel lblPH;
private javax.swing.JLabel lblTN;
private javax.swing.JLabel lblTV1;
private javax.swing.JLabel lblTV3;
private javax.swing.JTextArea tfDH1;
private javax.swing.JTextArea tfDH2;
private javax.swing.JTextArea tfDH3;
private javax.swing.JTextArea tfDM1;
private javax.swing.JTextArea tfDM2;
private javax.swing.JTextArea tfDM3;
private javax.swing.JTextArea tfDN1;
private javax.swing.JTextArea tfDN2;
private javax.swing.JTextArea tfDN3;
private javax.swing.JTextArea tfPH;
private javax.swing.JTextArea tfTN;
private javax.swing.JTextArea tfTV1;
private javax.swing.JTextArea tfTV3;
// End of variables declaration
}
我从NetBeans gui builder获取代码,并将其粘贴到notepad ++中,然后我添加了监听器和一些代码。我也从中删除了包装线。