Link to home
Start Free TrialLog in
Avatar of sargent240
sargent240Flag for United States of America

asked on

Placing labels in a panel

Attached is code I am using to display labels and text fields on a panel  The JFrame was created using Netbeans.  The data with the order the labels should be displayed comes from a mysql database.  I have the info available in property display and now need to get it to display on a panel on my frame.  I've tried as few things like setvisible and pack  without any success so I am either not getting them in the right place or they are not the answer.  Any ideas apprediated
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */

package jclerk;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
    ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
        ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
        while (rec.next()) {            
            key = rec.getString("skey");
            value = rec.getString("svalue");
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
        }
        rec.close();
        stmt.close();
    } catch (SQLException sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
            con.close();
        } catch (SQLException e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 2));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        propertyPanel.add(prop.getLabel());
        propertyPanel.add(prop.getTextField());
    }
//    propertyPanel.setVisible(true);
    return propertyPanel;
}

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
        initComponents();

        populateClerkScreen();
        
    }

Open in new window

Avatar of for_yan
for_yan
Flag of United States of America image

The code which you posted does not conatine method initComponents() where the layout is created, so I cannot run and test it.

Just by a glnace it is difficult to check this rather long pieece of code, perhaps better to post the whol thing - then we can try to run and exceute it
(we can replaceretirvalfrom databse for testing with some array for terh testing purpses).

On the first glance what strikes me as odd is thatwhen retirieving from databses
 it does not make sense to store lables and textfileds in the array lists - you rather store strings - it is emnnough to store
Hashmap and maybe arraylist of keys just to follow the order (as Hashmap does not retain the order).
There is no sene to store lables, textfiles - those you would rather create when you create interface -
I would rather change this part tyo make it more natural.

And then post the whole code - it may be that you don;'t see them finally because of some other
reasomns of how they are added to elements of the gui.
Beacuse it was hard at least for me to find a flaw in suych a big piece of code without executing it and haveing IDE to help me

You see in your constructor I'm guessing you firts intiComponents and you add them, etc
but then after that you create this new JPanel propertyPanel in the method populateClerkScreen();
 which excecuttes after initComponents
and this JPanle is populated but it never gets added to your JFrame - so you would not see this new propertyPanel and its contents




I would also have made these changes for the beginning in accordance to my note above;

instead of these:
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

I'd rather make:

private List<String> orderedProperties = new ArrayList<String>();
private Map<String, String> propertiesVlauesMap =  new HashMap<String, String>();

and then change this passage:

JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedProperties.size(), 2));
    for (String prop : orderedProperties) {
     
String value = propertiesVlauesMap.getProp();

        propertyPanel.add(new JLabel(prop));
        propertyPanel.add(new JTextFiled(value));
    }





Avatar of sargent240

ASKER

Are you suggesting my code is not adequate to or is not workable to do what I am trying to do?
 
I think your code is not showing because you arefirst adding all comonenets and then creating and populating panle which you do not add anywhere
In addition I'm suggesting that you store from dtatabse not labels and textfields aand visual elementn but rathr store strings and then create lkables and textfileds when you want to add them to the panel. This is just good practice.
Avatar of zzynx
Your method

  populateClerkScreen()

returns a JPanel.
If you want to see that panel on your frame you have to add it somewhere.
Just creating it is not enough to make it visible on your frame.

eg. yourFrame.getContentPane().add(populateClerkScreen());
Thanks zzynx.  I added the following code and got the "non static method cannot be referenced in a static context"  error.  I did some reading on the error and between the discussions about instances and methods and data and instance methods and so forth I don't seem to have gained much.  Can you give me a suggestion?  I added the following to my code which produced the error.
 
public void displayLabels() {

        JFrame.getContentPane().add(populateClerkScreen());       
        
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
        initComponents();

        populateClerkScreen();
        displayLabels();
    }

Open in new window

ook at this code - it shows your labels, though I removed reading from adatabse
and justa added one key value pair, removed package - you can return package - that's not important

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */



//import com.mysql.jdbc.Connection;
//import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
  //  ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = null;
    //connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        //Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
       // ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
      //  while (rec.next()) {
        //    key = rec.getString("skey");
         //   value = rec.getString("svalue");
        key = "a";
        value = "b";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
       // }
       // rec.close();
       // stmt.close();
    } catch (Exception sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
        //    con.close();
        } catch (Exception e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 2));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        propertyPanel.add(prop.getLabel());
        propertyPanel.add(prop.getTextField());
    }
//    propertyPanel.setVisible(true);
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
      //  initComponents();

        populateClerkScreen();

        this.getContentPane().add( populateClerkScreen());

        this.setSize(400,500);
        this.setVisible(true);
        
    }
}

Open in new window

The main thins I did was adding these lines to constructor:

 this.getContentPane().add( populateClerkScreen());

        this.setSize(400,500);
        this.setVisible(true);


In this way I added the Jpanel to your main JFrame
you of cousres keep databses connection I removed it because I don have access to databse and yir question is about GUI

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */



//import com.mysql.jdbc.Connection;
//import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
  //  ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = null;
    //connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        //Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
       // ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
      //  while (rec.next()) {
        //    key = rec.getString("skey");
         //   value = rec.getString("svalue");
        key = "prop1";
        value = "value1";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);

          key = "prop2";
        value = "value2";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
       // }
       // rec.close();
       // stmt.close();
    } catch (Exception sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
        //    con.close();
        } catch (Exception e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 2));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        propertyPanel.add(prop.getLabel());
        propertyPanel.add(prop.getTextField());
    }
//    propertyPanel.setVisible(true);
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
      //  initComponents();

      //  populateClerkScreen();

        this.getContentPane().add( populateClerkScreen());

        this.setSize(400,500);
        this.setVisible(true);
        
    }
}

Open in new window



propVlaues.PNG
I am attaching a copy of the screen created using netbeans.  I need a pane with the labels and text fields to display in the big gray area to the right of the head in and head sold labels.  There should be two coumns and could be up to ten rows.

An example would be

                                                     Head Count:  (text field)
                                                    Total Weight:  (text field)
                                                 Seller Number:  (text field)
                                                    Desc. Code:  (text field)
                                                    Tag Number:  (text field)

And so forth.  The labels titles are in the database along with a key telling what row they belong in.  The labels and text boxes need to be just a bit smaller that the Head in and Head sold labels with appropriate sized text boxes of various lengths.
But that is what the code i posted above is doing
And there is no screen attached

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */



//import com.mysql.jdbc.Connection;
//import com.mysql.jdbc.Statement;
import java.awt.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.*;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
  //  ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = null;
    //connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        //Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
       // ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
      //  while (rec.next()) {
        //    key = rec.getString("skey");
         //   value = rec.getString("svalue");
        key = "Head Count:";
        value = "50";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);

          key = "Total Weight:";
        value = "500";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


           key = "Seller Number: ";
        value = "438";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Desc Code: ";
        value = "A514";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Tag Number: ";
        value = "B718";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


         /*
   Head Count:  (text field)
                                                    Total Weight:  (text field)
                                                 Seller Number:  (text field)


        */

       // }
       // rec.close();
       // stmt.close();
    } catch (Exception sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
        //    con.close();
        } catch (Exception e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
        fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
//    propertyPanel.setVisible(true);
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
      //  initComponents();

      //  populateClerkScreen();

        this.getContentPane().add( populateClerkScreen());

        this.setSize(400,200);
        this.setVisible(true);
        
    }
}

