提示jTextAreal有错误 * To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.hand;
import java.awt.Container;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;/**
*
* @author Administrator
*/
public class StuFr extends javax.swing.JFrame{
/**
* Creates new form StuFr
*
*
JFileChooser chooser=null;
public StuFr() {
initComponents();
setLocation(this);
}
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
/**
* 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() { jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jMenu1.setText("文件");
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
}); jMenuItem1.setText("添加学生");
jMenu1.add(jMenuItem1); jMenuItem2.setText("退出 ");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2); jMenuItem3.setText("打开");
jMenu1.add(jMenuItem3); jMenuItem4.setText("保存");
jMenu1.add(jMenuItem4); jMenuBar1.add(jMenu1); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 279, Short.MAX_VALUE)
); pack();
}// </editor-fold> private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
StuD d1=new StuD(null,true);
d1.setSize(400,300);
setLocation(d1);
d1.setResizable(false);
d1.setVisible(true);
if(d1.getok()==true){
Stu u=d1.getStu();
jTextArea1.append("身份证是:"+u.getIdenid()+"\n");
jTextArea1.append("姓名为:"+u.getName()+"\n");
jTextArea1.append("系部为:"+u.getDepartment()+"\n");
jTextArea1.append("班级为:"+u.getClasses()+"\n\n");
}
} private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
} /**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold> /* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new StuFr().setVisible(true);
}
});
}
public static void setLocation(Container container){ java.awt.Dimension screen=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
java.awt.Dimension Dcontainer=container.getSize(); if(Dcontainer.height>screen.height){ Dcontainer.height=screen.height;
}
if(Dcontainer.width>screen.width){ Dcontainer.width=screen.width;
}
container.setLocation((screen.width-Dcontainer.width)/2,
(screen.height-Dcontainer.height)/2);
}
// Variables declaration - do not modify
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
// End of variables declaration
}
* and open the template in the editor.
*/
package com.hand;
import java.awt.Container;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;/**
*
* @author Administrator
*/
public class StuFr extends javax.swing.JFrame{
/**
* Creates new form StuFr
*
*
JFileChooser chooser=null;
public StuFr() {
initComponents();
setLocation(this);
}
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
/**
* 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() { jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jMenu1.setText("文件");
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
}); jMenuItem1.setText("添加学生");
jMenu1.add(jMenuItem1); jMenuItem2.setText("退出 ");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2); jMenuItem3.setText("打开");
jMenu1.add(jMenuItem3); jMenuItem4.setText("保存");
jMenu1.add(jMenuItem4); jMenuBar1.add(jMenu1); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 279, Short.MAX_VALUE)
); pack();
}// </editor-fold> private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
StuD d1=new StuD(null,true);
d1.setSize(400,300);
setLocation(d1);
d1.setResizable(false);
d1.setVisible(true);
if(d1.getok()==true){
Stu u=d1.getStu();
jTextArea1.append("身份证是:"+u.getIdenid()+"\n");
jTextArea1.append("姓名为:"+u.getName()+"\n");
jTextArea1.append("系部为:"+u.getDepartment()+"\n");
jTextArea1.append("班级为:"+u.getClasses()+"\n\n");
}
} private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
} /**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StuFr.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold> /* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new StuFr().setVisible(true);
}
});
}
public static void setLocation(Container container){ java.awt.Dimension screen=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
java.awt.Dimension Dcontainer=container.getSize(); if(Dcontainer.height>screen.height){ Dcontainer.height=screen.height;
}
if(Dcontainer.width>screen.width){ Dcontainer.width=screen.width;
}
container.setLocation((screen.width-Dcontainer.width)/2,
(screen.height-Dcontainer.height)/2);
}
// Variables declaration - do not modify
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
// End of variables declaration
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货