Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Adding column to JTable with JSlider determined header

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding column to JTable with JSlider determined header

    Hi,

    This is the first time posting, up to now I've managed to use other people's questions to answer any questions I've had, but I have been working on this for two days and have got nowhere.

    I am trying to add a column to a JTable with the header specified by a JSlider (PickNumValue) on the click of a button in a different window. The JSlider and button are in the same class and I have a Default Table Model underpinning my JTable. I have put some code below, however have messed around with this all so much that I am sure it is beyond wrong. What I am in need of is some guidance in terms of how best to achieve what I describe.

    Advice most greatly appreciated,
    Oli

     
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import javax.swing.BoxLayout.*;
     
    public class Data extends JApplet {
        // Cell dimensions
        Dimension celldim = new Dimension(5,5);
        // Create table column names
        private String[] columnNames = {"Individual","Salinity One",
                                    "Salinity Two",
                                   };
     
        // Create table data
        public Object[][] data = {{"One","",""},{"Two","",""},{"Three","",""},
                {"Four","",""},{"Five","",""},{"Six","",""}};
     
     
    //    tableModel.addColumn(U_I.PickNumValue);
        //public static JTable dataTable;        
     
        public class MyTableModel extends DefaultTableModel {
     
            public int getColumnCount() {
            return columnNames.length;
        }
            public int getRowCount() {
            return data.length;
        }
            public String getColumnName(int col) {
            return columnNames[col];
        }
            public Object getValueAt(int row, int col) {
            return data[row][col];
        }
            public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
        }
     
            public void AddPickNumColumn(int s) {
            tableModel.addColumn(U_I.s, new java.util.Vector());
            tableModel.fireTableStructureChanged();
        }
     
            public void columnAdded(TableColumnModelEvent e) {  
            System.out.println("DATAMODEL found a columnAddedEvent!");  
            columnCount++;  
            System.out.println("columnCount now " + columnCount);  
            this.fireTableChanged(new TableModelEvent(this));     
        }
            // public void AddPickNumColumn (){
     
          //      DefaultTableModel tablemodel = (tableModel)getJTable().getModel();
          //      tableModel.addColumn("U_I.s", new java.util.Vector());
          //      tableModel.fireTableStructureChanged();
          //      tableModel.
     
            //}
     
            public void setValueAt(Object value, int row, int col) {
            data[row][col] = value;
            fireTableCellUpdated(row, col);
        }
    //        public void AddPickNumColumn (int PickNumValue) {
    //            tableModel.addColumn(U_I.PickNumValue);
     //       }
        }
     
          // Create a model
        public DefaultTableModel tableModel = 
                new MyTableModel();
     
        // Create a table
        public JTable dataTable = new JTable(tableModel) {
            public boolean isCellEditable(int rowIndex, int columnIndex) {      
                if (columnIndex == 0) {
                return false;}
            else {return true;}
    }
     
       // Transfer Count - doesn't work!!
       //     public void TransferCountValue (){
        //    dataTable.setValueAt(Analyse_.Count,x,y);
        ////    tableModel.fireTableCellUpdated(x,y);       
    //}
                public void AddPickNumColumn (){
     
          //      DefaultTableModel tablemodel = (tableModel)getJTable().getModel();
                tableModel.addColumn("U_I.s", new java.util.Vector());
                tableModel.fireTableStructureChanged();
          //      tableModel.
     
            }
    };
     
        public JScrollPane tablepane;
     
     
        public Data() {
     
            add(new JScrollPane(dataTable), BorderLayout.CENTER);
            //Frame c = (Frame)this.getParent().getParent();  
            //dataTable.setPreferredSize(800,500);
            dataTable.setPreferredScrollableViewportSize(new Dimension(800, 500));
            //dataTable.setFillsViewportHeight(true);
            dataTable.setIntercellSpacing(celldim);
            dataTable.setFont(new Font("Arial", Font.PLAIN, 16));
            dataTable.getTableHeader().setFont(new Font("Arial", Font.BOLD, 16));
            dataTable.setRowHeight(30);
            dataTable.setGridColor(Color.GRAY);
            dataTable.setShowGrid(true);
           // dataTable.setTitle("fd");
            //c.setTitle("Hello World");
     
     
        }
     
     
       ///////// public dataTable.setValueAt {};
        //public int x;
        //public int y;
     
    //    public void TransferCountValue (){
    //    dataTable.setValueAt(Analyse_.Count,x,y);
     //   tableModel.fireTableCellUpdated(x,y);    
     //  
    //}
     //            public class AddPickNumColumn {
      //               data
      //          Data.dataTable.addColumn(U_I.PickNumValue);
      //          tableModel.fireTableStructureChanged();
      ////      }
     
    }

    And from the class containing the JSlider and button this is the relevant listening class ( -

     
     
     
    class RunExptListenerClass implements ActionListener {
     
     
        public void actionPerformed(ActionEvent e) {
            if ((U_I.PickNumValue >= 10) && (U_I.PickNumValue <= 20)) {
                       Analyse_  analysebar = new Analyse_();
                       analysebar.setVisible(true);
     
      //                AddPickNumColumn();
        //               Data.tableModel.addColumn();
               //        Data AddPickNumColumn = new PickNumColumn();
          //             AddPickNumColumn
     
               // tableModel.addColumn(U_I.s);
     
     
     
              //  tableModel.fireTableStructureChanged();
            //    tableModel.AddPickNumColumn();     
                //IJ.run("Image Sequence...", "open=[/Users/otills/Desktop/"
                 //       + "Two] number=5 starting=1 increment=1 "
                //        + "scale=100 file=[] or=[] sort use");   
                //String directory = IJ.getDirectory("Select a Directory");
     
     
     
                //imp.show();
                //ImageStack.create(width, height, 3, 8);
                //ImageStack nf = ij.ImageStack.create(130, 133, n, n);
     
                //ImagePlus myImPlus = WindowManager.getCurrentImage();
     
                int myStackLength = 200;
                Opener opener = new Opener();
                ImagePlus imp = opener.openImage("/Users/otills/Desktop/Daniotest/img_000000000_Sequence_000.tif");
                ImageProcessor currIP = imp.getProcessor();
                ImageStack myStack = new ImageStack(currIP.getWidth(), currIP.getHeight());
     
                for (int SliceNo = 1; SliceNo <= myStackLength; SliceNo++) 
                    {
                    myStack.addSlice("Slice"+SliceNo, currIP);	
                    }
     
                ImagePlus myTargetImPlus = new ImagePlus("Stack of "+imp.getTitle(), currIP);	
                //The .getTitle() method, recuperates the title of the image. 
    		myTargetImPlus.show();
    		myTargetImPlus.setStack(null, myStack);	
     
                }
                //imp.createEmptyStack(800,600);
                //imp.show();
                //ImagePlus imp = IJ.openImage("/Users/otills/Desktop/Two");
                //imp.show();
     
     
     
     
                else if (U_I.PickNumValue < 10) {
                    System.out.println("less than 10");
                    Analyse_  analysebar = new Analyse_();
                    analysebar.setVisible(true);
                    IJ.run("Image Sequence...", "open=[/Users/otills/Desktop/"
                        + "One] number=5 starting=1 increment=1 "
                        + "scale=100 file=[] or=[] sort use");
                }
                else if (U_I.PickNumValue > 20) {
                    System.out.println("greater than 20");
                }
        } 
        }
    Last edited by Norm; March 6th, 2013 at 01:04 PM. Reason: removed spaces from code tags


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,143
    Thanks
    48
    Thanked 2,157 Times in 2,130 Posts

    Default Re: Adding column to JTable with JSlider determined header

    The posted code does not compile without errors. There is No way to test it without a clean compile.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Adding column to JTable with JSlider determined header

    Sorry Norm. I've just tested these two classes and they do now run OK.
    Any advice appreciated.

    import javax.swing.*;
    import java.awt.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import javax.swing.BoxLayout.*;
     
    public class Data extends JApplet {
        // Cell dimensions
        Dimension celldim = new Dimension(5,5);
        // Create table column names
        private String[] columnNames = {"X","Y",
                                    "Z",
                                   };
     
        // Create table data
        public Object[][] data = {{"One","",""},{"Two","",""},{"Three","",""},
                {"Four","",""},{"Five","",""},{"Six","",""}};
     
     
    //    tableModel.addColumn(U_I.PickNumValue);
        //public static JTable dataTable;        
     
        public class MyTableModel extends DefaultTableModel {
     
            public int getColumnCount() {
            return columnNames.length;
        }
            public int getRowCount() {
            return data.length;
        }
            public String getColumnName(int col) {
            return columnNames[col];
        }
            public Object getValueAt(int row, int col) {
            return data[row][col];
        }
            public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
        }
     
            public void AddPickNumColumn(int s) {
            tableModel.addColumn(U_I.s, new java.util.Vector());
            tableModel.fireTableStructureChanged();
        }
     
            public void columnAdded(TableColumnModelEvent e) {  
            System.out.println("DATAMODEL found a columnAddedEvent!");  
        //    columnCount++;  
        //    System.out.println("columnCount now " + columnCount);  
            this.fireTableChanged(new TableModelEvent(this));     
        }
            // public void AddPickNumColumn (){
     
          //      DefaultTableModel tablemodel = (tableModel)getJTable().getModel();
          //      tableModel.addColumn("U_I.s", new java.util.Vector());
          //      tableModel.fireTableStructureChanged();
          //      tableModel.
     
            //}
     
            public void setValueAt(Object value, int row, int col) {
            data[row][col] = value;
            fireTableCellUpdated(row, col);
        }
    //        public void AddPickNumColumn (int PickNumValue) {
    //            tableModel.addColumn(U_I.PickNumValue);
     //       }
        }
     
          // Create a model
        public DefaultTableModel tableModel = 
                new MyTableModel();
     
        // Create a table
        public JTable dataTable = new JTable(tableModel) {
            public boolean isCellEditable(int rowIndex, int columnIndex) {      
                if (columnIndex == 0) {
                return false;}
            else {return true;}
    }
     
       // Transfer Count - doesn't work!!
       //     public void TransferCountValue (){
        //    dataTable.setValueAt(Analyse_.Count,x,y);
        ////    tableModel.fireTableCellUpdated(x,y);       
    //}
                public void AddPickNumColumn (){
     
          //      DefaultTableModel tablemodel = (tableModel)getJTable().getModel();
                tableModel.addColumn("U_I.s", new java.util.Vector());
                tableModel.fireTableStructureChanged();
          //      tableModel.
     
            }
    };
     
        public JScrollPane tablepane;
     
     
        public Data() {
     
            add(new JScrollPane(dataTable), BorderLayout.CENTER);
            //Frame c = (Frame)this.getParent().getParent();  
            //dataTable.setPreferredSize(800,500);
            dataTable.setPreferredScrollableViewportSize(new Dimension(800, 500));
            //dataTable.setFillsViewportHeight(true);
            dataTable.setIntercellSpacing(celldim);
            dataTable.setFont(new Font("Arial", Font.PLAIN, 16));
            dataTable.getTableHeader().setFont(new Font("Arial", Font.BOLD, 16));
            dataTable.setRowHeight(30);
            dataTable.setGridColor(Color.GRAY);
            dataTable.setShowGrid(true);
           // dataTable.setTitle("fd");
            //c.setTitle("Hello World");
     
     
        }
     
     
       ///////// public dataTable.setValueAt {};
        //public int x;
        //public int y;
     
    //    public void TransferCountValue (){
    //    dataTable.setValueAt(Analyse_.Count,x,y);
     //   tableModel.fireTableCellUpdated(x,y);    
     //  
    //}
     //            public class AddPickNumColumn {
      //               data
      //          Data.dataTable.addColumn(U_I.PickNumValue);
      //          tableModel.fireTableStructureChanged();
      ////      }
     
    }

     
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    //import ij.plugin.frame.*;
    import ij.*;
    import ij.process.*;
    //import ij.plugin.*;
    //import ij.gui.*;
    //import ij.measure.ResultsTable;
    //import ij.ImageStack.*;
    //import ij.IJ;
    //import ij.io.Opener;
    //import ij.io.*;
     
    public class U_I extends JFrame implements ChangeListener {
     
        public static void main(String[] args) {
            U_I frame = new U_I();
            //frame.addMouseListener(frame);
            //frame.setSize(800, 600);
            //frame.pack();
            //frame.setVisible(true);
     
        }
     
        JLabel instruction;
        public JSlider pickNum;
        JButton RunExpt;
        JLabel description;
        JButton PlotResults;
        //ChangeListener pickNumChangeListener;
        static public int PickNumValue;
        int value;
        public static String s;
     
        public U_I() {
            super("Slider");
            setSize(800, 600);
            setLocationRelativeTo(null);
            Container pane = getContentPane();
            GridBagLayout gridbag = new GridBagLayout();
            GridBagConstraints constraints = new GridBagConstraints();
            pane.setLayout(gridbag);
     
      ////////////////////////////////////////////////////////////////////       
            //JPanel for slider and associated label
     
            //Slider Label
            JLabel instruction = new JLabel("<html><div style=\"text-align: "
         + "center;\"> <b>Choose a treatment </b></html>");
            instruction.setFont(new Font("sansserif", Font.BOLD, 15));
     
         //////////////////
     
            constraints = new GridBagConstraints();
     
            constraints.gridx = 0;
            constraints.gridy = 0;
            constraints.gridwidth = 3;
            constraints.gridheight = 2;
            constraints.weightx = 0.42;
            constraints.weighty = 0.14;
            constraints.fill = GridBagConstraints.NONE;
            constraints.anchor = GridBagConstraints.NORTHWEST;
            constraints.insets = new Insets(40,100,0,0);
            constraints.ipadx = 0;
            constraints.ipady = 0;
            //constraints.insets = new Insets(20,20,20,20);
            gridbag.setConstraints(instruction, constraints);
            add(instruction);
     
     
            //Slider
            JSlider pickNum = new JSlider(JSlider.HORIZONTAL, 0, 40, 5);
            pickNum.setMajorTickSpacing(10);
            pickNum.setMinorTickSpacing(5);
            pickNum.setPaintTicks(true);
            pickNum.setPaintLabels(true);
            pickNum.setSnapToTicks(true);
            pickNum.setPreferredSize(new Dimension(400,210));
            pickNum.setFont(new Font("sansserif", Font.BOLD, 15));
            //Register listener for slider
            //pickNumChangeListenerClass pickNumChangeListener = 
                    //new pickNumChangeListenerClass();
            pickNum.addChangeListener(this); 
     
     
     
     
     
            //String myString = "";
            //myString = Integer.toString(PickNumValue);
            //System.out.println(myString);
     
     
     
            // above converts the Slider int value to a string to allow print
            // for testing (not required for function)!
     
     
            //////////////////
            constraints = new GridBagConstraints();
     
            constraints.gridx = 0;
            constraints.gridy = 1;
            constraints.gridwidth = 3;
            constraints.gridheight = 2;
            constraints.weightx = 0.42;
            constraints.weighty = 0.14;
            constraints.fill = GridBagConstraints.NONE;
            constraints.anchor = GridBagConstraints.NORTHWEST;
            constraints.insets = new Insets(35,30,0,0);
            constraints.ipadx = 0;
            constraints.ipady = 0;
            //constraints.insets = new Insets(20,20,20,20);
            gridbag.setConstraints(pickNum, constraints);
            add(pickNum);
     
     
     ////////////////////////////////////////////////////////////////////
     
            //Run Expt Button
     
            ImageIcon play = new ImageIcon
                    ("/Users/otills/Code/Symbols/Play_small.gif");
            JButton RunExpt = new JButton("Run Experiment", play );
            RunExpt.setPreferredSize(new Dimension(190,100));
            RunExpt.setFont(new Font("sansserif", Font.BOLD, 15));
            RunExptListenerClass RunExptlistener = new RunExptListenerClass();
            RunExpt.addActionListener(RunExptlistener);
     
            constraints = new GridBagConstraints();
     
            constraints.gridx = 8;
            constraints.gridy = 1;
            constraints.gridwidth = 4;
            constraints.gridheight = 2;
            constraints.weightx = 0.33;
            constraints.weighty = 0.18;
            constraints.fill = GridBagConstraints.NONE;
            constraints.anchor = GridBagConstraints.NORTHWEST;
            constraints.insets = new Insets(20,0,0,0);
            constraints.ipadx = 0;
            constraints.ipady = 0;
            //constraints.insets = new Insets(20,20,20,20);
            gridbag.setConstraints(RunExpt, constraints);
            add(RunExpt);
     
     
     
    ////////////////////////////////////////////////////////////////////
     
            // Graphic
            JLabel description = new JLabel();
            description.setIcon(new javax.swing.ImageIcon
                    ("/Users/otills/Desktop/demovirtualexpt.jpg"));
     
            constraints = new GridBagConstraints();
     
            constraints.gridx = 1;
            constraints.gridy = 4;
            constraints.gridwidth = 6;
            constraints.gridheight = 4;
            constraints.weightx = 0.42;
            constraints.weighty = 0.5;
            constraints.fill = GridBagConstraints.NONE;
            constraints.anchor = GridBagConstraints.NORTHWEST;
            constraints.insets = new Insets(0,50,0,0);
            constraints.ipadx = 0;
            constraints.ipady = 0;
            //constraints.insets = new Insets(20,20,20,20);
            gridbag.setConstraints(description, constraints);
            add(description);
     
    ////////////////////////////////////////////////////////////////////
     
            //Plot Results Button
            ImageIcon graph = new ImageIcon
                    ("/Users/otills/JavaTest/src/Graph_icon.gif");
            JButton PlotResults = new JButton("Plot Results", graph);
            PlotResults.setPreferredSize(new Dimension(190,100));
            PlotResults.setFont(new Font("sansserif", Font.BOLD, 15));
            //PlotResults.addActionListener(this);
            constraints = new GridBagConstraints();
            PlotResultsListenerClass PlotListener = new PlotResultsListenerClass();
            PlotResults.addActionListener(PlotListener);
     
            constraints.gridx = 9;
            constraints.gridy = 8;
            constraints.gridwidth = 3;
            constraints.gridheight = 2;
            constraints.weightx = 0.25;
            constraints.weighty = 0.18;
            constraints.fill = GridBagConstraints.NONE;
            constraints.anchor = GridBagConstraints.NORTHWEST;
            constraints.insets = new Insets(0,0,10,0);
            constraints.ipadx = 0;
            constraints.ipady = 0;
            //constraints.insets = new Insets(20,20,20,20);
            gridbag.setConstraints(PlotResults, constraints);
            add(PlotResults);
     
            //PlotResults.addActionListener(this);
    //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
     
            setVisible(true);
        }
        //public void stateChanged(ChangeEvent e) {
            //JSlider source = (JSlider)e.getSource();
              //if (!source.getValueIsAdjusting()) {
                  //PickNumValue = (int)source.getValue();
                  //U_I.getvalue(pickNum)
                  //System.out.println(PickNumValue);
     
              //}}
                //if (PickNumValue < 20) {
                    //System.out.println(PickNumValue);
                //} else
                //{ IJ.runMacroFile("/Users/otills/Desktop/SequenceOne.txt");}
                //}  
        //}
     
     
        public void stateChanged(ChangeEvent e) {
                JSlider source = (JSlider)e.getSource();
                if (source.getValueIsAdjusting() !=true) {
                        PickNumValue = source.getValue();
                        String s = Integer.toString(PickNumValue);
                        System.out.println(s);
                    }
                }
     
    }
    class RunExptListenerClass implements ActionListener {
     
     
        public void actionPerformed(ActionEvent e) {
            if ((U_I.PickNumValue >= 10) && (U_I.PickNumValue <= 20)) {
                       Analyse_  analysebar = new Analyse_();
                       analysebar.setVisible(true);
     
      //                AddPickNumColumn();
        //               Data.tableModel.addColumn();
               //        Data AddPickNumColumn = new PickNumColumn();
          //             AddPickNumColumn
     
               // tableModel.addColumn(U_I.s);
     
     
     
              //  tableModel.fireTableStructureChanged();
            //    tableModel.AddPickNumColumn();     
                //IJ.run("Image Sequence...", "open=[/Users/otills/Desktop/"
                 //       + "Two] number=5 starting=1 increment=1 "
                //        + "scale=100 file=[] or=[] sort use");   
                //String directory = IJ.getDirectory("Select a Directory");
     
     
     
                //imp.show();
                //ImageStack.create(width, height, 3, 8);
                //ImageStack nf = ij.ImageStack.create(130, 133, n, n);
     
                //ImagePlus myImPlus = WindowManager.getCurrentImage();
     
               // int myStackLength = 200;
                //Opener opener = new Opener();
                //ImagePlus imp = opener.openImage("/Users/otills/Desktop/Daniotest/img_000000000_Sequence_000.tif");
                //ImageProcessor currIP = imp.getProcessor();
                //ImageStack myStack = new ImageStack(currIP.getWidth(), currIP.getHeight());
     
               // for (int SliceNo = 1; SliceNo <= myStackLength; SliceNo++) 
                //    {
                //    myStack.addSlice("Slice"+SliceNo, currIP);	
                //    }
     
                //ImagePlus myTargetImPlus = new ImagePlus("Stack of "+imp.getTitle(), currIP);	
                //The .getTitle() method, recuperates the title of the image. 
    		//myTargetImPlus.show();
    		//myTargetImPlus.setStack(null, myStack);	
     
                }
                //imp.createEmptyStack(800,600);
                //imp.show();
                //ImagePlus imp = IJ.openImage("/Users/otills/Desktop/Two");
                //imp.show();
     
     
     
     
                else if (U_I.PickNumValue < 10) {
                    System.out.println("less than 10");
                    Analyse_  analysebar = new Analyse_();
                    analysebar.setVisible(true);
                   // IJ.run("Image Sequence...", "open=[/Users/otills/Desktop/"
                       // + "One] number=5 starting=1 increment=1 "
                      //  + "scale=100 file=[] or=[] sort use");
                }
                else if (U_I.PickNumValue > 20) {
                    System.out.println("greater than 20");
                }
        } 
        }
     
                //System.out.println(s);
                //if (U_I.PickNumValue <20){
                //IJ.runMacroFile("/Users/otills/Desktop/SequenceOne.txt");
                //}
                //else if (U_I.PickNumValue > 20){
                //IJ.runMacroFile("/Users/otills/Desktop/SequenceTwo.txt");
                //System.out.println("PickNumValue.U_I"); 
    	//}
     
            //PickNumValue.UI = UI.getDeclaredField("PickNumValue");
     
     
     
    class PlotResultsListenerClass implements ActionListener {
        public void actionPerformed(ActionEvent e) {
             IJ.runMacroFile("/Users/otills/Desktop/SequenceTwo.txt");
            IJ.run("Table...", "name=Table width=350 height=450");
            //IJ.ImageWindow.setLocationRelativeTo(null);
            //ImageWindow.getWindows();
     
           // new.DataTable.Data();
             //Tablemodel datamodel = new AbstractTableModel() {
     
             };
     
     
     
        }
      //}
     
    class DataTable{
        public JTable Data;
     
     
    }
     
     
    //pickNum.addChangeListener(new ChangeListener() {
     //           public void stateChanged(ChangeEvent e) {
      //              JSlider source = (JSlider)e.getSource();
       //             if (!source.getValueIsAdjusting()) {
      //                  PickNumValue = source.getValue();
       //             }
       //         }
        //    });

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,143
    Thanks
    48
    Thanked 2,157 Times in 2,130 Posts

    Default Re: Adding column to JTable with JSlider determined header

    Why does the first class extend JApplet?

    How is the program executed? If Data is an applet do you use an HTML page?

    The code still has lots of compiler warnings and some errors

    Can you make a smaller program that compiles, executes and shows the problem?

    This code is very messy and has too many problems.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. How to get the sum value from a jtable column
    By Asri in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 8th, 2013, 09:00 AM
  2. JTable Column Sizing
    By Jeff.Steinkamp in forum AWT / Java Swing
    Replies: 1
    Last Post: January 20th, 2013, 08:23 PM
  3. Customize Jtable header
    By md_suzon in forum AWT / Java Swing
    Replies: 1
    Last Post: October 11th, 2011, 04:16 PM
  4. [SOLVED] Quick JTable Column Sort Question
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 15th, 2010, 04:35 PM
  5. Highlighting both row and column in JTable
    By bschneider14 in forum AWT / Java Swing
    Replies: 4
    Last Post: May 29th, 2010, 09:14 AM