Open in new window

screen corsponding to code above:
lables-texts.PNG

This will be with centered lables - looks better:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */



//import com.mysql.jdbc.Connection;
//import com.mysql.jdbc.Statement;
import java.awt.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.*;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
  //  ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = null;
    //connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        //Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
       // ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
      //  while (rec.next()) {
        //    key = rec.getString("skey");
         //   value = rec.getString("svalue");
        key = "Head Count:";
        value = "50";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);

          key = "Total Weight:";
        value = "500";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


           key = "Seller Number: ";
        value = "438";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Desc Code: ";
        value = "A514";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Tag Number: ";
        value = "B718";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


         /*
   Head Count:  (text field)
                                                    Total Weight:  (text field)
                                                 Seller Number:  (text field)


        */

       // }
       // rec.close();
       // stmt.close();
    } catch (Exception sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
        //    con.close();
        } catch (Exception e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
      //  fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
//    propertyPanel.setVisible(true);
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property, SwingConstants.CENTER);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
      //  initComponents();

      //  populateClerkScreen();

        this.getContentPane().add( populateClerkScreen());

        this.setSize(400,200);
        this.setVisible(true);
        
    }
}

Open in new window



By the way in your posting ID:37305438
this:

 JFrame.getContentPane().add(populateClerkScreen());    

is incorrect because you treat instance method getContentPane() aa static, trying
to invoke it not on instance of JFrame or its subclass (as it should be done)
but rather on the class JFrame itself (when you write JFrame.getContentPane()...), as if it were a static method, and static methods
are indeed invoked on name of the class and are not related to any specific instance of the class.
That is the origin of the error you are seeing.

In general the point is to get Container from this specific instance
of JFrame represented by instance of your class MainScreen which extends JFrame.

So in fact in such cases when you create woindows by extending JFrame
you need to add your elements to the underlying JFrame  mostly in this way:

Container c = this.getContentPane();
c.add(populateClerkScreen());

So you start from this , getContentPane() of this very instance of your JFrame
and add to it all waht you need to add.

In your case situation is additionally complicated by the fact that
method initComponents() created by NetBeans
will probebly also do such thing at some momemnt (request main Container and then add the
fisrt element, say the first JPanel, to that first Container).

therefore you need somehow to coordinate these things between your code and NetBeans code, as
there is only one first level container corresponding to each window.

As I didn't see any other components which you need to show along with labels and Textfileds, I just commented out
initComponents(). In more sophisticed cases you need to combine your code and initComponents()
or make sure  that they work together correctly.


The size and exact location of labels, textfields, etc. can be adjusted playing with
different layouts and appropriate constructors of the elements - it is not always straightforward but
usually doable.










I inserted your code into my and got the same thing you did.  Then I used your code but I used the info from my database and it put up a panel like you have been seeing but with the data from my database.  The problem is the labels are not appearing on the frame I created with netbeans.  As I mentioned in my previous post (and sent a screen shot of my frame)  I need the labels to appear on a plain panel on the upper right quadrant of my existing frame.  We are on the right track I think.  I am including my entire code, maybe that will help.  I am also attaching a snapshot of what was produced using your code and my database.
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */

package jclerk;



import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
    ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 
     	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
        ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
        while (rec.next()) {            
            key = rec.getString("skey");
            value = rec.getString("svalue");
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
        }
        rec.close();
        stmt.close();
    } catch (SQLException sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
            con.close();
        } catch (SQLException e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
        fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
      //  initComponents();

      //  populateClerkScreen();

        this.getContentPane().add( populateClerkScreen());

        this.setSize(400,200);
        this.setVisible(true);
        
    }

    
    
    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtPreviousTransactions = new javax.swing.JTable();
        jlNumberIn = new javax.swing.JLabel();
        jlHeadCheckedIn = new javax.swing.JLabel();
        jlHeadSoldLabel = new javax.swing.JLabel();
        jlHeadSold = new javax.swing.JLabel();
        jlWeighMaster = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jcbAudienceDisplays = new java.awt.Checkbox();
        jcbPrintTickets = new java.awt.Checkbox();
        jbZeroBalance = new java.awt.Button();
        jbWeighBack = new java.awt.Button();
        jbWeightOff = new java.awt.Button();
        jbComment = new java.awt.Button();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jbSelectAll = new javax.swing.JButton();
        jbCancelMD = new javax.swing.JButton();
        jbProcess = new javax.swing.JButton();
        jlMultidraft = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Clerk - Ver. 2.0 (April 1, 2011)");

        jtPreviousTransactions.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Trans", "Head", "Description", "Weight", "Average", "Seller", "Buyer", "Bid"
            }
        ));
        jtPreviousTransactions.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jtPreviousTransactions);

        jlNumberIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlNumberIn.setText("Head In:");

        jlHeadCheckedIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadCheckedIn.setText("0");
        jlHeadCheckedIn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlHeadSoldLabel.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSoldLabel.setText("Head Sold:");

        jlHeadSold.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSold.setText("0");
        jlHeadSold.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlWeighMaster.setFont(new java.awt.Font("Dialog", 1, 18));
        jlWeighMaster.setText("Weigh Master");

        jTextField1.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jcbAudienceDisplays.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbAudienceDisplays.setLabel("Audience Displays");
        jcbAudienceDisplays.setState(true);

        jcbPrintTickets.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbPrintTickets.setLabel("Print Tickets");
        jcbPrintTickets.setState(true);

        jbZeroBalance.setFont(new java.awt.Font("Dialog", 1, 12));
        jbZeroBalance.setLabel("Zero Balance");
        jbZeroBalance.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbZeroBalanceMouseClicked(evt);
            }
        });

        jbWeighBack.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
        jbWeighBack.setLabel("Weigh Back");
        jbWeighBack.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeighBackMouseClicked(evt);
            }
        });

        jbWeightOff.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeightOff.setLabel("Weight Display Off/On");
        jbWeightOff.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeightOffMouseClicked(evt);
            }
        });

        jbComment.setFont(new java.awt.Font("Dialog", 1, 12));
        jbComment.setLabel("Comment");
        jbComment.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbCommentMouseClicked(evt);
            }
        });

        jTable2.setFont(new java.awt.Font("Dialog", 0, 18));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Draft", "Head", "Weight", "Average"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setShowHorizontalLines(false);
        jTable2.setShowVerticalLines(false);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTable2);
        jTable2.getColumnModel().getColumn(0).setResizable(false);

        jbSelectAll.setText("Select All");

        jbCancelMD.setText("Delete All");

        jbProcess.setText("Process");

        jlMultidraft.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
        jlMultidraft.setText("Multidraft:");

        jButton1.setText("Multidraft On/off");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Reweigh");

        jButton3.setText("Edit Head Count");
        jButton3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNumberIn, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jlHeadSoldLabel)
                                .addGap(29, 29, 29)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jlHeadSold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jlHeadCheckedIn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jlMultidraft)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(jbProcess, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jbSelectAll, javax.swing.GroupLayout.Alignment.LEADING))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jbCancelMD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jButton1))))
                                        .addGap(187, 187, 187)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton2)
                                    .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jlWeighMaster)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(85, 85, 85)
                                .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlNumberIn)
                    .addComponent(jlHeadCheckedIn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlHeadSoldLabel)
                    .addComponent(jlHeadSold))
                .addGap(301, 301, 301)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jlMultidraft)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbProcess)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbSelectAll)
                            .addComponent(jbCancelMD))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlWeighMaster)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      

 if (multidraftFlag == 0) {   
    jButton1.setBackground(Color.red);
    jButton1.setForeground(Color.white);
    multidraftFlag = 1;
 }
 else {
    jButton1.setBackground(defaultButtonColor);
    jButton1.setForeground(Color.black);
    multidraftFlag = 0;
 }
    
}                                     

