3 Replies Latest reply: May 2, 2013 3:08 PM by TPD-Opitz RSS

    grouplayout with defaulttable model

      I am facing a problem while creating a table with default table model and using the group layout to lay all the components on the frame
      all the things are okay for compiling the program as I want but the problem is that all the components included in my table are displayed as strings, I want to know the reason without using other layout manager

      the code
      import javax.swing.*;
      import javax.swing.table.*;
       * @author COMPUTER SHOP
      public class JobsFollowUp extends JFrame {
          //declare the buttons for adding the job and removing for the last row
          JButton addJobButton = new JButton("Add Job");
          JButton removeJobButton = new JButton("Remove Job");
          //declare the engineer names, attach to combo box
          private  final static String[] engineerNames = {"Mohamad Samy", "Ahmad El_Namoury", "Ahmad Ismail"
                                          ,"Mohamad El_Gazar", "Mohamad Tolba", "Mohamad El_Askary"};
          JComboBox engineerNamesComboBox = new JComboBox(engineerNames);
          //declare the plant names, attach to combo box
          private  final static String[] plantNames = {"Qar'a", "A.M LPG", "Shipping"};
          JComboBox plantNamesComboBox = new JComboBox(plantNames);
          //declare the progress, attach to combo box
          private  final static String[] progressCases = {"Finished", "In Progress", "Waiting SD"};
          JComboBox progressCasesComboBox = new JComboBox(progressCases);
          //declare the job description textField
          JTextField jobDescriptionTextField = new JTextField();
          //declare the job description textField
          JTextField jobNoTextField = new JTextField();    
          //declare the table row that contains the editable cells
          private final  Object [][] rowData ={{engineerNames,jobDescriptionTextField,
                                                      plantNamesComboBox, progressCases,
              //declare the data for the column header 
          private static final String[] columnNames = {"Engineer Name", "Job Description",
                                                       "Plant Name", "Progress", " Job No."};
          //declare the grouplayout as the layout manager for the panel
          GroupLayout layout;
          //declare the scroll pane for the table
          JScrollPane tableScrollPane;
      public JobsFollowUp(){
              DefaultTableModel model = new DefaultTableModel(rowData,columnNames) ;
                //declare the jobs table
              JTable jobsTable = new JTable();
              layout = new GroupLayout(getContentPane());
              tableScrollPane = new JScrollPane(jobsTable);
              //arrange the icons in the program as needed
                          .addComponent(tableScrollPane, 0, 375, Short.MAX_VALUE
                      .addContainerGap(15, Short.MAX_VALUE))
              //arrange the icons in the vertical grid
                      .addComponent(tableScrollPane, 0, 170, Short.MAX_VALUE)
                      .addGap(5, 5, 5))
          public static void main(String[] args)
              JobsFollowUp application = new JobsFollowUp();
              application.setSize(700, 500);
      Edited by: Mohamad Samy on May 1, 2013 10:22 PM

      Edited by: Mohamad Samy on May 1, 2013 10:27 PM