Please help debug this code
The following code was developed on Netbeans 3.4 Beta 3 with JDK 1.4.0
Notice that the table column names are not displayed!
I think I should be able to see "Title 1", "Title 2" etc....
Thanks.
/*
* news.java
*
* Created on July 31, 2002, 10:57 AM
*/
/**
*
* @author unknown
*/
public class news extends javax.swing.JFrame {
/** Creates new form news */
public news() {
initComponents();
}
/** 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() {
jDialog1 = new javax.swing.JDialog();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jTable1 = new javax.swing.JTable();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jPanel1.setLayout(new java.awt.GridLayout(2, 0));
jButton1.setText("jButton1");
jPanel1.add(jButton1);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jPanel1.add(jTable1);
jTabbedPane1.addTab("tab1", jPanel1);
getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);
pack();
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new news().show();
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
private javax.swing.JButton jButton1;
private javax.swing.JTable jTable1;
private javax.swing.JDialog jDialog1;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration
}
# 1
Hi,
use JScrollPane not JPanel
At 07:05 PM 7/31/2002 -0400, you wrote:
>The following code was developed on Netbeans 3.4 Beta 3 with JDK 1.4.0
>Notice that the table column names are not displayed!
>I think I should be able to see "Title 1", "Title 2" etc....
>Thanks.
>
>
>
>/*
> * news.java
> *
> * Created on July 31, 2002, 10:57 AM
> */
>
>/**
> *
> * @author unknown
> */
>public class news extends javax.swing.JFrame {
>
>/** Creates new form news */
>public news() {
> initComponents();
>}
>
>/** 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() {
> jDialog1 = new javax.swing.JDialog();
> jTabbedPane1 = new javax.swing.JTabbedPane();
> jPanel1 = new javax.swing.JPanel();
> jButton1 = new javax.swing.JButton();
> jTable1 = new javax.swing.JTable();
>
> addWindowListener(new java.awt.event.WindowAdapter() {
> public void windowClosing(java.awt.event.WindowEvent evt) {
>exitForm(evt);
> }
> });
>
> jPanel1.setLayout(new java.awt.GridLayout(2, 0));
>
> jButton1.setText("jButton1");
> jPanel1.add(jButton1);
>
> jTable1.setModel(new javax.swing.table.DefaultTableModel(
> new Object [][] {
>{null, null, null, null},
>{null, null, null, null},
>{null, null, null, null},
>{null, null, null, null}
> },
> new String [] {
>"Title 1", "Title 2", "Title 3", "Title 4"
> }
> ));
> jPanel1.add(jTable1);
>
> jTabbedPane1.addTab("tab1", jPanel1);
>
> getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);
>
> pack();
>}
>
>/** Exit the Application */
>private void exitForm(java.awt.event.WindowEvent evt) {
> System.exit(0);
>}
>
>/**
>* @param args the command line arguments
>*/
>public static void main(String args[]) {
> new news().show();
>}
>
>// Variables declaration - do not modify
>private javax.swing.JPanel jPanel1;
>private javax.swing.JButton jButton1;
>private javax.swing.JTable jTable1;
>private javax.swing.JDialog jDialog1;
>private javax.swing.JTabbedPane jTabbedPane1;
>// End of variables declaration
>
>}
# 2
Please read Sun's document on Java Code/Programming conventions, which among
other things tells you to use Uppercase first character in class names, and
vice versa for methods, instances and variables (not that you have any
handcrafted ones in this section).
On Thursday 01 August 2002 07:05, Mihai Dobrin wrote:
> The following code was developed on Netbeans 3.4 Beta 3 with JDK 1.4.0
> Notice that the table column names are not displayed!
> I think I should be able to see "Title 1", "Title 2" etc....
> Thanks.
>
>
>
> /*
> * news.java
> *
> * Created on July 31, 2002, 10:57 AM
> */
>
> /**
> *
> * @author unknown
> */
> public class news extends javax.swing.JFrame {
>
>/** Creates new form news */
>public news() {
> initComponents();
>}
>
>/** 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() {
> jDialog1 = new javax.swing.JDialog();
> jTabbedPane1 = new javax.swing.JTabbedPane();
> jPanel1 = new javax.swing.JPanel();
> jButton1 = new javax.swing.JButton();
> jTable1 = new javax.swing.JTable();
>
> addWindowListener(new java.awt.event.WindowAdapter() {
> public void windowClosing(java.awt.event.WindowEvent evt) {
>exitForm(evt);
> }
> });
>
> jPanel1.setLayout(new java.awt.GridLayout(2, 0));
>
> jButton1.setText("jButton1");
> jPanel1.add(jButton1);
>
> jTable1.setModel(new javax.swing.table.DefaultTableModel(
> new Object [][] {
>{null, null, null, null},
>{null, null, null, null},
>{null, null, null, null},
>{null, null, null, null}
> },
> new String [] {
>"Title 1", "Title 2", "Title 3", "Title 4"
> }
> ));
> jPanel1.add(jTable1);
>
> jTabbedPane1.addTab("tab1", jPanel1);
>
> getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);
>
> pack();
>}
>
>/** Exit the Application */
>private void exitForm(java.awt.event.WindowEvent evt) {
> System.exit(0);
>}
>
>/**
>* @param args the command line arguments
>*/
>public static void main(String args[]) {
> new news().show();
>}
>
>// Variables declaration - do not modify
>private javax.swing.JPanel jPanel1;
>private javax.swing.JButton jButton1;
>private javax.swing.JTable jTable1;
>private javax.swing.JDialog jDialog1;
>private javax.swing.JTabbedPane jTabbedPane1;
>// End of variables declaration
>
> }