private void jbWeightOffMouseClicked(java.awt.event.MouseEvent evt) {                                         
// TODO add your handling code here:
 if (weightDisplayFlag == 0) {
     jbWeightOff.setBackground(Color.red);
     jbWeightOff.setForeground(Color.white);
     weightDisplayFlag = 1;
 }
 else {
     jbWeightOff.setBackground(defaultButtonColor);
     jbWeightOff.setForeground(Color.black);
     weightDisplayFlag = 0;
 }
}                                        

private void jbWeighBackMouseClicked(java.awt.event.MouseEvent evt) {                                         
// TODO add your handling code here:
}                                        

private void jbZeroBalanceMouseClicked(java.awt.event.MouseEvent evt) {                                           
// TODO add your handling code here:
try {
 if (zeroBalanceFlag == 0) {
     jbZeroBalance.setBackground(Color.red);
     jbZeroBalance.setForeground(Color.white);
     
     // Go print a zero balance ticket
     Thread.sleep(4000);     

     jbZeroBalance.setBackground(defaultButtonColor);
     jbZeroBalance.setForeground(Color.black);
 }   
} catch(Exception e) {
    JOptionPane.showMessageDialog(null, "ClassNotFoundException: " +
        e.getMessage());
}

}                                          

private void jbCommentMouseClicked(java.awt.event.MouseEvent evt) {                                       

    String str = JOptionPane.showInputDialog(null, "Comment : ", 
        "Clerk Comment", 1);
    if(str != null) {
        // Store the comment where ever
    }
    
}                                      

    /**
    * @param args the command line arguments
    */
/*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainScreen().setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton jbCancelMD;
    private java.awt.Button jbComment;
    private javax.swing.JButton jbProcess;
    private javax.swing.JButton jbSelectAll;
    private java.awt.Button jbWeighBack;
    private java.awt.Button jbWeightOff;
    private java.awt.Button jbZeroBalance;
    private java.awt.Checkbox jcbAudienceDisplays;
    private java.awt.Checkbox jcbPrintTickets;
    private javax.swing.JLabel jlHeadCheckedIn;
    private javax.swing.JLabel jlHeadSold;
    private javax.swing.JLabel jlHeadSoldLabel;
    private javax.swing.JLabel jlMultidraft;
    private javax.swing.JLabel jlNumberIn;
    private javax.swing.JLabel jlWeighMaster;
    private javax.swing.JTable jtPreviousTransactions;
    // End of variables declaration

}

Open in new window

snapshot.png
I guess if you are creating this layout with NetBans using the desiner so - you go ahead and create layout as you want it and placve a JPanel (or maybe it is JScrollPane) on that place where you want to populate lables and textfiled.

so just detemrine what will be the name of that panel or maybe it will even be JScrollPane) which should sit in that araea
and then you can do

 public MainScreen() {

      initComponents();

      empty_panel_which_was_placed_in_this_place. add(populateClerkScreen());

               
    }

I think it should work.

It is only important taht we do it after initComponents() so we have where to add this new panel which we created



I added a jPanel (jPanel1) using netbeans.  Then I changed the code in MainScreen() as follows and the frame with all the buttons and so forth came up but no labels.  I am also attaching another snaptshot of the latest screen that was created after the changes below.

/** Creates new form MainScreen */
    public MainScreen() {
        initComponents();

//        populateClerkScreen();
        jPanel1.add(populateClerkScreen());
//        this.getContentPane().add( populateClerkScreen());

//        this.setSize(400,200);
//        this.setVisible(true);
        
    }

Open in new window

snapshot1.png
Strange, whyit does not work.

Then try to go into initComaponents and inside there where it says

jPanel1 = new javax.swing.JPanel()

istead of this line say:

jPanel1 = populateClerkScreen();
I made the change in initComponents with the same result.
Please, post the whoel code as it is now once again.


I replaced one of ScrollPanes and istaed of jTable added this clerkPanel
like this:

       // jScrollPane1.setViewportView(jtPreviousTransactions);

         jScrollPane1.setViewportView(populateClerkScreen());

and it shows OK;
So create one more JScrollPane with cdesigner in the place where you want it to sit - and I'm sure it will show it in another place

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */

package jclerk;



//import com.mysql.jdbc.Connection;
//import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {

  //  ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;



