Swings-JFrame

IN my program ,JFrame,JButton1 named VIEW ALL ,JComboBox ,JButton2 by clicking this calender will be displayed select the date ,that selected date will come into JComboBox,JButton3 named BY DATE.
when click on VIEW ALL button data from the database(oracle 10g) will be retrieved into JTable, that table will be displayed in same JFrame.
If we click on BY DATE button data will be displayed by that date only in the same JFrame.
view is like this:
VIEW ALL JCOmboBox JButton2 BY DATE
display of JTable resultsin the same frame
i have written the code for JTable like this;
package crm;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.table.*;
import java.sql.*;
import java.util.*;
import java.lang.*;
* @author rajeshwari
public class Callbacks extends javax.swing.JFrame {
JTable table;
     JTableHeader header;
     Vector data = new Vector();
     String colnames[];
public Callbacks() {
getConnection();
/** 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.
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
// private void initComponents() {
// jPanel1 = new javax.swing.JPanel();
// jPanel2 = new javax.swing.JPanel();
// jButton1 = new javax.swing.JButton();
// jButton2 = new javax.swing.JButton();
// jButton3 = new javax.swing.JButton();
// jButton4 = new javax.swing.JButton();
// jButton5 = new javax.swing.JButton();
// jButton6 = new javax.swing.JButton();
// jButton7 = new javax.swing.JButton();
// jLabel1 = new javax.swing.JLabel();
// jTextField1 = new javax.swing.JTextField();
// jLabel2 = new javax.swing.JLabel();
// jTextField2 = new javax.swing.JTextField();
// jLabel3 = new javax.swing.JLabel();
// jScrollPane1 = new javax.swing.JScrollPane();
// jTextArea1 = new javax.swing.JTextArea();
// jLabel4 = new javax.swing.JLabel();
// jTextField3 = new javax.swing.JTextField();
// jLabel5 = new javax.swing.JLabel();
// jTextField4 = new javax.swing.JTextField();
// jLabel6 = new javax.swing.JLabel();
// jTextField5 = new javax.swing.JTextField();
// jLabel7 = new javax.swing.JLabel();
// jTextField6 = new javax.swing.JTextField();
// jLabel8 = new javax.swing.JLabel();
// jTextField7 = new javax.swing.JTextField();
// jLabel9 = new javax.swing.JLabel();
// jTextField8 = new javax.swing.JTextField();
// jLabel10 = new javax.swing.JLabel();
// jTextField9 = new javax.swing.JTextField();
// jLabel11 = new javax.swing.JLabel();
// jTextField10 = new javax.swing.JTextField();
// jButton8 = new javax.swing.JButton();
// jButton9 = new javax.swing.JButton();
// jPanel3 = new javax.swing.JPanel();
// jLabel12 = new javax.swing.JLabel();
// jTextField11 = new javax.swing.JTextField();
// jLabel13 = new javax.swing.JLabel();
// jTextField12 = new javax.swing.JTextField();
// jLabel14 = new javax.swing.JLabel();
// jTextField13 = new javax.swing.JTextField();
// jLabel15 = new javax.swing.JLabel();
// jTextField14 = new javax.swing.JTextField();
// jScrollPane2 = new javax.swing.JScrollPane();
// jTextPane1 = new javax.swing.JTextPane();
// jButton10 = new javax.swing.JButton();
// jScrollPane3 = new javax.swing.JScrollPane();
// jTextPane2 = new javax.swing.JTextPane();
// jMenuBar1 = new javax.swing.JMenuBar();
// jMenu1 = new javax.swing.JMenu();
// jMenu2 = new javax.swing.JMenu();
// jMenu3 = new javax.swing.JMenu();
// jMenu4 = new javax.swing.JMenu();
// jMenu5 = new javax.swing.JMenu();
// jMenu6 = new javax.swing.JMenu();
// jMenu7 = new javax.swing.JMenu();
// jMenu8 = new javax.swing.JMenu();
// setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
// jButton1.setText("Call Back");
// jButton2.setText("Not Interested");
// jButton3.setText("Person Not Available\n");
// jButton4.setText("Answering Machine");
// jButton5.setText("Person Available");
// jButton6.setText("Do not Call");
// jButton7.setText("Next>>...");
// org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
// jPanel2.setLayout(jPanel2Layout);
// jPanel2Layout.setHorizontalGroup(
// jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel2Layout.createSequentialGroup()
// .addContainerGap()
// .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
// .add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
// .add(jButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
// .add(jButton4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
// .add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
// .add(jButton6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
// .add(jButton7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)))
// jPanel2Layout.setVerticalGroup(
// jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel2Layout.createSequentialGroup()
// .addContainerGap()
// .add(jButton1)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jButton2)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jButton3)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jButton4)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jButton5)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jButton6)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jButton7)
// .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
// jLabel1.setText("\nCustomer ID:");
// jTextField1.setText("852");
// jLabel2.setText("Customer Name:");
// jTextField2.setText("Rajeshwari");
// jLabel3.setText("Address:");
// jTextArea1.setColumns(20);
// jTextArea1.setRows(5);
// jScrollPane1.setViewportView(jTextArea1);
// jLabel4.setText("City:");
// jTextField3.setText("HYD");
// jLabel5.setText("State:");
// jTextField4.setText("A.P");
// jLabel6.setText("Zip:");
// jTextField5.setText("39");
// jLabel7.setText("Phone:");
// jTextField6.setText("220288");
// jLabel8.setText("Mobile:");
// jTextField7.setText("9949162978");
// jLabel9.setText("Fax:");
// jTextField8.setText("2343535");
// jLabel10.setText("Email:");
// jTextField9.setText("[email protected]");
// jLabel11.setText("Call Time:");
// jTextField10.setText("12:34:23");
// jButton8.setText("Call Backs");
// jButton8.addActionListener(new java.awt.event.ActionListener() {
// public void actionPerformed(java.awt.event.ActionEvent evt) {
// jButton8ActionPerformed(evt);
// jButton9.setText("Hang");
// jLabel12.setText("Call Back Date:");
// jTextField11.setText("12-03-98");
// jLabel13.setText("Call Back Time:");
// jTextField12.setText("12:23:45");
// jLabel14.setText("Called on:");
// jTextField13.setText("11:12:99");
// jLabel15.setText("Called At:");
// jTextField14.setText("jTextField14");
// jScrollPane2.setViewportView(jTextPane1);
// jButton10.setText("ADD");
// org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
// jPanel3.setLayout(jPanel3Layout);
// jPanel3Layout.setHorizontalGroup(
// jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel3Layout.createSequentialGroup()
// .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel3Layout.createSequentialGroup()
// .addContainerGap()
// .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel3Layout.createSequentialGroup()
// .add(jLabel12)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jTextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(jPanel3Layout.createSequentialGroup()
// .add(jLabel13)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jTextField12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
// .add(27, 27, 27)
// .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
// .add(jPanel3Layout.createSequentialGroup()
// .add(jLabel14)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jTextField13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 84, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(jPanel3Layout.createSequentialGroup()
// .add(jLabel15)
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jTextField14))))
// .add(jPanel3Layout.createSequentialGroup()
// .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 187, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(28, 28, 28)
// .add(jButton10)))
// .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
// jPanel3Layout.setVerticalGroup(
// jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel3Layout.createSequentialGroup()
// .addContainerGap()
// .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel12)
// .add(jTextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(jLabel14)
// .add(jTextField13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(17, 17, 17)
// .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel13)
// .add(jTextField12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(jLabel15)
// .add(jTextField14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
// .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
// .add(jButton10)
// .add(22, 22, 22))))
// jScrollPane3.setViewportView(jTextPane2);
// org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
// jPanel1.setLayout(jPanel1Layout);
// jPanel1Layout.setHorizontalGroup(
// jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createSequentialGroup()
// .add(30, 30, 30)
// .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(32, 32, 32)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jLabel2)
// .add(jLabel1)
// .add(jLabel3)
// .add(jLabel4)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
// .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
// .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 46, Short.MAX_VALUE)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createSequentialGroup()
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
// .add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
// .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 149, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(58, 58, 58))
// .add(jPanel1Layout.createSequentialGroup()
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
// .add(org.jdesktop.layout.GroupLayout.LEADING, jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
// .add(jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))
// .add(66, 66, 66))
// .add(jPanel1Layout.createSequentialGroup()
// .add(jTextField5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
// .add(66, 66, 66))))
// .add(jPanel1Layout.createSequentialGroup()
// .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(254, 254, 254)))
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createSequentialGroup()
// .add(jButton8)
// .add(27, 27, 27)
// .add(jButton9))
// .add(jPanel1Layout.createSequentialGroup()
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
// .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
// .add(jLabel8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
// .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel9))
// .add(jLabel10)
// .add(jLabel11))
// .add(6, 6, 6)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
// .add(jTextField10)
// .add(jTextField9)
// .add(jTextField8)
// .add(jTextField7)
// .add(jTextField6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)))
// .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 212, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(45, 45, 45))
// jPanel1Layout.setVerticalGroup(
// jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createSequentialGroup()
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createSequentialGroup()
// .add(23, 23, 23)
// .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(jPanel1Layout.createSequentialGroup()
// .add(42, 42, 42)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel1)
// .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(jLabel7)
// .add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jPanel1Layout.createSequentialGroup()
// .add(16, 16, 16)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel2)
// .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(25, 25, 25)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(jLabel3))
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 17, Short.MAX_VALUE)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel4)
// .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(18, 18, 18)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel5)
// .add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(jButton8)
// .add(jButton9)
// .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
// .add(jPanel1Layout.createSequentialGroup()
// .add(27, 27, 27)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel8)
// .add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(27, 27, 27)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel9)
// .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(27, 27, 27)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel10)
// .add(jTextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
// .add(34, 34, 34)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
// .add(jLabel11)
// .add(jTextField10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))))
// .add(63, 63, 63)
// .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
// .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(jPanel1Layout.createSequentialGroup()
// .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 88, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .add(44, 44, 44))))
// jMenu1.setText("start");
// jMenuBar1.add(jMenu1);
// jMenu2.setText("Leads");
// jMenuBar1.add(jMenu2);
// jMenu3.setText("Campaign");
// jMenuBar1.add(jMenu3);
// jMenu4.setText("Reports");
// jMenuBar1.add(jMenu4);
// jMenu5.setText("Recordings");
// jMenuBar1.add(jMenu5);
// jMenu6.setText("Agents");
// jMenuBar1.add(jMenu6);
// jMenu7.setText("Time Zones");
// jMenuBar1.add(jMenu7);
// jMenu8.setText("Help");
// jMenuBar1.add(jMenu8);
// setJMenuBar(jMenuBar1);
// org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
// getContentPane().setLayout(layout);
// layout.setHorizontalGroup(
// layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(layout.createSequentialGroup()
// .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
// .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
// layout.setVerticalGroup(
// layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
// .add(layout.createSequentialGroup()
// .add(78, 78, 78)
// .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
// pack();
// }// </editor-fold>
public void getConnection()
// Object src=evt.getSource();
String name="";
String call_back_date="";
String call_back_time="";
String called_on="";
String called_at="";
String phone="";
String comments="";
// if(src==jButton8)
try{
colnames=new String[]{"name","call_back_date","call_back_time","called_on","called_at","phone","comments"};
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:oracle";
Connection con=DriverManager.getConnection(url,"scott","root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from Callbacks_details");
          while (rs.next())
          name=rs.getString("name");
          call_back_date=rs.getString("call_back_date");
          call_back_time=rs.getString("call_back_time");
called_on=rs.getString("called_on");
called_at=rs.getString("called_at");
          phone=rs.getString("phone");
comments=rs.getString("comments");
Vector row = new Vector(colnames.length);
// Vector r=new Vector();
          row.addElement(name);
          row.addElement(call_back_date);
          row.addElement(call_back_time);
row.addElement(called_on);
row.addElement(called_at);
          row.addElement(phone);
row.addElement(comments);
          data.addElement(row);
// System.out.println(data);
catch(Exception a)
a.printStackTrace();
System.out.println(a);
table=new JTable(new MyTableModel(colnames,data));
//int n=table.getColumnCount();
          TableColumn column=null;
          for (int i = 0; i<colnames.length; i++) {
          column = table.getColumnModel().getColumn(i);
     column.setPreferredWidth(100);
          JScrollPane scrollPane = new JScrollPane(table);
          getContentPane().add(scrollPane);
public class MyTableModel extends AbstractTableModel{
String[] columnNames;
     Vector d= new Vector(6);
MyTableModel(String[] columnNames, Vector data){
     this.columnNames = columnNames;
     d = data;
public int getColumnCount() {
return columnNames.length;
public int getRowCount() {
return d.size();
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int row, int col) {
     Vector d

for displaying table on same frame(do not cross post and use code tags just click CODE and paste the code in between)
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
public class TableShow extends JFrame{
    /** Creates a new instance of TableShow */
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    public TableShow() {
        jTable1 = new javax.swing.JTable(5,5);
        jScrollPane1 = new javax.swing.JScrollPane(jTable1);
        jButton1 = new javax.swing.JButton("Show");
        jPanel1 = new javax.swing.JPanel();
        jPanel1.setLayout(new BorderLayout());
        jPanel1.add(jScrollPane1);
        jScrollPane1.setVisible(false);
        getContentPane().add(jButton1, BorderLayout.NORTH);
        getContentPane().add(jPanel1, BorderLayout.CENTER);
        setVisible(true);
        setSize(300,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(jScrollPane1.isVisible()) {
                    jScrollPane1.setVisible(false);
                } else{
                    jScrollPane1.setVisible(true);
                jPanel1.validate();
    public static void main(String args[]){
        new TableShow();
}

Similar Messages

  • Variable textArea not found in class javax.swing.JFrame...

    Making progress on this issue -- but still stuck. Again trying to get the text from a JTextArea on exit:
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
            });User MARSIAN helped me understand the scope fo the variables and now that has been fixed. Unfortunately I cannot access my variable textArea in the above code. If get this error:
    Error: variable textArea not found in class javax.swing.JFrame
    What am I doing wrong?
    import  java.net.*;
    import  javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import FragImpl.*;
    public class Framework extends WindowAdapter {
        public int numWindows = 0;
        private Point lastLocation = null;
        private int maxX = 500;
        private int maxY = 500;
        JFrame frame;
        public Framework() {
            newFrag();
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            maxX = screenSize.width - 50;
            maxY = screenSize.height - 50;
            makeNewWindow();
        public void makeNewWindow() {
            frame = new MyFrame(this);  //*
            numWindows++;
            System.out.println("Number of windows: " + numWindows);
            if (lastLocation != null) {
                //Move the window over and down 40 pixels.
                lastLocation.translate(40, 40);
                if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
                    lastLocation.setLocation(0, 0);
                frame.setLocation(lastLocation);
            } else {
                lastLocation = frame.getLocation();
            System.out.println("Frame location: " + lastLocation);
            frame.setVisible(true);
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
        //This method must be evoked from the event-dispatching thread.
        public void quit(JFrame frame) {
            if (quitConfirmed(frame)) {
                System.exit(0);
            System.out.println("Quit operation not confirmed; staying alive.");
        private boolean quitConfirmed(JFrame frame) {
            String s1 = "Quit";
            String s2 = "Cancel";
            Object[] options = {s1, s2};
            int n = JOptionPane.showOptionDialog(frame,
                    "Windows are still open.\nDo you really want to quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    s1);
            if (n == JOptionPane.YES_OPTION) {
                return true;
            } else {
                return false;
         private void newFrag()
              Frag frag = new FragImpl();
        public static void main(String[] args) {
            Framework framework = new Framework();
    class MyFrame extends JFrame {
        protected Dimension defaultSize = new Dimension(200, 200);
        protected Framework framework = null;
        private Color color = Color.yellow;
        private Container c;
        JTextArea textArea;
        public MyFrame(Framework controller) {
            super("New Frame");
            framework = controller;
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            setSize(defaultSize);
            //Create a text area.
            textArea = new JTextArea(
                    "This is an editable JTextArea " +
                    "that has been initialized with the setText method. " +
                    "A text area is a \"plain\" text component, " +
                    "which means that although it can display text " +
                    "in any font, all of the text is in the same font."
            textArea.setFont(new Font("Serif", Font.ITALIC, 16));
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setBackground ( Color.yellow );
            JScrollPane areaScrollPane = new JScrollPane(textArea);
            //Create the status area.
            JPanel statusPane = new JPanel(new GridLayout(1, 1));
            ImageIcon icoOpen = null;
            URL url = null;
            try
                icoOpen = new ImageIcon("post_it0a.gif"); //("doc04d.gif");
            catch(Exception ex)
                ex.printStackTrace();
                System.exit(1);
            setIconImage(icoOpen.getImage());
            c = getContentPane();
            c.setBackground ( Color.yellow );
            c.add ( areaScrollPane, BorderLayout.CENTER )  ;
            c.add ( statusPane, BorderLayout.SOUTH );
            c.repaint ();
    }

    Yeah!!! It works. Turned out to be a combination of DrKlap's and Martisan's suggestions -- had to change var frame's declaration from JFrame to MyFrame:
        MyFrame frame;Next, created the external class -- but again changed JFrame references to MyFrame:
    public class ShowOnExit extends WindowAdapter {
    //   JFrame aFrame;
       MyFrame aFrame;
       public ShowOnExit(MyFrame f) {
          aFrame = f;
       public void windowClosing(WindowEvent e)
          System.out.println("Why me???" + aFrame.textArea.getText()); // aFrame here not frame !!!
    }This worked. So looks like even though the original code added a WindowListener to 'frame', the listener didn't couldn't access frame's methods unless it was explicitly passed in as a parameter. Let me know if that's wrong.
    Thanks again, all.

  • GUI Problem (Swing JFrame/JPanel). HELP!

    Hi,
    I made an small application for calculate some things.
    I download i piece of code for creating bar chart and i icluded in my code. But i have problem when i am trying to show the chart in the Frame. All the buttons, textfields, labels goes to left and half are hiding.
    If i open the chart on a new frame i dont have problem.
    the problem apears when after i put the panel in the frame i try to put the chart in the frame. Look the code:
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!that command mades me the problem!
    Here are 2 screenshots
    1. When i put the chart in the Frame (the problem)
    http://www.iweb.gr/images/InFrame.jpg
    2. When i put the chart on new frame (works fine)
    http://www.iweb.gr/images/NewFrame.jpg
    Hopes someone can help. Thanks
    The code List:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    //The main class of the program
    public class PlantFertilizer  extends JFrame{//The main class is a subclass of Frame
         private Label lN, lP,lK;//These show the value of the observable
         public TextField tN, tP, tK;
         private MyData thedata;//The observable we are going to watch
         private double[] values=new double[3];
        private String[] names=new String[3];
        private String title;
    public PlantFertilizer(){
         thedata=new MyData();// create the observable
         addWindowListener(new WindowAdapter(){//if user closes the Frame, quit
              public void windowClosing(WindowEvent e){
                   System.exit(0);
         setSize(400,500);//Set size
         setTitle(getClass().getName()+" By Pantelis Stoumpis");
         JPanel p = new JPanel();    //Make a panel for buttons and output
         //Input Data Area
         p.add(new Label("-------------------------Input Data Area--------------------------",Label.CENTER));
         p.add(new Label("Nitrogen (N)"));
         tN = new TextField();p.add(tN);
         p.add(new Label("Phosphorus (P)"));
         tP = new TextField();p.add(tP);
         p.add(new Label("Potassium (K)"));
         tK = new TextField();p.add(tK);
         lN=new Label("N = %", Label.CENTER);
         p.add(lN);     //Put the N label in the panel
         lP=new Label("P = %", Label.CENTER);
         p.add(lP);          //Put the P label in the panel
         lK=new Label("K = %", Label.CENTER);
         p.add(lK);          //Put the K label in the panel
         addButton(p,"Apply",          //Apply new Values
         new ActionListener(){
         public void actionPerformed(ActionEvent evt){
              int iNt = Integer.parseInt(tN.getText());
              int iPt = Integer.parseInt(tP.getText());
              int iKt = Integer.parseInt(tK.getText());
              thedata.addOne(iNt,iPt,iKt);          //which adds one to the observable
              JFrame f = new JFrame();
             f.setSize(400, 300);
              values[0] = 40;
             names[0] = "N";
             values[1] = 20;
             names[1] = "P";
             values[2] = 30;
             names[2] = "K";
             f.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"));
              f.setVisible(true);
         addButton(p,"Close",          //add a close button to quit the program
         new ActionListener(){
         public void actionPerformed(ActionEvent evt){
              System.exit(0);
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!
    //A utility function to add a button with a given title and action
    public void addButton(Container c, String title,ActionListener a)
              Button b=new Button(title);
              c.add(b);
              b.addActionListener(a);
    public class ChartPanel extends JPanel {
      private double[] values;
      private String[] names;
      private String title;
      public ChartPanel(double[] v, String[] n, String t) {
        names = n;
        values = v;
        title = t;
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (values == null || values.length == 0)
          return;
        double minValue = 0;
        double maxValue = 0;
        for (int i = 0; i < values.length; i++) {
          if (minValue > values)
    minValue = values[i];
    if (maxValue < values[i])
    maxValue = values[i];
    //Dimension d = getSize();
    //int clientWidth = d.width;
    //int clientHeight = d.height;
    //int barWidth = clientWidth / values.length;
    //Dimension d = 100;
         int clientWidth = 100;
         int clientHeight = 150;
    int barWidth = clientWidth / values.length;
    Font titleFont = new Font("SansSerif", Font.BOLD, 12);
    FontMetrics titleFontMetrics = g.getFontMetrics(titleFont);
    Font labelFont = new Font("SansSerif", Font.PLAIN, 10);
    FontMetrics labelFontMetrics = g.getFontMetrics(labelFont);
    int titleWidth = titleFontMetrics.stringWidth(title);
    int y = titleFontMetrics.getAscent();
    int x = (clientWidth - titleWidth) / 2;
    g.setFont(titleFont);
    g.drawString(title, 10, 300);
    int top = titleFontMetrics.getHeight();
    int bottom = labelFontMetrics.getHeight();
    if (maxValue == minValue)
    return;
    double scale = (clientHeight - top - bottom) / (maxValue - minValue);
    y = clientHeight - labelFontMetrics.getDescent();
    g.setFont(labelFont);
    for (int i = 0; i < values.length; i++) {
    int valueX = i * barWidth + 1;
    int valueY = top;
    int height = (int) (values[i] * scale);
    if (values[i] >= 0)
    valueY += (int) ((maxValue - values[i]) * scale);
    else {
    valueY += (int) (maxValue * scale);
    height = -height;
    g.setColor(Color.red);
    g.fillRect(valueX, valueY, barWidth - 2, height);
    g.setColor(Color.black);
    g.drawRect(valueX, valueY, barWidth - 2, height);
    int labelWidth = labelFontMetrics.stringWidth(names[i]);
    x = i * barWidth + (barWidth - labelWidth) / 2;
    g.drawString(names[i], x, y);
    //main is called when we start the application
    public static void main(String[]args){
                   PlantFertilizer od = new PlantFertilizer();//make an observationsDemo frame
                   NWatcher watchitN = new NWatcher(od.lN);//make an observer
                   od.thedata.addObserver(watchitN);//register observer with the observable
                   PWatcher watchitP = new PWatcher(od.lP);//make an observer
                   od.thedata.addObserver(watchitP);//register observer with the observable
                   KWatcher watchitK = new KWatcher(od.lK);//make an observer
                   od.thedata.addObserver(watchitK);//register observer with the observable
                   od.setVisible(true);//show the frame on the screen

    Why are you putting Labels and TextFields (heavyweight AWT components) into a lightweight JPanels?
    What's the first rule of Swing? DO NOT MIX heavyweight AWT components and lightweight Swing components. Period. Never.
    There's Swing equivalents for every single AWT component, and then some. There's no excuse for not using them.
    However, if this chart library code is AWT based, then you should make a completely AWT based UI. Or find a different library based on Swing (like JFreeChart).
    And finally:
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!is wrong....
    add(p);      // <-- The problem!!
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"));You don't call add on JFrame or JDialog to add things to it, unless you know what you're doing. And you clearly don't, else you wouldn't have done it. What you probably want to do is this:
    this.getContentPane().add(p, BorderLayout.SOUTH);
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"), BorderLayout.CENTER);

  • Using setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); ...?

    using setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
    JFrame Window will cover windows toolbar.
    how to create JFrame&#65292;make it max size,don't cover windows toolbar.

    import javax.swing.*;
    import java.awt.*;
    class Testing
      public void buildGUI()
        JFrame f = new JFrame();
        f.setExtendedState(JFrame.MAXIMIZED_BOTH);
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        f.setMaximizedBounds(env.getMaximumWindowBounds());
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • Flash SWF file within Swing JFrame

    I was wondering whether its possible to open a Flash swf file within a JFrame
    I am looking for a solution similar to the usage of Flash Activex control in .NET
    thanks in advance
    Vikas

    I have read the forum link and other such entries in this forum. I have found the following:
    1.) JFlash - a java based flash player. https://jflash.dev.java.net/
    Could'nt find the app or the official site
    2.) a few projects on sourceforge.org :
    java flash bridge where you embed the flash inside an Integrated Browser Component
    3.) SWT Flash integration.
    I do not find any of these solutions satisfactory.except the SWT/Flash integration which I havent tried.
    My question is that isnt there an easier and simpler way to :
    Embed Flash into Swing app where actionscript and java can communicate.
    I am aware of Remoting and web services. But It is a desktop app I am talking about.
    Can anyone suggest anything?
    thanks in advance..
    from a very frustrated programmer....

  • Error "javax.swing.JFrame"  cannot find symbol  frame.getContentPane90.add

    Getting above errror when running the code below.how do I install the Jframe so the program can see it.Looks like JRE and JDK does not have it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SimpleGui1{
    public static void main(String []args){
    JFrame frame = new JFrame();
    JButton button = new JButton("click me");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane90.add(button);
    frame.setSize(300,300);
    frame.setVisible(true);
    }

    This is the single most amazing thread I have ever+* seen.                                                                                                                                                                                                   

  • Objects in java Swing Jframe

    Can anybody tell me how do I get the list of objects in Jframe.
    Thnaks in adavance
    Dinesh

    use getComponent() methd....
    sami

  • Javax.swing.JFrame snapping ?

    Hi,
    I'll get right to the point.
    I would like to make my jFrames "snap" together when they're close to each other and keep snapped together when they do this. A lot like WinAMP does with it's windows. I have tried to write this snapping code by myself using ComponentMoved(ComponentEvent e) but I humble in the dark when it comes to snapping ... and also the code I wrote just snaps (in a bit buggy way) to the edge of the screen, not to other jFrames. I have looked around and found that java Look and Feel (www.lf2prod.com) has something called windowsnapping ... but the documentation is empty, and I'm more then ever confused. Is there a way to do this "snapping"? Are there methods already written that could simplify my task ? If not, any suggestions on how to implement this window snapping feature by scratch ?
    Thank you all,
    s0gno

    I'm looking for the same thing... except for JInternalFrames. I haven't been able to find anything even remotely close to addressing this issue.

  • Regarding java swing JFrame

    Sir!
    Whenever I Create a JFrame or Frame, the components of the frame are not
    visible until I maxmize the frame window.Once maximized, the components
    remain visible even after restoring to the initial size of the frame set
    by setSize() method.Why?

    Did you call the validate method after adding all the components to your Frame?
    abraham

  • How to integrate Crystal Report viewer on java swing Jframe

    Dear, I want to display crystal reports in java Desktop applicaion. can any one help me how can i display crystal report developed report in java application. i searched best but not able to find right direction.
    Regards,
    Sahibzada
    Edited by: Sahibzada on Jan 27, 2010 4:32 AM

    You can use [i-net Crystal-Clear|http://www.inetsoftware.de/products/crystal-clear]. It is a Java Reporting Framework that can read and execute Crystal Reports files. It is very easy with i-net Crystal-Clear to show a report which is design with Crystal Reports in a Java Swing application.

  • Java.lang.ClassNotFoundException: javax.swing.JFrame

    i have developed a program in java and it is working fine in windows xp, but when i try to execute it in redhat linux, the ff errors are generated:
    Exception in thread "main" java.lang.InternalError: Unexpected exception while defining class WESMOMP$1: java.lang.ClassNotFoundException: javax.net.ssl.HostnameVerifier
       at 0x00362ca3: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x00355b1e: java.lang.Error.Error(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x00363086: java.lang.VirtualMachineError.VirtualMachineError(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x003574be: java.lang.InternalError.InternalError(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x00354abf: java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain) (/usr/lib/./libgcj.so.3)
       at 0x003548a3: java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int) (/usr/lib/./libgcj.so.3)
       at 0x003ebd96: java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x003420f7: gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x00354794: java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/./libgcj.so.3)
       at 0x003427fc: _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/./libgcj.so.3)
       at 0x0033ec6d: java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/./libgcj.so.3)
       at 0x0033549f: _Jv_BytecodeVerifier.verify_instructions_0() (/usr/lib/./libgcj.so.3)
       at 0x0032b7c7: _Jv_VerifyMethod(_Jv_InterpMethod) (/usr/lib/./libgcj.so.3)
       at 0x00323a64: _Jv_PrepareClass(java.lang.Class) (/usr/lib/./libgcj.so.3)
       at 0x00341f88: java.lang.ClassLoader.linkClass0(java.lang.Class) (/usr/lib/./libgcj.so.3)
       at 0x00354b43: java.lang.ClassLoader.resolveClass0(java.lang.Class) (/usr/lib/./libgcj.so.3)
       at 0x003403fc: java.lang.Class.initializeClass() (/usr/lib/./libgcj.so.3)
       at 0x0033ec94: java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/./libgcj.so.3)
       at 0x0033ed2f: java.lang.Class.forName(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x003a6e81: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
       at 0x00349aec: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
       at 0x0031682c: _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/./libgcj.so.3)
       at 0x08048930: ?? (??:0)
       at 0x006f778a: __libc_start_main (/lib/tls/libc.so.6)
       at 0x080486e1: ?? (??:0)I think that java cannot see the javax package.
    also i tried to execute a java program that uses mysql connector, it generated this error:
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
       at 0x00362ca3: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x00355b62: java.lang.Exception.Exception(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x00355218: java.lang.ClassNotFoundException.ClassNotFoundException(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x003ebdb9: java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x003420f7: gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x003547af: java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/./libgcj.so.3)
       at 0x00342839: _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/./libgcj.so.3)
       at 0x0033ec6d: java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/./libgcj.so.3)
       at 0x0033ed2f: java.lang.Class.forName(java.lang.String) (/usr/lib/./libgcj.so.3)
       at 0x0047d007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
       at 0x0047cfc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
       at 0x0032a658: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
       at 0x0032af64: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
       at 0x00328474: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
       at 0x0047ce7c: ?? (??:0)
       at 0x0033cd68: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/./libgcj.so.3)
       at 0x003a6e91: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
       at 0x00349aec: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
       at 0x0031682c: _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/./libgcj.so.3)
       at 0x08048930: ?? (??:0)
       at 0x0074c78a: __libc_start_main (/lib/tls/libc.so.6)
       at 0x080486e1: ?? (??:0)how to install the mysql jdbc connector?
    please help...thx

    First: Check java version
    $java -version
    Second: Run your program with explicit classpath declaration
    $java -cp yourjdbcdriver.jar;yourprogram.jar com.you.program.ClassContainingMainMethodI'm not sure what to use for jar's delimeter semicolon, or colon. Try both.

  • Learning Swing - Can't get JLabel to appear in JFrame

    Hi,
    I'm a complete beginner to Java. I'm taking a course that's moving way too fast, in my opinion, and we're currently studying Swing. I've likely missed a lot of basic basic Java fundamentals due to the speed of this class, so if I'm making a ridiculous mistake, please let me know.
    I'm trying to create the following:
    +"Create a GUI interface using the Swing API. Use the JOptionPane class to create a dialog box to ask the+
    +user for the University Name. Create a JFrame that has a label with the University name and create your+
    +own logo. The window should have the capability of inputting first name , last name, and id for a student+
    +in text fields. Once the id is entered open another dialog box with the student information."+
    I'm pretty much done, I'm just having issues getting the output from the first JFrame to appear in the second JFrame. When I create a new JFrame, the title I specify appears, but the normal syntax for a JLabel just isn't working and I'm not sure why.
    I suspect it has something to do with the general structure of my program rather than my syntax. ...I know I'm missing a lot of fundamentals that I should have developed, thanks to the way the course I'm in is structured.
    I'm posting two .java files. The first, called GUIFrame.java is the class that basically does everything, it calls JOptionPane, opens the first and second JFrames, and uses ActionEvent and ActionListener to read text from the text fields. The second .java file is called GUITest.java and all it does is instantiate GUIFrame and sets the JFrame parameters.
    If anyone has any suggestions, at all, about how to fix this, or especially how to structure these better... Any suggestion would be greatly appreciated.
    CODE:
    import javax.swing.JFrame; //provides basic window features
    import javax.swing.JOptionPane; //simple GUI input/output
    import javax.swing.JLabel; //displays text and images
    import javax.swing.Icon; //interface used to manipulate images
    import javax.swing.ImageIcon; //loads images
    import java.awt.FlowLayout; // specifies how components are arranged
    import javax.swing.SwingConstants; //common constants used with Swing
    import javax.swing.JTextField;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class GUIFrame extends JFrame
         private JLabel line1;
         private JLabel line2;
         private JLabel line3;
         private JLabel line4;
         private JTextField textField1;
         private JTextField textField2;
         private JTextField textField3;
         //This method prompts the user in a JOptionPane for the university's name.
         public static String obtainUniversityName()
              //Obtain user input from JOptionPane input dialog for universityName.
              String uName = JOptionPane.showInputDialog(null,"Enter the University's name","University Name",JOptionPane.QUESTION_MESSAGE);
              return uName;     
         //This method creates an image icon if possible, or it will print an error and return null
         protected ImageIcon createImageIcon(String path,String description)
              java.net.URL imgURL = getClass().getResource(path);
              if (imgURL != null)
                   return new ImageIcon(imgURL, description);
              } else {
                   System.err.println("Couldn't find file: " + path);
                   return null;
         public GUIFrame()
              //Create a new JFrame for the university info to be placed in
              //The title of the window is also declared here
              super(obtainUniversityName());
              //Sets way things are arranged
              setLayout(new FlowLayout());
              //Grabs logo and aligns it with "Welcome to the University"
              ImageIcon logo = createImageIcon("girl.gif","This is a logo");
              line1 = new JLabel("Welcome to the University", logo, JLabel.CENTER);
              add(line1);
              //"First Name" + Text Field
              line2 = new JLabel("First Name");
              add(line2);
              textField1 = new JTextField(10);
              add(textField1);
              //"Last Name" + Text Field
              line3 = new JLabel("Last Name");
              add(line3);
              textField2 = new JTextField(10);
              add(textField2);
              //"Student ID" + Text Field
              line4 = new JLabel("Student ID");
              add(line4);
              textField3 = new JTextField(10);
              add(textField3);
              //Register event handlers
              TextFieldHandler handler = new TextFieldHandler();
              textField1.addActionListener(handler);
              textField2.addActionListener(handler);
              textField3.addActionListener(handler);
         private class TextFieldHandler implements ActionListener
              public void actionPerformed(ActionEvent event)
                   String fname = "";
                   String lname = "";
                   String stuid = "";
                   //When user presses enter in any text field, these set values for input into text field
                   if(event.getSource()==textField1)
                        fname = String.format("First Name: %s", event.getActionCommand());
                             else if(event.getSource()==textField2)
                                  lname=String.format("Last Name: %s", event.getActionCommand());
                                       else if(event.getSource()==textField3)
                                            stuid=String.format("Student ID: %s", event.getActionCommand());
                                                 else
                                                      System.out.println("ERROR! You didn't fill in atleast one of the text boxes...");
                   //Creates a new JFrame with title "Student Info"          
                   JFrame frame2 = new JFrame("Student Info");
                   //Sets way things are arranged
                   setLayout(new FlowLayout());
                   //Temporary - Tests to see that processing of text field events occurs correctly
                   System.out.println(fname);
                   System.out.println(lname);
                   System.out.println(stuid);               
                   //Puts data into JLabels for display in new JFrame
                   JLabel label1=new JLabel(fname);
                   add(label1);
                   JLabel label2=new JLabel("Can you see this!?");
                   add(label2);          
                   JLabel label3=new JLabel(stuid);
                   add(label3);
                   //Sets parameters, size, close, visibility, etc, for new JFrame
                   frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame2.setSize(275,210);
                   frame2.setVisible(true);
              }//end void actionPerformed
         }//end TextFieldHandler
    }//end GUIFrame
    ==================================================================================
    import javax.swing.JFrame; //provides basic window features
    public class GUITest
         public static void main(String args[])
              //Calls on GUIFrame class. Instantiates.
              GUIFrame guiFrame = new GUIFrame();
              //Set the window to exit when closed
              guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Size the window
              guiFrame.setSize(275,210);
              //Center the window on the screen
              guiFrame.setLocationRelativeTo(null);
              //Make the window visible
              guiFrame.setVisible(true);
    }

    Thanks so much for the quick response. Yeah, I guess I'm a bit oblivious, I guess I missed that it was supposed to be another JOptionPane.
    I fixed that and got rid of all the second JFrame stuff. Thank you.
    And you're right, now that I can see my output, it's obvious I have serious issues in the actionPerformed() method with the ActionListener. I guess it's just a simple question of how to take what's in all three boxes and output to JOptionPane. Simple logic I guess.
    I don't completely understand the ActionListener. I've read my textbook about it and looked at a few online resources, but I don't have a complete understanding.
    How then, would I be able to use the ActionListener to get the text from all three text fields?
    The way it is now, as you correctly predicted, it waits for enter to be inputted from each text field and whichever text field you hit enter in, despite what's in the other text fields, is the only thing that is outputted to the string in the JOptionPane.
    Do you have a suggestion for that?
    Thanks again.
    CODE:
    import javax.swing.JFrame; //provides basic window features
    import javax.swing.JOptionPane; //simple GUI input/output
    import javax.swing.JLabel; //displays text and images
    import javax.swing.Icon; //interface used to manipulate images
    import javax.swing.ImageIcon; //loads images
    import java.awt.FlowLayout; // specifies how components are arranged
    import javax.swing.SwingConstants; //common constants used with Swing
    import javax.swing.JTextField;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class GUIFrame extends JFrame
         private JLabel line1;
         private JLabel line2;
         private JLabel line3;
         private JLabel line4;
         private JTextField textField1;
         private JTextField textField2;
         private JTextField textField3;
         //This method prompts the user in a JOptionPane for the university's name.
         public static String obtainUniversityName()
              //Obtain user input from JOptionPane input dialog for universityName.
              String uName = JOptionPane.showInputDialog(null,"Enter the University's name","University Name",JOptionPane.QUESTION_MESSAGE);
              return uName;     
         //This method creates an image icon if possible, or it will print an error and return null
         protected ImageIcon createImageIcon(String path,String description)
              java.net.URL imgURL = getClass().getResource(path);
              if (imgURL != null)
                   return new ImageIcon(imgURL, description);
              } else {
                   System.err.println("Couldn't find file: " + path);
                   return null;
         public GUIFrame()
              //Create a new JFrame for the university info to be placed in
              //The title of the window is also declared here
              super(obtainUniversityName());
              //Sets way things are arranged
              setLayout(new FlowLayout());
              //Grabs logo and aligns it with "Welcome to the University"
              ImageIcon logo = createImageIcon("girl.gif","This is a logo");
              line1 = new JLabel("Welcome to the University", logo, JLabel.CENTER);
              add(line1);
              //"First Name" + Text Field
              line2 = new JLabel("First Name");
              add(line2);
              textField1 = new JTextField(10);
              add(textField1);
              //"Last Name" + Text Field
              line3 = new JLabel("Last Name");
              add(line3);
              textField2 = new JTextField(10);
              add(textField2);
              //"Student ID" + Text Field
              line4 = new JLabel("Student ID");
              add(line4);
              textField3 = new JTextField(10);
              add(textField3);
              //Register event handlers
              TextFieldHandler handler = new TextFieldHandler();
              textField1.addActionListener(handler);
              textField2.addActionListener(handler);
              textField3.addActionListener(handler);
         private class TextFieldHandler implements ActionListener
              public void actionPerformed(ActionEvent event)
                   String fname = "";
                   String lname = "";
                   String stuid = "";
                   //When user presses enter in any text field, these set values for input into text field
                   if(event.getSource()==textField1)
                        fname = String.format("First Name: %s", event.getActionCommand());
                             else if(event.getSource()==textField2)
                                  lname=String.format("Last Name: %s", event.getActionCommand());
                                       else if(event.getSource()==textField3)
                                            stuid=String.format("Student ID: %s", event.getActionCommand());
                                                 else
                                                      System.out.println("ERROR! You didn't fill in atleast one of the text boxes...");
                   String out = fname + "\n" + lname + "\n" + stuid;
                   JOptionPane.showMessageDialog(null,out);
              }//end void actionPerformed
         }//end TextFieldHandler
    }//end GUIFrame
    import javax.swing.JFrame; //provides basic window features
    public class GUITest
         public static void main(String args[])
              //Calls on GUIFrame class. Instantiates.
              GUIFrame guiFrame = new GUIFrame();
              //Set the window to exit when closed
              guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Size the window
              guiFrame.setSize(275,210);
              //Center the window on the screen
              guiFrame.setLocationRelativeTo(null);
              //Make the window visible
              guiFrame.setVisible(true);
    }Edited by: heathercmiller on Apr 5, 2008 8:56 AM

  • Help please with JFRAMES swing  and variables

    Hi...I need some help with Swing.I need to use the variable "datauser" and read it to operate with it( add,multiply,etc)
    I have two independants JFrames.(2 classes in different .java files).
    //FRAME1 get user data
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.*;
    public class FRAME1 extends javax.swing.JFrame {
              public double datauser; //i need this variable
              public JPanel jPanel1;
              public JTextField jTextField1;
              public FRAME1(){
              datauser=this.datauser;
              jPanel1 = new JPanel();
         jTextField1 = new JTextField();
              jTextField1.setText("10");
              JPanel1.add(jTextField1);
              jTextField1.addActionListener(new hearme());
              pack();
    class hearme implements ActionListener{
    public void actionPerformed(ActionEvent e)
    {     datauser= Double.parseDouble(jTextField1.getText()); //people write a number
    In other JFrame class (another .java file) i put:
    public class FRAME2 extends javax.swing.JFrame
              double aux;
              double multiplyby100() {
              aux= datauser *100;
              return aux;
    ANd i cant get anything just errors ..how can i relate to variables from differents Jframes?? I mean..how can i use a variable from Jframe1 in Jframe2. The actual value that people type in that textfield

    oh well thx for ur help...
    I meant ..i have 10 differentes Jframes (10 different clases)
    SO i have 10 differents windows...Then with a combobox ill choose what Jframe will appear.When a window appears i put ,for instance,parameters for calculating a circle area .Then i select rectangle in the combobox list and appear in the principal window its parameters to write in. Then i choose another element in that combobox and i put parameters for a square.Each one is a different window.I dont want to use Jdialog for that.
    The problem is that i want to use a variable defined in one frame to use that value in another class....for example i want to use a variable like this
    double side =double.parse(Textfield.getText()); //in a texfield in frame 1
    And do something with "side" but in a different class.(different file in the same package)
    public class hi() {
    double theside;
    theside=side; //<---------- here i have problems
    //how can i use the variable "side" in the class hi
    The exact point is that i want to get all the parameters from the user for each window that appears.And each class Jframe have their own variables .
    And i want to access to those variables in real time (what people type)
    So i cant find any solution.I have a structure for each window with labels and textfields (to put parameters).And i need to save each variable that people type in those textfields in public variables because i need to operate with data in a different class (for example in a main class).But that data is only saved into the particular classes because variables exist in there.
    Thanks in advance for ur answers .I havent slept for hours trying to think of that
    thanks!

  • Problem with IconImage for JFrame

    If I create an BufferedImage by ImageIO.read for example and then call getScaledInstance on this image and set the scaled Image to a JFrame as the IconImage (via setIconImage(Image image)), the application hangs.
    Has anyone else this problem?

    ok ok, i read it and now think that this is a sscce:
    import java.awt.Image;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class Start
         public static void main(String[] args)
              final JFrame frame = new JFrame();
              final Image image, imageScaled;
              try
                   image = ImageIO.read(new File("test.png"));
                   imageScaled = image.getScaledInstance(8, 8, Image.SCALE_DEFAULT);
                   frame.add(new JLabel(new ImageIcon(image)));
                   //frame.setIconImage(image); works
                   frame.setIconImage(imageScaled); // works not
                   frame.pack();
                   frame.setVisible(true);
              catch (IOException e)
                   System.err.println(e.getMessage());
                   e.printStackTrace(System.err);
    }

  • Problem with JFrame and busy/wait Cursor

    Hi -- I'm trying to set a JFrame's cursor to be the busy cursor,
    for the duration of some operation (usually just a few seconds).
    I can get it to work in some situations, but not others.
    Timing does seem to be an issue.
    There are thousands of posts on the BugParade, but
    in general Sun indicates this is not a bug. I just need
    a work-around.
    I've written a test program below to demonstrate the problem.
    I have the problem on Solaris, running with both J2SE 1.3 and 1.4.
    I have not tested on Windows yet.
    When you run the following code, three JFrames will be opened,
    each with the same 5 buttons. The first "F1" listens to its own
    buttons, and works fine. The other two (F2 and F3) listen
    to each other's buttons.
    The "BUSY" button simply sets the cursor on its listener
    to the busy cursor. The "DONE" button sets it to the
    default cursor. These work fine.
    The "SLEEP" button sets the cursor, sleeps for 3 seconds,
    and sets it back. This does not work.
    The "INVOKE LATER" button does the same thing,
    except is uses invokeLater to sleep and set the
    cursor back. This also does not work.
    The "DELAY" button sleeps for 3 seconds (giving you
    time to move the mouse into the other (listerner's)
    window, and then it behaves just like the "SLEEP"
    button. This works.
    Any ideas would be appreciated, thanks.
    -J
    import java.awt.BorderLayout;
    import java.awt.Cursor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    public class BusyFrameTest implements ActionListener
    private static Cursor busy = Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR);
    private static Cursor done = Cursor.getDefaultCursor();
    JFrame frame;
    JButton[] buttons;
    public BusyFrameTest (String title)
    frame = new JFrame (title);
    buttons = new JButton[5];
    buttons[0] = new JButton ("BUSY");
    buttons[1] = new JButton ("DONE");
    buttons[2] = new JButton ("SLEEP");
    buttons[3] = new JButton ("INVOKE LATER");
    buttons[4] = new JButton ("DELAY");
    JPanel buttonPanel = new JPanel();
    for (int i = 0; i < buttons.length; i++)
    buttonPanel.add (buttons);
    frame.getContentPane().add (buttonPanel);
    frame.pack();
    frame.setVisible (true);
    public void addListeners (ActionListener listener)
    for (int i = 0; i < buttons.length; i++)
    buttons[i].addActionListener (listener);
    public void actionPerformed (ActionEvent e)
    System.out.print (frame.getTitle() + ": " + e.getActionCommand());
    if (e.getActionCommand().equals ("BUSY"))
    frame.setCursor (busy);
    else if (e.getActionCommand().equals ("DONE"))
    frame.setCursor (done);
    else if (e.getActionCommand().equals ("SLEEP"))
    frame.setCursor (busy);
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.print (" finished");
    else if (e.getActionCommand().equals ("INVOKE LATER"))
    frame.setCursor (busy);
    SwingUtilities.invokeLater (thread);
    else if (e.getActionCommand().equals ("DELAY"))
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (busy);
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.print (" finished");
    System.out.println();
    Runnable thread = new Runnable()
    public void run()
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.println (" finished");
    public static void main (String[] args)
    BusyFrameTest f1 = new BusyFrameTest ("F1");
    f1.addListeners (f1);
    BusyFrameTest f2 = new BusyFrameTest ("F2");
    BusyFrameTest f3 = new BusyFrameTest ("F3");
    f2.addListeners (f3); // 2 listens to 3
    f3.addListeners (f2); // 3 listens to 2

    I've had the same problems with cursors and repaints in a swing application, and I was thinking of if I could use invokeLater, but I never got that far with it.
    I still believe you would need a thread for the time consuming task, and that invokeLater is something you only need to use in a thread different from the event thread.

Maybe you are looking for

  • Send email from mail

    I cannot send but I do receive. AOL is the server and I have matched all my settings with my map book pro. and I have done the aol assistant manager. still not working any ideas?

  • How to change color from default black in JS and still retain fade effect?

    Hi, I have got some java script that fades in some text on loading. It is working but I cant seem to change the color and retain the fade in effect. Any ideas? I am using CS5. I think it is something in here that needs changing? <script language="jav

  • How to get detailStamp working in an af:table when using request scope ?

    <af:table var="row" id="t1" value="#{listUsers.users}" summary="Userlist" binding="#{listUsers.ATable}" [...] <af:column sortable="false" headerText="Username" id="c13" filterable="true"> <af:outputText value="#{row.username}" id="ot13"/> </af:column

  • IMessages not functioning on Mac OS X 10.8.2

    I cant decide if this is a Mountain Lion problem or not... I updated to ML and all was fine. I recently got a new iPhone and set that up for iMessage etc. This was in England. I have recently moved to South America. My account is still attached to En

  • Can anyone help me...Why Can't I open a compound clips containing missing files?

    I Have been using FCPX for only a short time and I have a few unfinished projects on the go. But after tidying up an reorganising my hard drives putting FCPx Projects and Events on an external drive. I find some of my projects with compound clips sho