当前位置: 技术问答>java相关
Java中表格的问题!用的是Forte for java! JDK为1.3.01
来源: 互联网 发布时间:2015-03-01
本文导语: /* * TryJApplet.java * * Created on 2001年12月5日, 上午11:12 */ /** * * @author luyong */ import java.awt.*; import javax.swing.*; import javax.swing.table.*; import java.io.*; import java.util.*; public class TryJApplet extends javax.swing.JAppl...
/*
* TryJApplet.java
*
* Created on 2001年12月5日, 上午11:12
*/
/**
*
* @author luyong
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import java.io.*;
import java.util.*;
public class TryJApplet extends javax.swing.JApplet {
/** Creates new form TryJApplet */
public TryJApplet() {
initComponents();
jCBLoadPolicy.addItem("翻译最快");
jCBLoadPolicy.addItem("负载最小");
Object[][] data = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Chasing toddlers", new Integer(2), new Boolean(false)},
{"Mark", "Andrews",
"Speed reading", new Integer(20), new Boolean(true)},
{"Angela", "Lih",
"Teaching high school", new Integer(4), new Boolean(false)}
};
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
detailTalbleModel=new DefaultTableModel(data,columnNames);
detailTable=new JTable(detailTalbleModel); //我自己想定制表格里的行和列
}
/** 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.
*/
private void initComponents() {
mytimer = new org.netbeans.examples.lib.timerbean.Timer();
jPanel13 = new javax.swing.JPanel();
jPanel15 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jPanel16 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jPanel17 = new javax.swing.JPanel();
jLableInputPort = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jPanel18 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
try {
jCBLoadPolicy =(javax.swing.JComboBox)java.beans.Beans.instantiate(getClass().getClassLoader(), "TryJApplet_jComboBox1"); //系统自己添加的
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
}
jPanel19 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
try {
detailTable =(javax.swing.JTable)java.beans.Beans.instantiate(getClass().getClassLoader(), "TryJApplet_jTable1");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
}
mytimer.addTimerListener(new org.netbeans.examples.lib.timerbean.TimerListener() {
public void onTime(java.awt.event.ActionEvent evt) {
mytimerOnTime(evt);
}
});
getContentPane().setLayout(new java.awt.GridLayout(2, 0));
setForeground(java.awt.Color.white);
jPanel13.setLayout(new java.awt.GridLayout(5, 0));
jPanel13.setMinimumSize(new java.awt.Dimension(700, 1100));
jLabel3.setText("u4e3bu63a7u5de5u4f5cu7ad9");
jLabel3.setFont(new java.awt.Font("Dialog", 1, 18));
jPanel15.add(jLabel3);
jPanel13.add(jPanel15);
jPanel16.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel4.setText("u8bf7u8f93u5165u4e3bu63a7u5de5u4f5cu7ad9u7684IPu5730u5740uff1a ");
jLabel4.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel16.add(jLabel4);
jLabel6.setText("255.255.255.255");
jPanel16.add(jLabel6);
jPanel13.add(jPanel16);
jPanel17.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLableInputPort.setText("u8bf7u8f93u5165u4e3bu63a7u5de5u4f5cu7ad9u7684u670du52a1u7aefu53e3uff1a");
jLableInputPort.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel17.add(jLableInputPort);
jLabel5.setText("8001");
jPanel17.add(jLabel5);
jPanel13.add(jPanel17);
jPanel18.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("u8d1fu8f7du5747u8861u7b56u7565: ");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel18.add(jLabel1);
jPanel18.add(jCBLoadPolicy);
jPanel13.add(jPanel18);
jLabel2.setText("u7ffbu8bd1u5f15u64ceu5217u8868 ");
jLabel2.setFont(new java.awt.Font("Dialog", 1, 18));
jPanel19.add(jLabel2);
jPanel13.add(jPanel19);
getContentPane().add(jPanel13);
jScrollPane2.setViewportView(detailTable);
getContentPane().add(jScrollPane2);
}
private void mytimerOnTime(java.awt.event.ActionEvent evt) {
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
detailTalbleModel.addRow(columnNames);// Add your handling code here:
}
private DefaultTableModel detailTalbleModel;
// Variables declaration - do not modify
private org.netbeans.examples.lib.timerbean.Timer mytimer;
private javax.swing.JPanel jPanel13;
private javax.swing.JPanel jPanel15;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel16;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel17;
private javax.swing.JLabel jLableInputPort;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel18;
private javax.swing.JLabel jLabel1;
private javax.swing.JComboBox jCBLoadPolicy;
private javax.swing.JPanel jPanel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable detailTable; //定义一个jTable
// End of variables declaration
}
结果出来的是系统缺省的一个表格!
* TryJApplet.java
*
* Created on 2001年12月5日, 上午11:12
*/
/**
*
* @author luyong
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import java.io.*;
import java.util.*;
public class TryJApplet extends javax.swing.JApplet {
/** Creates new form TryJApplet */
public TryJApplet() {
initComponents();
jCBLoadPolicy.addItem("翻译最快");
jCBLoadPolicy.addItem("负载最小");
Object[][] data = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Chasing toddlers", new Integer(2), new Boolean(false)},
{"Mark", "Andrews",
"Speed reading", new Integer(20), new Boolean(true)},
{"Angela", "Lih",
"Teaching high school", new Integer(4), new Boolean(false)}
};
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
detailTalbleModel=new DefaultTableModel(data,columnNames);
detailTable=new JTable(detailTalbleModel); //我自己想定制表格里的行和列
}
/** 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.
*/
private void initComponents() {
mytimer = new org.netbeans.examples.lib.timerbean.Timer();
jPanel13 = new javax.swing.JPanel();
jPanel15 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jPanel16 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jPanel17 = new javax.swing.JPanel();
jLableInputPort = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jPanel18 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
try {
jCBLoadPolicy =(javax.swing.JComboBox)java.beans.Beans.instantiate(getClass().getClassLoader(), "TryJApplet_jComboBox1"); //系统自己添加的
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
}
jPanel19 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
try {
detailTable =(javax.swing.JTable)java.beans.Beans.instantiate(getClass().getClassLoader(), "TryJApplet_jTable1");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
}
mytimer.addTimerListener(new org.netbeans.examples.lib.timerbean.TimerListener() {
public void onTime(java.awt.event.ActionEvent evt) {
mytimerOnTime(evt);
}
});
getContentPane().setLayout(new java.awt.GridLayout(2, 0));
setForeground(java.awt.Color.white);
jPanel13.setLayout(new java.awt.GridLayout(5, 0));
jPanel13.setMinimumSize(new java.awt.Dimension(700, 1100));
jLabel3.setText("u4e3bu63a7u5de5u4f5cu7ad9");
jLabel3.setFont(new java.awt.Font("Dialog", 1, 18));
jPanel15.add(jLabel3);
jPanel13.add(jPanel15);
jPanel16.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel4.setText("u8bf7u8f93u5165u4e3bu63a7u5de5u4f5cu7ad9u7684IPu5730u5740uff1a ");
jLabel4.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel16.add(jLabel4);
jLabel6.setText("255.255.255.255");
jPanel16.add(jLabel6);
jPanel13.add(jPanel16);
jPanel17.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLableInputPort.setText("u8bf7u8f93u5165u4e3bu63a7u5de5u4f5cu7ad9u7684u670du52a1u7aefu53e3uff1a");
jLableInputPort.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel17.add(jLableInputPort);
jLabel5.setText("8001");
jPanel17.add(jLabel5);
jPanel13.add(jPanel17);
jPanel18.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jLabel1.setText("u8d1fu8f7du5747u8861u7b56u7565: ");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel18.add(jLabel1);
jPanel18.add(jCBLoadPolicy);
jPanel13.add(jPanel18);
jLabel2.setText("u7ffbu8bd1u5f15u64ceu5217u8868 ");
jLabel2.setFont(new java.awt.Font("Dialog", 1, 18));
jPanel19.add(jLabel2);
jPanel13.add(jPanel19);
getContentPane().add(jPanel13);
jScrollPane2.setViewportView(detailTable);
getContentPane().add(jScrollPane2);
}
private void mytimerOnTime(java.awt.event.ActionEvent evt) {
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
detailTalbleModel.addRow(columnNames);// Add your handling code here:
}
private DefaultTableModel detailTalbleModel;
// Variables declaration - do not modify
private org.netbeans.examples.lib.timerbean.Timer mytimer;
private javax.swing.JPanel jPanel13;
private javax.swing.JPanel jPanel15;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel16;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel17;
private javax.swing.JLabel jLableInputPort;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel18;
private javax.swing.JLabel jLabel1;
private javax.swing.JComboBox jCBLoadPolicy;
private javax.swing.JPanel jPanel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable detailTable; //定义一个jTable
// End of variables declaration
}
结果出来的是系统缺省的一个表格!
|
upgz