private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = null;
    //connectDatabase.getConnection();

    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        Statement stmt = null;
        //(Statement) con.createStatement();
        // let database sort the values for you
       // ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
        /*
        while (rec.next()) {
            key = rec.getString("skey");
            value = rec.getString("svalue");
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
            */

             key = "Head Count:";
        value = "50";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);

          key = "Total Weight:";
        value = "500";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


           key = "Seller Number: ";
        value = "438";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Desc Code: ";
        value = "A514";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Tag Number: ";
        value = "B718";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);






      //  }
      //  rec.close();
      //  stmt.close();
    } catch (Exception sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
         //   con.close();
        } catch (Exception e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
        fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
    return propertyPanel;
}
/*
    public static void main(String[] args) {
       new MainScreen();
    }
    */

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }

    /** Creates new form MainScreen */
    public MainScreen() {
       initComponents();
        
      //  populateClerkScreen();

        //this.getContentPane().add( populateClerkScreen());

       // this.setSize(400,200);
       // this.setVisible(true);

    }



    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
       

        jtPreviousTransactions = new javax.swing.JTable();
        jlNumberIn = new javax.swing.JLabel();
        jlHeadCheckedIn = new javax.swing.JLabel();
        jlHeadSoldLabel = new javax.swing.JLabel();
        jlHeadSold = new javax.swing.JLabel();
        jlWeighMaster = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jcbAudienceDisplays = new java.awt.Checkbox();
        jcbPrintTickets = new java.awt.Checkbox();
        jbZeroBalance = new java.awt.Button();
        jbWeighBack = new java.awt.Button();
        jbWeightOff = new java.awt.Button();
        jbComment = new java.awt.Button();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jbSelectAll = new javax.swing.JButton();
        jbCancelMD = new javax.swing.JButton();
        jbProcess = new javax.swing.JButton();
        jlMultidraft = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Clerk - Ver. 2.0 (April 1, 2011)");

        jtPreviousTransactions.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Trans", "Head", "Description", "Weight", "Average", "Seller", "Buyer", "Bid"
            }
        ));
        jtPreviousTransactions.getTableHeader().setReorderingAllowed(false);
       // jScrollPane1.setViewportView(jtPreviousTransactions);

         jScrollPane1.setViewportView(populateClerkScreen());


        jlNumberIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlNumberIn.setText("Head In:");

        jlHeadCheckedIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadCheckedIn.setText("0");
        jlHeadCheckedIn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlHeadSoldLabel.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSoldLabel.setText("Head Sold:");

        jlHeadSold.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSold.setText("0");
        jlHeadSold.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlWeighMaster.setFont(new java.awt.Font("Dialog", 1, 18));
        jlWeighMaster.setText("Weigh Master");

        jTextField1.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jcbAudienceDisplays.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbAudienceDisplays.setLabel("Audience Displays");
        jcbAudienceDisplays.setState(true);

        jcbPrintTickets.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbPrintTickets.setLabel("Print Tickets");
        jcbPrintTickets.setState(true);

        jbZeroBalance.setFont(new java.awt.Font("Dialog", 1, 12));
        jbZeroBalance.setLabel("Zero Balance");
        jbZeroBalance.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbZeroBalanceMouseClicked(evt);
            }
        });

        jbWeighBack.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
        jbWeighBack.setLabel("Weigh Back");
        jbWeighBack.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeighBackMouseClicked(evt);
            }
        });

        jbWeightOff.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeightOff.setLabel("Weight Display Off/On");
        jbWeightOff.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeightOffMouseClicked(evt);
            }
        });

        jbComment.setFont(new java.awt.Font("Dialog", 1, 12));
        jbComment.setLabel("Comment");
        jbComment.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbCommentMouseClicked(evt);
            }
        });

        jTable2.setFont(new java.awt.Font("Dialog", 0, 18));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Draft", "Head", "Weight", "Average"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setShowHorizontalLines(false);
        jTable2.setShowVerticalLines(false);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTable2);
        jTable2.getColumnModel().getColumn(0).setResizable(false);

        jbSelectAll.setText("Select All");

        jbCancelMD.setText("Delete All");

        jbProcess.setText("Process");

        jlMultidraft.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
        jlMultidraft.setText("Multidraft:");

        jButton1.setText("Multidraft On/off");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Reweigh");

        jButton3.setText("Edit Head Count");
        jButton3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNumberIn, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jlHeadSoldLabel)
                                .addGap(29, 29, 29)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jlHeadSold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jlHeadCheckedIn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jlMultidraft)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(jbProcess, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jbSelectAll, javax.swing.GroupLayout.Alignment.LEADING))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jbCancelMD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jButton1))))
                                        .addGap(187, 187, 187)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton2)
                                    .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jlWeighMaster)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(85, 85, 85)
                                .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlNumberIn)
                    .addComponent(jlHeadCheckedIn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlHeadSoldLabel)
                    .addComponent(jlHeadSold))
                .addGap(301, 301, 301)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jlMultidraft)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbProcess)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbSelectAll)
                            .addComponent(jbCancelMD))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlWeighMaster)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

 if (multidraftFlag == 0) {
    jButton1.setBackground(Color.red);
    jButton1.setForeground(Color.white);
    multidraftFlag = 1;
 }
 else {
    jButton1.setBackground(defaultButtonColor);
    jButton1.setForeground(Color.black);
    multidraftFlag = 0;
 }

}

private void jbWeightOffMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
 if (weightDisplayFlag == 0) {
     jbWeightOff.setBackground(Color.red);
     jbWeightOff.setForeground(Color.white);
     weightDisplayFlag = 1;
 }
 else {
     jbWeightOff.setBackground(defaultButtonColor);
     jbWeightOff.setForeground(Color.black);
     weightDisplayFlag = 0;
 }
}

private void jbWeighBackMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}

private void jbZeroBalanceMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
try {
 if (zeroBalanceFlag == 0) {
     jbZeroBalance.setBackground(Color.red);
     jbZeroBalance.setForeground(Color.white);

     // Go print a zero balance ticket
     Thread.sleep(4000);

     jbZeroBalance.setBackground(defaultButtonColor);
     jbZeroBalance.setForeground(Color.black);
 }
} catch(Exception e) {
    JOptionPane.showMessageDialog(null, "ClassNotFoundException: " +
        e.getMessage());
}

}

private void jbCommentMouseClicked(java.awt.event.MouseEvent evt) {

    String str = JOptionPane.showInputDialog(null, "Comment : ",
        "Clerk Comment", 1);
    if(str != null) {
        // Store the comment where ever
    }

}

    /**
    * @param args the command line arguments
    */

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainScreen().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton jbCancelMD;
    private java.awt.Button jbComment;
    private javax.swing.JButton jbProcess;
    private javax.swing.JButton jbSelectAll;
    private java.awt.Button jbWeighBack;
    private java.awt.Button jbWeightOff;
    private java.awt.Button jbZeroBalance;
    private java.awt.Checkbox jcbAudienceDisplays;
    private java.awt.Checkbox jcbPrintTickets;
    private javax.swing.JLabel jlHeadCheckedIn;
    private javax.swing.JLabel jlHeadSold;
    private javax.swing.JLabel jlHeadSoldLabel;
    private javax.swing.JLabel jlMultidraft;
    private javax.swing.JLabel jlNumberIn;
    private javax.swing.JLabel jlWeighMaster;
    private javax.swing.JTable jtPreviousTransactions;
    // End of variables declaration

}

Open in new window

replaced-one-of-scrool-panes.PNG
Attached is the entire code.  I can't get at the line you are talking about.  The code generated by betbeans is grayed out and I can't change it.  If I right click on the panel and go to properties I can change the line you originally suggested I change but that did not make any difference.
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */

package jclerk;



import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
    ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 
     	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
        ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
        while (rec.next()) {            
            key = rec.getString("skey");
            value = rec.getString("svalue");
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
        }
        rec.close();
        stmt.close();
    } catch (SQLException sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
            con.close();
        } catch (SQLException e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
        fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
        initComponents();

//        populateClerkScreen();
//        jPanel1.add(populateClerkScreen());
//        this.getContentPane().add( populateClerkScreen());

//        this.setSize(400,200);
//        this.setVisible(true);
        
    }

    
    
    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtPreviousTransactions = new javax.swing.JTable();
        jlNumberIn = new javax.swing.JLabel();
        jlHeadCheckedIn = new javax.swing.JLabel();
        jlHeadSoldLabel = new javax.swing.JLabel();
        jlHeadSold = new javax.swing.JLabel();
        jlWeighMaster = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jcbAudienceDisplays = new java.awt.Checkbox();
        jcbPrintTickets = new java.awt.Checkbox();
        jbZeroBalance = new java.awt.Button();
        jbWeighBack = new java.awt.Button();
        jbWeightOff = new java.awt.Button();
        jbComment = new java.awt.Button();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jbSelectAll = new javax.swing.JButton();
        jbCancelMD = new javax.swing.JButton();
        jbProcess = new javax.swing.JButton();
        jlMultidraft = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Clerk - Ver. 2.0 (April 1, 2011)");

        jtPreviousTransactions.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Trans", "Head", "Description", "Weight", "Average", "Seller", "Buyer", "Bid"
            }
        ));
        jtPreviousTransactions.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jtPreviousTransactions);

        jlNumberIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlNumberIn.setText("Head In:");

        jlHeadCheckedIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadCheckedIn.setText("0");
        jlHeadCheckedIn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlHeadSoldLabel.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSoldLabel.setText("Head Sold:");

        jlHeadSold.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSold.setText("0");
        jlHeadSold.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlWeighMaster.setFont(new java.awt.Font("Dialog", 1, 18));
        jlWeighMaster.setText("Weigh Master");

        jTextField1.setFont(new java.awt.Font("Dialog", 0, 18));
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jcbAudienceDisplays.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbAudienceDisplays.setLabel("Audience Displays");
        jcbAudienceDisplays.setState(true);

        jcbPrintTickets.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbPrintTickets.setLabel("Print Tickets");
        jcbPrintTickets.setState(true);

        jbZeroBalance.setFont(new java.awt.Font("Dialog", 1, 12));
        jbZeroBalance.setLabel("Zero Balance");
        jbZeroBalance.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbZeroBalanceMouseClicked(evt);
            }
        });

        jbWeighBack.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeighBack.setLabel("Weigh Back");
        jbWeighBack.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeighBackMouseClicked(evt);
            }
        });

        jbWeightOff.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeightOff.setLabel("Weight Display Off/On");
        jbWeightOff.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeightOffMouseClicked(evt);
            }
        });

        jbComment.setFont(new java.awt.Font("Dialog", 1, 12));
        jbComment.setLabel("Comment");
        jbComment.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbCommentMouseClicked(evt);
            }
        });

        jTable2.setFont(new java.awt.Font("Dialog", 0, 18));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Draft", "Head", "Weight", "Average"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setShowHorizontalLines(false);
        jTable2.setShowVerticalLines(false);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTable2);
        jTable2.getColumnModel().getColumn(0).setResizable(false);

        jbSelectAll.setText("Select All");

        jbCancelMD.setText("Delete All");

        jbProcess.setText("Process");

        jlMultidraft.setFont(new java.awt.Font("Dialog", 1, 18));
        jlMultidraft.setText("Multidraft:");

        jButton1.setText("Multidraft On/off");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Reweigh");

        jButton3.setText("Edit Head Count");
        jButton3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 216, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 276, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNumberIn, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jlHeadSoldLabel)
                                .addGap(29, 29, 29)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jlHeadSold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jlHeadCheckedIn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(120, 120, 120)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jlMultidraft)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(jbProcess, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jbSelectAll, javax.swing.GroupLayout.Alignment.LEADING))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jbCancelMD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jButton1))))
                                        .addGap(187, 187, 187)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton2)
                                    .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jlWeighMaster)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(85, 85, 85)
                                .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlNumberIn)
                    .addComponent(jlHeadCheckedIn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlHeadSoldLabel)
                        .addComponent(jlHeadSold))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(53, 53, 53)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jlMultidraft)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbProcess)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbSelectAll)
                            .addComponent(jbCancelMD))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlWeighMaster)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      

 if (multidraftFlag == 0) {   
    jButton1.setBackground(Color.red);
    jButton1.setForeground(Color.white);
    multidraftFlag = 1;
 }
 else {
    jButton1.setBackground(defaultButtonColor);
    jButton1.setForeground(Color.black);
    multidraftFlag = 0;
 }
    
}                                     

private void jbWeightOffMouseClicked(java.awt.event.MouseEvent evt) {                                         
// TODO add your handling code here:
 if (weightDisplayFlag == 0) {
     jbWeightOff.setBackground(Color.red);
     jbWeightOff.setForeground(Color.white);
     weightDisplayFlag = 1;
 }
 else {
     jbWeightOff.setBackground(defaultButtonColor);
     jbWeightOff.setForeground(Color.black);
     weightDisplayFlag = 0;
 }
}                                        

private void jbWeighBackMouseClicked(java.awt.event.MouseEvent evt) {                                         
// TODO add your handling code here:
}                                        

private void jbZeroBalanceMouseClicked(java.awt.event.MouseEvent evt) {                                           
// TODO add your handling code here:
try {
 if (zeroBalanceFlag == 0) {
     jbZeroBalance.setBackground(Color.red);
     jbZeroBalance.setForeground(Color.white);
     
     // Go print a zero balance ticket
     Thread.sleep(4000);     

     jbZeroBalance.setBackground(defaultButtonColor);
     jbZeroBalance.setForeground(Color.black);
 }   
} catch(Exception e) {
    JOptionPane.showMessageDialog(null, "ClassNotFoundException: " +
        e.getMessage());
}

}                                          

private void jbCommentMouseClicked(java.awt.event.MouseEvent evt) {                                       

    String str = JOptionPane.showInputDialog(null, "Comment : ", 
        "Clerk Comment", 1);
    if(str != null) {
        // Store the comment where ever
    }
    
}                                      

    /**
    * @param args the command line arguments
    */
/*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainScreen().setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton jbCancelMD;
    private java.awt.Button jbComment;
    private javax.swing.JButton jbProcess;
    private javax.swing.JButton jbSelectAll;
    private java.awt.Button jbWeighBack;
    private java.awt.Button jbWeightOff;
    private java.awt.Button jbZeroBalance;
    private java.awt.Checkbox jcbAudienceDisplays;
    private java.awt.Checkbox jcbPrintTickets;
    private javax.swing.JLabel jlHeadCheckedIn;
    private javax.swing.JLabel jlHeadSold;
    private javax.swing.JLabel jlHeadSoldLabel;
    private javax.swing.JLabel jlMultidraft;
    private javax.swing.JLabel jlNumberIn;
    private javax.swing.JLabel jlWeighMaster;
    private javax.swing.JTable jtPreviousTransactions;
    // End of variables declaration

}

Open in new window

The following code is with the change you suggested in comment #37306629.  The change shows up in line 195.  Hope some of this helps.
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */

package jclerk;



import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {
    
    ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;
  
 
     	
private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = connectDatabase.getConnection();
   
    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        Statement stmt = (Statement) con.createStatement();
        // let database sort the values for you
        ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
        while (rec.next()) {            
            key = rec.getString("skey");
            value = rec.getString("svalue");
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
        }
        rec.close();
        stmt.close();
    } catch (SQLException sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
            con.close();
        } catch (SQLException e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
        fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
    return propertyPanel;
}

    public static void main(String[] args) {
       new MainScreen();
    }

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }
    
    /** Creates new form MainScreen */
    public MainScreen() {
        initComponents();

//        populateClerkScreen();
//        jPanel1.add(populateClerkScreen());
//        this.getContentPane().add( populateClerkScreen());

//        this.setSize(400,200);
//        this.setVisible(true);
        
    }

    
    
    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtPreviousTransactions = new javax.swing.JTable();
        jlNumberIn = new javax.swing.JLabel();
        jlHeadCheckedIn = new javax.swing.JLabel();
        jlHeadSoldLabel = new javax.swing.JLabel();
        jlHeadSold = new javax.swing.JLabel();
        jlWeighMaster = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jcbAudienceDisplays = new java.awt.Checkbox();
        jcbPrintTickets = new java.awt.Checkbox();
        jbZeroBalance = new java.awt.Button();
        jbWeighBack = new java.awt.Button();
        jbWeightOff = new java.awt.Button();
        jbComment = new java.awt.Button();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jbSelectAll = new javax.swing.JButton();
        jbCancelMD = new javax.swing.JButton();
        jbProcess = new javax.swing.JButton();
        jlMultidraft = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel1 = populateClerkScreen();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Clerk - Ver. 2.0 (April 1, 2011)");

        jtPreviousTransactions.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Trans", "Head", "Description", "Weight", "Average", "Seller", "Buyer", "Bid"
            }
        ));
        jtPreviousTransactions.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jtPreviousTransactions);

        jlNumberIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlNumberIn.setText("Head In:");

        jlHeadCheckedIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadCheckedIn.setText("0");
        jlHeadCheckedIn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlHeadSoldLabel.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSoldLabel.setText("Head Sold:");

        jlHeadSold.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSold.setText("0");
        jlHeadSold.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlWeighMaster.setFont(new java.awt.Font("Dialog", 1, 18));
        jlWeighMaster.setText("Weigh Master");

        jTextField1.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jcbAudienceDisplays.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbAudienceDisplays.setLabel("Audience Displays");
        jcbAudienceDisplays.setState(true);

        jcbPrintTickets.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbPrintTickets.setLabel("Print Tickets");
        jcbPrintTickets.setState(true);

        jbZeroBalance.setFont(new java.awt.Font("Dialog", 1, 12));
        jbZeroBalance.setLabel("Zero Balance");
        jbZeroBalance.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbZeroBalanceMouseClicked(evt);
            }
        });

        jbWeighBack.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
        jbWeighBack.setLabel("Weigh Back");
        jbWeighBack.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeighBackMouseClicked(evt);
            }
        });

        jbWeightOff.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeightOff.setLabel("Weight Display Off/On");
        jbWeightOff.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeightOffMouseClicked(evt);
            }
        });

        jbComment.setFont(new java.awt.Font("Dialog", 1, 12));
        jbComment.setLabel("Comment");
        jbComment.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbCommentMouseClicked(evt);
            }
        });

        jTable2.setFont(new java.awt.Font("Dialog", 0, 18));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Draft", "Head", "Weight", "Average"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setShowHorizontalLines(false);
        jTable2.setShowVerticalLines(false);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTable2);
        jTable2.getColumnModel().getColumn(0).setResizable(false);

        jbSelectAll.setText("Select All");

        jbCancelMD.setText("Delete All");

        jbProcess.setText("Process");

        jlMultidraft.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
        jlMultidraft.setText("Multidraft:");

        jButton1.setText("Multidraft On/off");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Reweigh");

        jButton3.setText("Edit Head Count");
        jButton3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 216, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 276, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNumberIn, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jlHeadSoldLabel)
                                .addGap(29, 29, 29)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jlHeadSold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jlHeadCheckedIn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(120, 120, 120)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jlMultidraft)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(jbProcess, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jbSelectAll, javax.swing.GroupLayout.Alignment.LEADING))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jbCancelMD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jButton1))))
                                        .addGap(187, 187, 187)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton2)
                                    .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jlWeighMaster)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(85, 85, 85)
                                .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlNumberIn)
                    .addComponent(jlHeadCheckedIn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlHeadSoldLabel)
                        .addComponent(jlHeadSold))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(53, 53, 53)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jlMultidraft)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbProcess)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbSelectAll)
                            .addComponent(jbCancelMD))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlWeighMaster)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      

 if (multidraftFlag == 0) {   
    jButton1.setBackground(Color.red);
    jButton1.setForeground(Color.white);
    multidraftFlag = 1;
 }
 else {
    jButton1.setBackground(defaultButtonColor);
    jButton1.setForeground(Color.black);
    multidraftFlag = 0;
 }
    
}                                     

private void jbWeightOffMouseClicked(java.awt.event.MouseEvent evt) {                                         
// TODO add your handling code here:
 if (weightDisplayFlag == 0) {
     jbWeightOff.setBackground(Color.red);
     jbWeightOff.setForeground(Color.white);
     weightDisplayFlag = 1;
 }
 else {
     jbWeightOff.setBackground(defaultButtonColor);
     jbWeightOff.setForeground(Color.black);
     weightDisplayFlag = 0;
 }
}                                        

private void jbWeighBackMouseClicked(java.awt.event.MouseEvent evt) {                                         
// TODO add your handling code here:
}                                        

private void jbZeroBalanceMouseClicked(java.awt.event.MouseEvent evt) {                                           
// TODO add your handling code here:
try {
 if (zeroBalanceFlag == 0) {
     jbZeroBalance.setBackground(Color.red);
     jbZeroBalance.setForeground(Color.white);
     
     // Go print a zero balance ticket
     Thread.sleep(4000);     

     jbZeroBalance.setBackground(defaultButtonColor);
     jbZeroBalance.setForeground(Color.black);
 }   
} catch(Exception e) {
    JOptionPane.showMessageDialog(null, "ClassNotFoundException: " +
        e.getMessage());
}

}                                          

private void jbCommentMouseClicked(java.awt.event.MouseEvent evt) {                                       

    String str = JOptionPane.showInputDialog(null, "Comment : ", 
        "Clerk Comment", 1);
    if(str != null) {
        // Store the comment where ever
    }
    
}                                      

    /**
    * @param args the command line arguments
    */
/*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainScreen().setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify                     
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton jbCancelMD;
    private java.awt.Button jbComment;
    private javax.swing.JButton jbProcess;
    private javax.swing.JButton jbSelectAll;
    private java.awt.Button jbWeighBack;
    private java.awt.Button jbWeightOff;
    private java.awt.Button jbZeroBalance;
    private java.awt.Checkbox jcbAudienceDisplays;
    private java.awt.Checkbox jcbPrintTickets;
    private javax.swing.JLabel jlHeadCheckedIn;
    private javax.swing.JLabel jlHeadSold;
    private javax.swing.JLabel jlHeadSoldLabel;
    private javax.swing.JLabel jlMultidraft;
    private javax.swing.JLabel jlNumberIn;
    private javax.swing.JLabel jlWeighMaster;
    private javax.swing.JTable jtPreviousTransactions;
    // End of variables declaration                   

}

Open in new window

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainScreen.java
 *
 * Created on Mar 27, 2011, 8:57:25 PM
 */

package jclerk;



//import com.mysql.jdbc.Connection;
//import com.mysql.jdbc.Statement;
import java.awt.Color;
import java.awt.GridLayout;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author al
 */

public class MainScreen extends javax.swing.JFrame {

  //  ConnectDatabase connectDatabase = new ConnectDatabase();
    int multidraftFlag = 0;
    int weightDisplayFlag = 0;
    int zeroBalanceFlag = 0;
    Color defaultButtonColor = new Color(238, 238, 238);
    String [][] columnData;

//    public Connection con;
    String[] order;



private List<PropertyDisplay> orderedPropertyDisplays = new ArrayList<PropertyDisplay>();
private Map<String, PropertyDisplay> propertyDisplayMap =  new HashMap<String, PropertyDisplay>();

private JPanel populateClerkScreen() {
    Connection con = null;
    //connectDatabase.getConnection();

    // PropertyDisplay objects will be stored in both a
    // List, for access to the correct ordering, and a
    // Map, so you can get the PropertyDisplay for a
    // particular property key
    try {
        Statement stmt = null;
        //(Statement) con.createStatement();
        // let database sort the values for you
       // ResultSet rec = stmt.executeQuery("SELECT skey, svalue FROM setup WHERE skey LIKE 'cOrder%' ORDER BY svalue");
        String key;
        String value;
        PropertyDisplay prop;
        /*
        while (rec.next()) {
            key = rec.getString("skey");
            value = rec.getString("svalue");
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);
            */

             key = "Head Count:";
        value = "50";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);

          key = "Total Weight:";
        value = "500";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


           key = "Seller Number: ";
        value = "438";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Desc Code: ";
        value = "A514";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);


             key = "Tag Number: ";
        value = "B718";
            prop = new PropertyDisplay(key, value);
            orderedPropertyDisplays.add(prop);
            propertyDisplayMap.put(key, prop);






      //  }
      //  rec.close();
      //  stmt.close();
    } catch (Exception sqe) {
        JOptionPane.showMessageDialog(null,
            "populateClerkScreen: " + sqe.getMessage());
    } finally {
        // attempt to close the connection since you are done with it
        try {
         //   con.close();
        } catch (Exception e) {
            // can ignore, but better to log
            e.printStackTrace(System.err);
        }
    }

    // now create property panel GUI
    JPanel propertyPanel = new JPanel();
    propertyPanel.setLayout(new GridLayout(orderedPropertyDisplays.size(), 1));
    for (PropertyDisplay prop : orderedPropertyDisplays) {
        JPanel pnl = new JPanel();
        GridLayout fl = new GridLayout(1,2);
        fl.setVgap(10);
        pnl.setLayout(fl);
        JLabel label = prop.getLabel();
        label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        pnl.add(label);
        pnl.add(prop.getTextField());
        propertyPanel.add(pnl);
    }
    return propertyPanel;
}
/*
    public static void main(String[] args) {
       new MainScreen();
    }
    */

// slight change to PropertyDisplay, adding 'value' to constructor
// and set/getValue() methods
    private static class PropertyDisplay {
        private final String property;
        private final JLabel label;
        private final JTextField textField;

        public PropertyDisplay(String property, String value) {
            this.property = property;
            this.label = new JLabel(property);
            this.textField = new JTextField(value);
        }

        public String getProperty() {
            return property;
        }

        public JLabel getLabel() {
            return label;
        }

        public JTextField getTextField() {
            return textField;
        }

        public void setValue(String value) {
            textField.setText(value);
        }

        public String getValue() {
            return textField.getText();
        }
    }

    /** Creates new form MainScreen */
    public MainScreen() {
       initComponents();
        
      //  populateClerkScreen();

        //this.getContentPane().add( populateClerkScreen());

       // this.setSize(400,200);
       // this.setVisible(true);

    }



    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">

  private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtPreviousTransactions = new javax.swing.JTable();
        jlNumberIn = new javax.swing.JLabel();
        jlHeadCheckedIn = new javax.swing.JLabel();
        jlHeadSoldLabel = new javax.swing.JLabel();
        jlHeadSold = new javax.swing.JLabel();
        jlWeighMaster = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jcbAudienceDisplays = new java.awt.Checkbox();
        jcbPrintTickets = new java.awt.Checkbox();
        jbZeroBalance = new java.awt.Button();
        jbWeighBack = new java.awt.Button();
        jbWeightOff = new java.awt.Button();
        jbComment = new java.awt.Button();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jbSelectAll = new javax.swing.JButton();
        jbCancelMD = new javax.swing.JButton();
        jbProcess = new javax.swing.JButton();
        jlMultidraft = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
       jPanel1 = new javax.swing.JScrollPane();
         jPanel1.setViewportView(populateClerkScreen());
        //jPanel1 = populateClerkScreen();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Clerk - Ver. 2.0 (April 1, 2011)");

        jtPreviousTransactions.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Trans", "Head", "Description", "Weight", "Average", "Seller", "Buyer", "Bid"
            }
        ));
        jtPreviousTransactions.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jtPreviousTransactions);

        jlNumberIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlNumberIn.setText("Head In:");

        jlHeadCheckedIn.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadCheckedIn.setText("0");
        jlHeadCheckedIn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlHeadSoldLabel.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSoldLabel.setText("Head Sold:");

        jlHeadSold.setFont(new java.awt.Font("Dialog", 1, 18));
        jlHeadSold.setText("0");
        jlHeadSold.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jlWeighMaster.setFont(new java.awt.Font("Dialog", 1, 18));
        jlWeighMaster.setText("Weigh Master");

        jTextField1.setFont(new java.awt.Font("Dialog", 0, 18));
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jcbAudienceDisplays.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbAudienceDisplays.setLabel("Audience Displays");
        jcbAudienceDisplays.setState(true);

        jcbPrintTickets.setFont(new java.awt.Font("Dialog", 1, 18));
        jcbPrintTickets.setLabel("Print Tickets");
        jcbPrintTickets.setState(true);

        jbZeroBalance.setFont(new java.awt.Font("Dialog", 1, 12));
        jbZeroBalance.setLabel("Zero Balance");
        jbZeroBalance.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbZeroBalanceMouseClicked(evt);
            }
        });

        jbWeighBack.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeighBack.setLabel("Weigh Back");
        jbWeighBack.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeighBackMouseClicked(evt);
            }
        });

        jbWeightOff.setFont(new java.awt.Font("Dialog", 1, 12));
        jbWeightOff.setLabel("Weight Display Off/On");
        jbWeightOff.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbWeightOffMouseClicked(evt);
            }
        });

        jbComment.setFont(new java.awt.Font("Dialog", 1, 12));
        jbComment.setLabel("Comment");
        jbComment.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbCommentMouseClicked(evt);
            }
        });

        jTable2.setFont(new java.awt.Font("Dialog", 0, 18));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Draft", "Head", "Weight", "Average"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setShowHorizontalLines(false);
        jTable2.setShowVerticalLines(false);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTable2);
        jTable2.getColumnModel().getColumn(0).setResizable(false);

        jbSelectAll.setText("Select All");

        jbCancelMD.setText("Delete All");

        jbProcess.setText("Process");

        jlMultidraft.setFont(new java.awt.Font("Dialog", 1, 18));
        jlMultidraft.setText("Multidraft:");

        jButton1.setText("Multidraft On/off");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Reweigh");

        jButton3.setText("Edit Head Count");
        jButton3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
/*
        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 216, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 276, Short.MAX_VALUE)
        );
        */

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNumberIn, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jlHeadSoldLabel)
                                .addGap(29, 29, 29)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jlHeadSold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jlHeadCheckedIn, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(120, 120, 120)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jlMultidraft)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(jbProcess, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jbSelectAll, javax.swing.GroupLayout.Alignment.LEADING))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jbCancelMD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jButton1))))
                                        .addGap(187, 187, 187)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton2)
                                    .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jlWeighMaster)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(85, 85, 85)
                                .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlNumberIn)
                    .addComponent(jlHeadCheckedIn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlHeadSoldLabel)
                        .addComponent(jlHeadSold))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(53, 53, 53)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jlMultidraft)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbProcess)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jbSelectAll)
                            .addComponent(jbCancelMD))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbZeroBalance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeighBack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbWeightOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jlWeighMaster)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jcbAudienceDisplays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbPrintTickets, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>





    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

 if (multidraftFlag == 0) {
    jButton1.setBackground(Color.red);
    jButton1.setForeground(Color.white);
    multidraftFlag = 1;
 }
 else {
    jButton1.setBackground(defaultButtonColor);
    jButton1.setForeground(Color.black);
    multidraftFlag = 0;
 }

}

private void jbWeightOffMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
 if (weightDisplayFlag == 0) {
     jbWeightOff.setBackground(Color.red);
     jbWeightOff.setForeground(Color.white);
     weightDisplayFlag = 1;
 }
 else {
     jbWeightOff.setBackground(defaultButtonColor);
     jbWeightOff.setForeground(Color.black);
     weightDisplayFlag = 0;
 }
}

private void jbWeighBackMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}

private void jbZeroBalanceMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
try {
 if (zeroBalanceFlag == 0) {
     jbZeroBalance.setBackground(Color.red);
     jbZeroBalance.setForeground(Color.white);

     // Go print a zero balance ticket
     Thread.sleep(4000);

     jbZeroBalance.setBackground(defaultButtonColor);
     jbZeroBalance.setForeground(Color.black);
 }
} catch(Exception e) {
    JOptionPane.showMessageDialog(null, "ClassNotFoundException: " +
        e.getMessage());
}

}

private void jbCommentMouseClicked(java.awt.event.MouseEvent evt) {

    String str = JOptionPane.showInputDialog(null, "Comment : ",
        "Clerk Comment", 1);
    if(str != null) {
        // Store the comment where ever
    }

}

    /**
    * @param args the command line arguments
    */

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainScreen().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton jbCancelMD;
    private java.awt.Button jbComment;
    private javax.swing.JButton jbProcess;
    private javax.swing.JButton jbSelectAll;
    private java.awt.Button jbWeighBack;
    private java.awt.Button jbWeightOff;
    private java.awt.Button jbZeroBalance;
    private java.awt.Checkbox jcbAudienceDisplays;
    private java.awt.Checkbox jcbPrintTickets;
    private javax.swing.JLabel jlHeadCheckedIn;
    private javax.swing.JLabel jlHeadSold;
    private javax.swing.JLabel jlHeadSoldLabel;
    private javax.swing.JLabel jlMultidraft;
    private javax.swing.JLabel jlNumberIn;
    private javax.swing.JLabel jlWeighMaster;
    private javax.swing.JTable jtPreviousTransactions;
    private javax.swing.JScrollPane jPanel1;

    // End of variables declaration

}

Open in new window

with-table.PNG
Another consideration is that I only have limited access to the code in initCompontents() as it is created by netbeans and the only access is through netbeans.
I also did it in Netbeans, but I modified code in iinitComponents without problems
MainScreen.java
Your most recent post is what I am trying to do.  What did you change?
I changed jPanel1 into JScrollPane and addded this clerk panel to the viewport of jPanel1 and
commented out the stuff about jPanel1 layout
Did you just cut and past the code and bring it up with netbeans?  I created the GUI with netbeans and you probably cut and pasted the code that might allow you to edit it.
Yes, I think you may just replace your java file with that which I attached - after than only correct the part
which has to do with database selection
How will that react then when I start making adjustments in the GUI using netbeans?
Don't know about that.

Alternatively create again your GUI - place JScrollPane in that place and then just add this operator where it adds viewportview


In the worst case after the adjustments you can add that operator again.

In general drop this netbeans stuff - it is extremely inconvenient and you are not learning how to do it in a normal way.
They are even writing that they are not going to support it in future.

If you create a generic frame using netbeans and then add a jpanel you can right click on the panel, go to customize code and that is where I made the change you suggested.  There is another line you can change and I am not sure whether that is of interest to us or not.  There are also several other option that might be of interest.  If you create a frame and panel you will see what I am talking about.
But that change which you made with right-clicking  still didn't work.
Rather create in that place JScrollPnae and add that line which I mentioned - after your GUI is ready - you see it works that way.
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I copied the line you used into my public MainScreen() and I got an error:

cannot find symbol
  symbol:    method setViewportView(java.swing.jPanel)
  location: variable jPanel1 of type javax.swing.jpanel
As I told you in my code I changed jPanel1 to type JScrollPanel  (it is no longer JPanel, but JScrollPanel)

So I suggest that you go bacjk to your designer and place JScrllPane on that position where you want to see these lable/texts
- it will generate soem variable of type JScrllPane sitting in the same place - you'll then look up how they named this
variable and use that variable name in that line instead of jPanel1
Well, I guess the bottom line is the View only works on a pane and not on a panel as it works on scrollpanes, tabbedPanes and so forth.  It works.  One more quick question, what line do I use to adjust the length of the text boxes and the size of the label font?

Thanks yan
In the constructor of JTextField you provide number of charcaters and that's how it will make length of the textfield

But these questions are not that starightforward - they depend on interactions with layouts and many factors - so you
make layout and then try to adjust if you are not stasified by modifying layouts and properties, like number of charcaters, etc -
so  there is no simple answer to that question.

BTW, I think your box for now looks good.
Thank you you very much.  There has been so much going on here I don't know where to begin when it comes to accepting the solution.  Several comments have led to the solution.  I have some other questions concerning spacing and sizing of the text boxes but I suppose it would be best to open another question.  Thank you for hanging in there, I appreciate it.

Cheers, maybe you can lend a hand when I pose a question or two about the sizing.   Good night if you are in the western hemisphere.
You are always welcome.
Good night!
Perfect!