Jtextfield initializations

hello,
new in Jdev and java - France
Jdeveloper 9i - version 9.0.4.0 (build 1407)
same demand as number 318074
1) In a Panelxxxx.java for a form created automatically via the Swing/ Jclient for BC4J - Form, I have inserted a Jbutton to create a new row (instead of the + JUNavigationBar).
//Positionne le panel en Insert Mode
RowIterator iter = null;
iter = navBar.getModel().getNavigatableRowIterator();
Row row = iter.createRow();
iter.insertRow(row);
all the fields have a "document - Jclient Attribute binding"
then i set some Jtextfields automatically, exemple :
mNivUrg.setText(result1);
or setting some others in the EOImpl.java
it works but when I entered a value in any field, many values initialized (not all...) disappeared.
if I entered the value again manually, when I commit, it seems that the EO Attribute are not informed...
What do I do?
I have seen in the foraum that maybe I have to call textfieldbinding.setDataValueAt(text,0)...??? but what means textfieldbinding? if it is the solution.
2) I have a big problem with the control hints for the EO (and the view linked).
the first to attributes are:
NoTicket - type number
Horodate - type date
in the control hints when i indicate number and a format for the first, the control hints for the second propose me a number-currency type (it must be simple date).
when i choose simple date for the second, it re-initialize the first attribute to format type in control hints at simple date...???
do you have heard of this bug. strange.
so when I commit, it tells me that the field horadate for exemple is not in the good format!
(oracle.jbo.JboException) JBO-29000: Cannot format given Object as a Date
could you help me?
thanks

Rahim_From_Puniyal wrote:
Yannix
i post this thread at java programming forum. You reply me that "should be post at swing forum" then i post it again here you again reply my question like your previous answer.I said Next time Swing related question should be posted in the Swing forum.
In short next time you have a new problem about swing post it in here. Simple English.
Please don't reply if you don't have any useful answer to the question ok.
your are not alone here at SUN developer forum. May be some give me a useful answer of my question and who is not memeber of java programming forum. that's allI think your are just one of those guys who doesn't read a post carefully.
If you take a look at your other post I did give you an answer in reply # 1. Read Carefully.
So before you tell me what's my problem you should read the thread carefully.
and If you carefully read reply#1 I did state read your other thread for solution.

Similar Messages

  • Missing method body or declare abstract error

    Hi!
    I have been working on this simple Java 1.3.1 program for three days now and cannot figure out what I am doing wrong. If anyone has done the "Building an Application" tutorial in the New to Java Programming Center, you might recognize the code. I am trying to set up a frame with panels first using the BorderLayout and then the FlowLayout within each section of the BorderLayout. It will have textfields and checkboxes. I am working on the code to retrieve the user input from the text boxes and also to determine which checkbox the user has checked. Here is my code: (ignore my irrelivent comments!)
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.awt.event.*;
    import java.awt.Color.*;
    import java.awt.Image.*;
    //Header Comment for a Routine/Method
    //This method gathers the input text supplied by the user from five text fields on the Current
    //Purchase tab of the tabbed pane of the MPGLog.java program. The way it gathers the text
    //depends on the current processing state, which it retrieves on its own. It saves the text to
    //a text file called textinput.txt.
    public class CollectTextInput extends JPanel implements ActionListener
    { // Begin class
         //Declare all the objects needed first.
         // These are the text fields
         private JTextField currentMileage;
         private JTextField numofGallonsBought;
         private JTextField dateofPurchase;
         private JTextField pricePerGallon;
         private JTextField gasBrand;
         // Declaring the Labels to go with each TextField
         private JLabel lblcurrentMileage;
         private JLabel lblnumofGallonsBought;
         private JLabel lbldateofPurchase;
         private JLabel lblpricePerGallon;
         private JLabel lblgasBrand;
         // Declaring the Checkboxes for the types of gas bought
         private JCheckBox chbxReg;
         private JCheckBox chbxSuper;
         private JCheckBox chbxUltra;
         private JCheckBox chbxOther;
         private JCheckBox chbxHigher;
         private JCheckBox chbxLower;
         // Declaring the Buttons and images needed
         private JButton enter;
         private JButton edit;
         //private JButton report; //Will be used later
         private JLabel bluecar;          //Used with the ImageIcon to create CRV image
         private JPanel carimage;     //Used in buildImagePanel method
         private JPanel datum;          //Used in buildDatumPanel method
         private JPanel gasgrade;     //Used in buildGasTypePanel method.
         //Declaring the Panels that need to be built and added
         //to the border layout of this panel.
         //private JPanel panlimages;
         //private JPanel panltextinputs;
         //private JPanel panlchkBoxes;
         // Class to handle functionality of checkboxes
         ItemListener handler = new CheckBoxHandler();
         // This is where you add the constructor for the class - I THINK!!
         public CollectTextInput()
         { // Opens collectTextInput constructor
              // Must set layout for collectTextInput here
              // Choosing a BorderLayout because we simply want to
              // add panels to the North, Center and South borders, which, by
              // default, will fill the layout with the three panels
              // we are creating
              setLayout(new BorderLayout());
              //Initialize the objects in the constructor of the class.
              //Initialize the textfields
              currentMileage = new JTextField();
              numofGallonsBought = new JTextField();
              dateofPurchase = new JTextField();
              pricePerGallon = new JTextField();
              gasBrand = new JTextField();
              // Initialize the labels that go with each TextField
              lblcurrentMileage = new JLabel("Enter the mileage at the time of gas purchase: ");
              lblnumofGallonsBought = new JLabel("Enter the number of gallons of gas bought: ");
              lbldateofPurchase = new JLabel("Enter the date of the purchase: ");
              lblpricePerGallon = new JLabel("Enter the price per gallon you paid for the gas: ");
              lblgasBrand = new JLabel("Enter the brand name of the gas: ");
              //Initialize the labels for the checkboxes.
              chbxReg = new JCheckBox("Regular ", true);
              chbxSuper = new JCheckBox("Super ");
              chbxUltra = new JCheckBox("Ultra ");
              chbxOther = new JCheckBox("Other: (Choose one from below) ");
              chbxHigher = new JCheckBox("Higher than Ultra ");
              chbxLower = new JCheckBox("Lower than Ultra ");
              //Initialize the buttons that go on the panel.
              enter = new JButton("Save Data");
              edit = new JButton("Edit Data");
              //Initialize the image that oges on the panel.
              bluecar = new JLabel("2002 Honda CR-V", new ImageIcon("CRVBlue.jpg"),JLabel.CENTER);
              // Now bring it all together by calling the other methods
              // that build the other panels and menu.
              buildImagePanel();
              buildDatumPanel();
              buildGasTypePanel();
              // Once the methods above build the panels, this call to add
              //  them will add the panels to the main panel's border
              // layout manager.
              add(datum, BorderLayout.NORTH);
              add(carimage, BorderLayout.EAST);
              add(gasgrade, BorderLayout.CENTER);
         } // Ends the constructor.
            // This method creates a panel called images that holds the car image.
         public void buildImagePanel();
         { // Opens buildImagePanel.
              // First, create the Panel
              carimage = new JPanel();
              //Second, set the color and layout.
              carimage.setBackground(Color.white);
              carimage.setLayout(new FlowLayout());
              // Third, add the image to the panel.
              carimage.add(bluecar);
         }// Closes buildImagePanel
         //This method creates a panel called datum that holds the text input.
         public void buildDatumPanel();
         { //Opens buildDatumPanel
              // First, create the Panel.
              datum = new JPanel();
              //Second, set the background color and layout.
              datum.setBackground(Color.white);
              datum.setLayout(new GridLayout(2, 4, 20, 20));
              //Third, add the textfields and text labels to the panel.
              datum.add(lblcurrentMileage);
              datum.add(currentMileage);
              datum.add(lblnumofGallonsBought);
              datum.add(numofGallonsBought);
              datum.add(lbldateofPurchase);
              datum.add(dateofPurchase);
              datum.add(lblpricePerGallon);
              datum.add(pricePerGallon);
              datum.add(lblgasBrand);
              datum.add(gasBrand);
              //Optionally - Fourth -set a border around the panel, including
              // a title.
              datum.setBorder(BorderFactory.createTitledBorder("Per Purchase Information"));
              //Fifth - Add listeners to each text field to be able to
              //  know when data is input into them.
              currentMileage.addActionListener(this);
              numofGallonsBought.addActionListener(this);
              dateofPurchase.addActionListener(this);
              pricePerGallon.addActionListener(this);
              gasBrand.addActionListener(this);
         }// Closes buildDatumPanel
         // This method builds a panel called gasTypePanel that holds the checkboxes.
         public void buildGasTypePanel()
         { // Opens buildGasTypePanel method
              // First, create the panel.
              gasgrade = new JPanel();
              // Second, set its background color and its layout.
              gasgrade.setBackground(Color.white);
              gasgrade.setLayout(new GridLayout(5, 1, 10, 20));
              // Third, add all the checkboxes to the panel.
              gasgrade.add(chbxReg);
              gasgrade.add(chbxSuper);
              gasgrade.add(chbxUltra);
              gasgrade.add(chbxOther);
              gasgrade.add(chbxHigher);
              gasgrade.add(chbxLower);
              //Optionally, - Fourth - set a border around the panel, including
              // a title.
              gasgrade.setBorder(BorderFactory.createTitledBorder("Gas Type Information"));
              // Fifth - CheckBoxes require a CheckBox Handler.
              // This is a method created separately
              // outside of the method where the checkboxes are added to
              // the panel or where the checkboxes are even created.
              // This method (CheckBox Handler) implements and ItemListener
              // and is a self-contained method all on its own. See
              // the CheckBox Handler methods following the
              // actionPerformed method which follows.-SLM
         } // Closes the buildGasTypePanel method
    // Create the functionality to capture and react to an event
    //   for the checkboxes when they are checked by the user and
    //   the text fields to know when text is entered. Also to react to the
    //   Enter button being pushed and the edit button being pushed.
    public void actionPerformed(ActionEvent evt)
    { // Opens actionPerformed method.
         if((evt.getSource() == currentMileage) || (evt.getSource() == enter))
              { // Opens if statement.
                // Retrieves the text from the currentMileage text field
                //  and assigns it to the variable currentMileageText of
                //  type String.
                String currentMileageText = currentMileage.getText();
                lblcurrentMileage.setText("Current Mileage is:    " + currentMileageText);
                // After printing text to JLabel, hide the text field.
                currentMileage.setVisible(false);
           } // Ends if statement.
          if((evt.getSource() == numofGallonsBought) || (evt.getSource() == enter))
              { // Opens if statement.
                // Retrieves the text from the numofGallonsBought text field
                //  and assigns it to the variable numofGallonsBoughtText of
                //  type String.
                String numofGallonsBoughtText = numofGallonsBought.getText();
                lblnumofGallonsBought.setText("The number of gallons of gas bought is:    " + numofGallonsBoughtText);
                // After printing text to JLabel, hide the text field.
                numofGallonsBought.setVisible(false);
           } // Ends if statement.
           if((evt.getSource() == dateofPurchase) || (evt.getSource() == enter))
                     { // Opens if statement.
                       // Retrieves the text from the dateofPurchase text field
                       //  and assigns it to the variable dateofPurchaseText of
                       //  type String.
                       String dateofPurchaseText = dateofPurchase.getText();
                       lbldateofPurchase.setText("The date of this purchase is:    " + dateofPurchaseText);
                       // After printing text to JLabel, hide the text field.
                       dateofPurchase.setVisible(false);
           } // Ends if statement.
           if((evt.getSource() == pricePerGallon) || (evt.getSource() == enter))
                            { // Opens if statement.
                              // Retrieves the text from the pricePerGallon text field
                              //  and assigns it to the variable pricePerGallonText of
                              //  type String.
                              String pricePerGallonText = pricePerGallon.getText();
                              lblpricePerGallon.setText("The price per gallon of gas for this purchase is:    " + pricePerGallonText);
                              // After printing text to JLabel, hide the text field.
                              pricePerGallon.setVisible(false);
           } // Ends if statement.
           if((evt.getSource() == gasBrand) || (evt.getSource() == enter))
                       { // Opens if statement.
                         // Retrieves the text from the gasBrand text field
                         //  and assigns it to the variable gasBrandText of
                         //  type String.
                         String gasBrandText = gasBrand.getText();
                         lblgasBrand.setText("The Brand of gas for this purchase is:    " + gasBrandText);
                         // After printing text to JLabel, hide the text field.
                         gasBrand.setVisible(false);
           } // Ends if statement.
           // This provides control statements for the Edit button. If the
           //  Edit button is clicked, then the text fields are visible again.
           if(evt.getSource() == edit)
           { // Opens if statement.
             // If the edit button is pressed, the following are set to
             //  visible.
                currentMileage.setVisible(true);
                numofGallonsBought.setVisible(true);
                dateofPurchase.setVisible(true);
                pricePerGallon.setVisible(true);
                gasBrand.setVisible(true);
         }// Closes if statement.
    } // Closes actionPerformed method.
         private class CheckBoxHandler implements ItemListener
         { // Opens inner class
              public void itemStateChanged (ItemEvent e)
              {// Opens the itemStateChanged method.
                   JCheckBox source = (JCheckBox) e.getSource();
                        if(e.getStateChange() == ItemEvent.SELECTED)
                             source.setForeground(Color.blue);
                        else
                             source.setForeground(Color.black);
                        }// Closes the itemStateChanged method
                   }// Closes the CheckBoxHandler class.
    } //Ends the public class collectTextInput classThe error I keep receiving is as follows:
    C:\jdk131\CollectTextInput.java:128: missing method body, or declare abstract
         public void buildImagePanel();
    ^
    C:\jdk131\CollectTextInput.java:142: missing method body, or declare abstract
         public void buildDatumPanel();
    ^
    2 errors
    I have looked this error up in three different places but the solutions do not apply to what I am trying to accomplish.
    Any help would be greatly appreciated!! Thanks!
    Susan

    C:\jdk131\CollectTextInput.java:128: missing methodbody, or declare ?abstract
    public void buildImagePanel();^
    C:\jdk131\CollectTextInput.java:142: missing methodbody, or declare abstract
    public void buildDatumPanel();Just remove the semicolons.
    Geesh! If I had a hammer I would be hitting myself over the head with it right now!!! What an obviously DUMB newbie mistake!!!
    Thanks so much for not making me feel stupid! :-)
    Susan

  • JTextField not gaining focus on initialization of Applet

    I originally tried posting this in the Applets forum but was unable to get a response, so I am re-posting here in hopes of finding an answer.
    I have a simple JApplet with a JFrame, a JTextField added to the JFrame, and a WindowListener added to the JFrame that requests focus to the JTextField whenever the JFrame is activated. Upon opening the applet the WindowListener's windowActivated() method is called and requestFocusInWindow() for the JTextField returns true however the focus is never actually given to the JTextField. According to the API for Component,
    "This method returns a boolean value. If false is returned, the request is guaranteed to fail. If true is returned, the request will succeed unless it is vetoed, or an extraordinary event, such as disposal of the Component's peer, occurs before the request can be granted by the native windowing system. Again, while a return value of true indicates that the request is likely to succeed, developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event"
    I am assuming that the request is getting "vetoed" but I don't understand why or what this even means. If I alt-tab off of the applet window and alt-tab back on then the request is handled properly. This issue only arises on initially opening the applet. Has anyone seen this issue before? Is there a known workaround? Here is the code for my sample applet:
    import javax.swing.*;
    import java.awt.event.*;
    public class MyApplet extends JApplet{
    private JFrame myFrame;
    private JTextField myTextField;
    private FrameWindowListener myListener;
    public void init(){
    myFrame = new JFrame();
    myFrame.setSize(700, 360);
    myFrame.setLocation(100, 100);
    myTextField = new JTextField();
    myFrame.add(myTextField);
    myListener = new FrameWindowListener();
    myFrame.addWindowListener(myListener);
    public void start(){
    myFrame.setVisible(true);
    myFrame.pack();
    public class FrameWindowListener extends WindowAdapter{
    public void windowActivated(WindowEvent e){
    boolean focus = myTextField.requestFocusInWindow();
    if(focus){
    System.out.println("Focus successful");
    } else{
    System.out.println("Focus unsuccessful");
    }

    Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
    http://forum.java.sun.com/help.jspa?sec=formatting
    Works fine for me using JDK1.4.2 on XP using appletviewer.
    The only suggestion I would make is that you should use pack() before setVisible(...). Also I usually have that code in the init() method instead of the start() method.

  • Initialize a bunch of jTextFields

    Hi:
    I have a bunch of jTextFields. I want to be able to clear them in a loop. I could use an array jTextField[x], but I don't have that luxury to make that change. How could I do it ??
    jTextField38.setText("");
    jTextField39.setText("");
    jTextField60.setText("");Thanks for any help

            int count = panel.getComponentCount()-1;
            for( ; count>-1; count--){
                Component component = panel.getComponent(count);
                if( component instanceof JTextField ){
                    ((JTextField)component).setText("");
            }

  • Problem with PropertyChangeListener and JTextField

    I'm having a problem with PropertyChangeListener and JTextField.
    I can not seem to get the propertychange event to fire.
    Anyone have any idea why the code below doesn't work?
    * NewJFrame.java
    * Created on May 15, 2005, 4:21 PM
    import java.beans.*;
    import javax.swing.*;
    * @author wolfgray
    public class NewJFrame extends javax.swing.JFrame
    implements PropertyChangeListener {
    /** Creates new form NewJFrame */
    public NewJFrame() {
    initComponents();
    jTextField1.addPropertyChangeListener( this );
    public void propertyChange(PropertyChangeEvent e) {
    System.out.println(e);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    jTextField1 = new javax.swing.JTextField();
    jScrollPane1 = new javax.swing.JScrollPane();
    jFormattedTextField1 = new javax.swing.JFormattedTextField();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1, java.awt.BorderLayout.NORTH);
    jFormattedTextField1.setText("jFormattedTextField1");
    jScrollPane1.setViewportView(jFormattedTextField1);
    getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    pack();
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new NewJFrame().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    }

    If you want to listen to changes in the textfield's contents you should use a DocumentListener and not a PropertyChangeListener:
    http://java.sun.com/docs/books/tutorial/uiswing/events/documentlistener.html
    And please use [co[/i]de]  tags when you are posting code (press the code button above the message window).

  • Problem in assigning Database Value to jTextfield (form doesn't show up)

    Hi,
    I'm trying to get an integer value from database, add 1 to it and assign it to a jTextfield in formInternalFrameOpened event, but this causes the form not to open.
    If I remove just this thing the rest of the form works fine.
    The open event has no problem it works fine, I have checked with jOptionDialog.
    heres the code
        private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {                                        
    // Get last driver ID, add 1 to it and assign it to driver ID JTextField
            Connection con = null;
            try
                MyDBConnection myDBConnection = new MyDBConnection();
                myDBConnection.init();
                con = myDBConnection.getMyConnection();
                Statement pullStmt = con.createStatement();
                ResultSet pullRs = pullStmt.executeQuery("SELECT key_driverId FROM drivers ORDER BY key_driverId DESC LIMIT 1");
                pullRs.first();
                driverId.setText(String.valueOf(pullRs.getInt("key_driverId")+1));
                pullRs.close();
                con.close();
            catch(SQLException e){}
        }   

    Thanks, here it is.... Remember, I'm trying to insert a value from database into jTextfield in formInternalFrameOpened event.
    * NewDriver.java
    * Created on August 9, 2007, 9:14 AM
    package LimoApp;
    import java.sql.*;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import javax.swing.JOptionPane;
    * @author  NKA
    public class NewDriver extends javax.swing.JInternalFrame {
        /** Creates new form NewDriver */
        public NewDriver() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            driverId = new javax.swing.JTextField();
            firstName = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            lastName = new javax.swing.JTextField();
            jLabel5 = new javax.swing.JLabel();
            address = new javax.swing.JTextField();
            jLabel6 = new javax.swing.JLabel();
            city = new javax.swing.JTextField();
            jLabel7 = new javax.swing.JLabel();
            state = new javax.swing.JComboBox();
            jLabel8 = new javax.swing.JLabel();
            zipcode = new javax.swing.JTextField();
            jLabel9 = new javax.swing.JLabel();
            workPhone = new javax.swing.JTextField();
            jLabel10 = new javax.swing.JLabel();
            extention = new javax.swing.JTextField();
            jLabel11 = new javax.swing.JLabel();
            homePhone = new javax.swing.JTextField();
            jLabel12 = new javax.swing.JLabel();
            mobilePhone = new javax.swing.JTextField();
            jLabel13 = new javax.swing.JLabel();
            dispatchEmail = new javax.swing.JTextField();
            personalEmail = new javax.swing.JTextField();
            jPanel3 = new javax.swing.JPanel();
            licenseNumber = new javax.swing.JTextField();
            jLabel18 = new javax.swing.JLabel();
            socialSecurityNumber = new javax.swing.JTextField();
            jLabel19 = new javax.swing.JLabel();
            dateOfBirth = new javax.swing.JTextField();
            jLabel20 = new javax.swing.JLabel();
            hireDate = new javax.swing.JTextField();
            jLabel21 = new javax.swing.JLabel();
            vehicleAssigned = new javax.swing.JComboBox();
            jLabel22 = new javax.swing.JLabel();
            jPanel4 = new javax.swing.JPanel();
            payWaitingTime = new javax.swing.JCheckBox();
            payExtraStops = new javax.swing.JCheckBox();
            payEarlyLate = new javax.swing.JCheckBox();
            payTolls = new javax.swing.JCheckBox();
            payParking = new javax.swing.JCheckBox();
            payGasSurcharge = new javax.swing.JCheckBox();
            gratuity = new javax.swing.JTextField();
            jLabel14 = new javax.swing.JLabel();
            jLabel15 = new javax.swing.JLabel();
            commission = new javax.swing.JTextField();
            perHourRate = new javax.swing.JTextField();
            perMileRate = new javax.swing.JTextField();
            jLabel16 = new javax.swing.JLabel();
            jLabel17 = new javax.swing.JLabel();
            btNewDriverSave = new javax.swing.JButton();
            setClosable(true);
            setIconifiable(true);
            setTitle("New Driver");
            addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
                public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
                public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                    formInternalFrameOpened(evt);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Driver", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(102, 0, 0)));
            driverId.setEditable(false);
            driverId.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            firstName.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    firstNameFocusLost(evt);
            jLabel1.setText("Dispatch Email");
            jLabel2.setText("Personal Email");
            jLabel3.setText("Driver ID");
            jLabel4.setText("First Name");
            lastName.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    lastNameFocusLost(evt);
            jLabel5.setText("Last Name");
            jLabel6.setText("Address");
            jLabel7.setText("City");
            state.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AL", "VA" }));
            jLabel8.setText("State");
            zipcode.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    zipcodeFocusLost(evt);
            jLabel9.setText("Zipcode");
            workPhone.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    workPhoneFocusLost(evt);
            jLabel10.setText("Work Phone");
            extention.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    extentionFocusLost(evt);
            jLabel11.setText("Extention");
            homePhone.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    homePhoneFocusLost(evt);
            jLabel12.setText("Home Phone");
            mobilePhone.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    mobilePhoneFocusLost(evt);
            jLabel13.setText("Cell");
            dispatchEmail.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    dispatchEmailFocusLost(evt);
            personalEmail.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    personalEmailFocusLost(evt);
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(8, 8, 8)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel12)
                                .addComponent(jLabel10)
                                .addComponent(jLabel4)
                                .addComponent(jLabel3)
                                .addComponent(jLabel6)
                                .addComponent(jLabel7)))
                        .addComponent(jLabel1)
                        .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(firstName, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lastName))
                        .addComponent(address)
                        .addComponent(dispatchEmail)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(workPhone, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(city, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                                .addComponent(homePhone, javax.swing.GroupLayout.Alignment.LEADING))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel8)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(10, 10, 10)
                                            .addComponent(jLabel11)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(extention, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(state, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel9)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(zipcode))))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel13)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(mobilePhone, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addComponent(personalEmail)
                        .addComponent(driverId, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(driverId, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(jLabel5)
                        .addComponent(lastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(firstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel6)
                        .addComponent(address, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(city, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(state, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8)
                        .addComponent(jLabel9)
                        .addComponent(zipcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(workPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10)
                        .addComponent(jLabel11)
                        .addComponent(extention, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel12)
                        .addComponent(jLabel13)
                        .addComponent(mobilePhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(homePhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(dispatchEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(personalEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Documents", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(102, 0, 0)));
            licenseNumber.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    licenseNumberFocusLost(evt);
            jLabel18.setText("License #");
            socialSecurityNumber.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    socialSecurityNumberFocusLost(evt);
            jLabel19.setText("Social Security #");
            dateOfBirth.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    dateOfBirthFocusLost(evt);
            jLabel20.setText("Date of Birth");
            hireDate.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    hireDateFocusLost(evt);
            jLabel21.setText("Hire Date");
            vehicleAssigned.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            jLabel22.setText("Vehicle Assigned");
            javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel18)
                                .addComponent(jLabel19))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(socialSecurityNumber)
                                .addComponent(licenseNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel20)
                                .addComponent(jLabel21))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(hireDate)
                                .addComponent(dateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel22)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(vehicleAssigned, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel18)
                                .addComponent(licenseNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel19)
                                .addComponent(socialSecurityNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel20)
                                .addComponent(dateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(hireDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel21))))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(vehicleAssigned, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel22))
                    .addContainerGap())
            jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Payroll Stettings", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11), new java.awt.Color(102, 0, 0)));
            payWaitingTime.setText("Pay Waiting Time");
            payWaitingTime.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payWaitingTime.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payExtraStops.setText("Pay Extra Stops");
            payExtraStops.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payExtraStops.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payEarlyLate.setText("Pay Early / Late");
            payEarlyLate.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payEarlyLate.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payTolls.setText("Pay Tolls");
            payTolls.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payTolls.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payParking.setText("Pay Parking");
            payParking.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payParking.setMargin(new java.awt.Insets(0, 0, 0, 0));
            payGasSurcharge.setText("Pay Gas Surcharge");
            payGasSurcharge.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
            payGasSurcharge.setMargin(new java.awt.Insets(0, 0, 0, 0));
            gratuity.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            gratuity.setText("0");
            gratuity.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    gratuityFocusLost(evt);
            jLabel14.setText("Gratuity %");
            jLabel15.setText("Commission %");
            commission.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            commission.setText("0");
            commission.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    commissionFocusLost(evt);
            perHourRate.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            perHourRate.setText("0");
            perHourRate.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    perHourRateFocusLost(evt);
            perMileRate.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
            perMileRate.setText("0");
            perMileRate.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    perMileRateFocusLost(evt);
            jLabel16.setText("Per Mile Rate");
            jLabel17.setText("Per Hour Rate");
            javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
            jPanel4.setLayout(jPanel4Layout);
            jPanel4Layout.setHorizontalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addGap(16, 16, 16)
                            .addComponent(jLabel14)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(gratuity, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(9, 9, 9)
                            .addComponent(jLabel16)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(perMileRate, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addComponent(jLabel15)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(commission, 0, 0, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel17)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(perHourRate, 0, 0, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(payWaitingTime)
                                .addComponent(payEarlyLate)
                                .addComponent(payExtraStops))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(payParking)
                                        .addComponent(payTolls))
                                    .addGap(36, 36, 36))
                                .addComponent(payGasSurcharge))))
                    .addContainerGap())
            jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {commission, gratuity, perHourRate, perMileRate});
            jPanel4Layout.setVerticalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(gratuity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(perMileRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(14, 14, 14)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(commission, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

  • JTextField update problem when called from PropertyChangeEvent

    Hi,
    I'm trying to create forms that can be dynamically loaded with Class.forname(formName).
    Those forms should always inherit some methods that make it easy to pass data to
    them and receive data from them. The idea is that the data comes from a table which
    sends a hashmap (String column/JTextField-name + String Value pairs) with firePropertyChanged
    as soon as a new row is seleceted. The JTextFields in the form are marked with setName("FieldName") that has to correspond to the name of the columns of the table.
    My problem is that I can't update the fields in my form when I'm calling getRow(HashMap)
    from within propertyChangeEvent but that's necessary to keep the forms flexible.
    JTextFieldName.setText(newText) just won't work. But it works when I call getRow(HashMap)
    from the constructor. SwingWorker and threads to update the form didn't help.
    I don't need to call pack() / update() / repaint() on the JFrame, do I ??
    update() / validate() / repaint() etc. didn't work on the JTextField themselves.
    Below is the code for one of the test-forms (just a JPanel that is inserted in a frame)
    with all of it's methods. Does anybody have a solution to this problem ??
    Thanks for taking time for that !!
    Benjamin
    * testTable.java
    * Created on 15. April 2004, 16:12
    package viewcontrol.GUI;
    * @author gerbarmb
    import javax.swing.*;
    import java.awt.*;
    import java.beans.*;
    import java.util.*;
    public class testTable extends javax.swing.JPanel
              implements
                   java.awt.event.KeyListener,
                   java.beans.PropertyChangeListener {
          * public static void main(String[] argv) { testTable tt = new testTable();
          * JFrame jf = new JFrame(); jf.setContentPane(tt); jf.setVisible(true); }
         /** Creates new customizer testTable */
         public testTable() {
              initComponents();
              HashMap hm = new HashMap();
               * Only for debugging, to see that the method getRow() works when
               * called from the constructor.
               hm.put("ttext", "TEst");
               this.getRow(hm);
          * 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 FormEditor.
         private void initComponents() {//GEN-BEGIN:initComponents
              java.awt.GridBagConstraints gridBagConstraints;
              jLabel1 = new javax.swing.JLabel();
              textIn = new javax.swing.JTextField();
              jLabel2 = new javax.swing.JLabel();
              intIn = new javax.swing.JTextField();
              jLabel3 = new javax.swing.JLabel();
              numIn = new javax.swing.JTextField();
              jLabel4 = new javax.swing.JLabel();
              dateIn = new javax.swing.JTextField();
              jLabel5 = new javax.swing.JLabel();
              dateTimeIn = new javax.swing.JTextField();
              jLabel6 = new javax.swing.JLabel();
              jCheckBox1 = new javax.swing.JCheckBox();
              keepValues = new javax.swing.JCheckBox();
              jButton1 = new javax.swing.JButton();
              setLayout(new java.awt.GridBagLayout());
              jLabel1.setText("Text");
              add(jLabel1, new java.awt.GridBagConstraints());
              textIn.setName("ttext");
              textIn.setPreferredSize(new java.awt.Dimension(100, 21));
              textIn.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent evt) {
                        textInActionPerformed(evt);
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridwidth = 2;
              add(textIn, gridBagConstraints);
              jLabel2.setText("Integer");
              add(jLabel2, new java.awt.GridBagConstraints());
              intIn.setName("tint");
              intIn.setPreferredSize(new java.awt.Dimension(50, 21));
              add(intIn, new java.awt.GridBagConstraints());
              jLabel3.setText("Number");
              add(jLabel3, new java.awt.GridBagConstraints());
              numIn.setName("tnum");
              numIn.setPreferredSize(new java.awt.Dimension(50, 21));
              add(numIn, new java.awt.GridBagConstraints());
              jLabel4.setText("Date");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 0;
              gridBagConstraints.gridy = 1;
              add(jLabel4, gridBagConstraints);
              dateIn.setName("tdate");
              dateIn.setPreferredSize(new java.awt.Dimension(50, 21));
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 1;
              gridBagConstraints.gridy = 1;
              add(dateIn, gridBagConstraints);
              jLabel5.setText("DateTime");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 2;
              gridBagConstraints.gridy = 1;
              add(jLabel5, gridBagConstraints);
              dateTimeIn.setName("tidate");
              dateTimeIn.setPreferredSize(new java.awt.Dimension(80, 21));
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridy = 1;
              add(dateTimeIn, gridBagConstraints);
              jLabel6.setText("Bit");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridy = 1;
              add(jLabel6, gridBagConstraints);
              jCheckBox1.setName("tbit");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridy = 1;
              add(jCheckBox1, gridBagConstraints);
              keepValues.setText("keep values");
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 7;
              gridBagConstraints.gridy = 3;
              add(keepValues, gridBagConstraints);
              jButton1.setText("Send");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton1ActionPerformed(evt);
              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridx = 7;
              gridBagConstraints.gridy = 2;
              add(jButton1, gridBagConstraints);
         }//GEN-END:initComponents
         private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
              sendRow();
         }//GEN-LAST:event_jButton1ActionPerformed
         private boolean sendRow() {
              java.util.HashMap hm = new java.util.HashMap();
              Component[] cs = this.getComponents();
              for (int i = 0; i < cs.length; i++) {
                   if (((Component) cs).getName() != null) {
                        if (cs[i] instanceof JCheckBox) {
                             String value = ((JCheckBox) cs[i]).isSelected() ? "1" : "0";
                             hm.put(cs[i].getName(), value);
                        } else if (cs[i] instanceof JCheckBox) {
                             hm.put(cs[i].getName(), ((JTextField) cs[i]).getText());
              } // end for
              firePropertyChange("rowChanged", null, hm);
              return true;
         private void getRow(java.util.HashMap hm) {
              //if (! this.keepValues.isSelected()) {
              Component[] cs = this.getComponents();
              for (int i = 0; i < cs.length; i++) {
                   if (cs[i].getName() != null && hm.containsKey(cs[i].getName())) {
                        Component component = cs[i];
                        String componentName = cs[i].getName();
                        String componentValue = (String) hm.get(component.getName());
                        if (cs[i] instanceof JTextField) {
                             // output for debugging
                             System.out.println("Setting " + cs[i].getName() + " = "
                                       + componentValue);
                             ((JTextField) component).setText(componentValue);
                        } else if (cs[i] instanceof JCheckBox) {
                             // output for debugging
                             System.out.println("JCheckBox found");
                             JCheckBox cb = (JCheckBox) component;
                             boolean selected = (componentValue == null ? false : (componentValue.equals("1")
                                       ? true
                                       : false));
                             ((JCheckBox) component).setSelected(selected);
              } // end for
              /* Uncomment this code snippet to retrieve the text that has been set
              for the components (that means JTextFields)
              This is just for debugging !
              Component[] cs = this.getComponents(); for (int i = 0; i < cs.length;
              i++) { if (cs[i].getName() != null) { if (cs[i] instanceof
              JTextField) { System.out.println("Value of " +cs[i].getName() + " = " +
              ((JTextField) cs[i]).getText()); } } } // end for
         private void textInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textInActionPerformed
         }//GEN-LAST:event_textInActionPerformed
         public void keyPressed(java.awt.event.KeyEvent e) {
              if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                   sendRow();
         public void keyReleased(java.awt.event.KeyEvent e) {
         public void keyTyped(java.awt.event.KeyEvent e) {
         public void propertyChange(java.beans.PropertyChangeEvent evt) {
              if (evt.getPropertyName().equals("newRow")) {
                   final PropertyChangeEvent finalEvt = evt;
                   Runnable makeChanges = new Runnable () {
                        public void run() {
                             getRow((java.util.HashMap) finalEvt.getNewValue());
         // Variables declaration - do not modify//GEN-BEGIN:variables
         private javax.swing.JTextField dateIn;
         private javax.swing.JTextField dateTimeIn;
         private javax.swing.JTextField intIn;
         private javax.swing.JButton jButton1;
         private javax.swing.JCheckBox jCheckBox1;
         private javax.swing.JLabel jLabel1;
         private javax.swing.JLabel jLabel2;
         private javax.swing.JLabel jLabel3;
         private javax.swing.JLabel jLabel4;
         private javax.swing.JLabel jLabel5;
         private javax.swing.JLabel jLabel6;
         private javax.swing.JCheckBox keepValues;
         private javax.swing.JTextField numIn;
         private javax.swing.JTextField textIn;
         // End of variables declaration//GEN-END:variables

    The problem of the change in the form not being comitted is that
    I forgot SwingUtilities.invokeLater(makeChanges); in the bottom
    part in public void propertyChange(java.beans.PropertyChangeEvent evt)
    after having created a new Runnable.
    Changes to the UI often have to be comitted by SwingUtitlities.invokeLater()
    though I don't know that much about Swing yet.
    Thanks to everybody who tried to solve that problem.
    Benjamin

  • JTextField Question

    Hey guys,
    I've google'd all over the place and I'm still not getting what I want, hopefully you can help. :)
    I'm trying to use a gui for class assignment to make it a little more flashy. The first thing I'm trying to do before I even start coding is setup a text field at the bottom of my JFrame that by default displays a certain string. I made this original program with command line input read in the directory for files from a directory.txt, since I have a gui I added a JTextField to allow users to change that instead of prompting. So basically, I read the string in from the file and set it to a variable called fileLocation. I then want my program to change the text displayed in that text box to the String fileLocation that is being used in my program. I found some help online that used the .setText command however, I keep getting a NULL error. The fileLocation will print out just fine to the command line so I know the variable has the string inside it set I just can't figure out what I need to setup to allow my text field to display it. Any advice?
    I'm decent with most Java but sadly, this is probably my first real GUI I've tried to setup, so I'm a complete newbie when it comes to Swing.
    I'll paste the code below, most of it is automatically being generated via NetBeans 6.9.1.
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * IRMainForm.java
    * Created on Oct 26, 2010, 8:31:13 PM
    * @author Andrews
    public class IRMainForm extends javax.swing.JFrame {
        /** Creates new form IRMainForm */
        public IRMainForm() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            dirTextBoxLabel = new javax.swing.JLabel();
            libDirectoryField = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
            IRmainMenu = new javax.swing.JMenuBar();
            mainMenuFile = new javax.swing.JMenu();
            fileAbout = new javax.swing.JMenuItem();
            fileExit = new javax.swing.JMenuItem();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Information Retrieval");
            dirTextBoxLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
            dirTextBoxLabel.setText("Document Library:");
            libDirectoryField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    libDirectoryFieldActionPerformed(evt);
            jButton1.setText("jButton1");
            mainMenuFile.setText("File");
            fileAbout.setText("About");
            mainMenuFile.add(fileAbout);
            fileExit.setText("Exit");
            fileExit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    fileExitActionPerformed(evt);
            mainMenuFile.add(fileExit);
            IRmainMenu.add(mainMenuFile);
            setJMenuBar(IRmainMenu);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(dirTextBoxLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(libDirectoryField, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton1))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(344, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1)
                        .addComponent(libDirectoryField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(dirTextBoxLabel)))
            pack();
        }// </editor-fold>
        private void fileExitActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            System.exit(1);
        private void libDirectoryFieldActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new IRMainForm().setVisible(true);
            readDirectory();
        }//end main
        // Variables declaration - do not modify
        private javax.swing.JMenuBar IRmainMenu;
        private javax.swing.JLabel dirTextBoxLabel;
        private javax.swing.JMenuItem fileAbout;
        private javax.swing.JMenuItem fileExit;
        private javax.swing.JButton jButton1;
        protected static javax.swing.JTextField libDirectoryField;
        private javax.swing.JMenu mainMenuFile;
        // End of variables declaration
        static String fileLocation;
        static String indexFile;
        static String permFile;
        static String rankFile;
        static String distFile;
        //static File folder = new File(fileLocation);
        //static File[] listOfFiles = folder.listFiles();
        static ArrayList<String> indexList = new ArrayList<String>();
        static ArrayList<String> permList = new ArrayList<String>();
        static ArrayList<String> rankList = new ArrayList<String>();
        static ArrayList<String> distList = new ArrayList<String>();
        public static void readDirectory(){
            try{
                String thisDir = new File(".").getCanonicalPath();
                BufferedReader br = new BufferedReader( new FileReader(
                    thisDir + "\\data\\directory.txt"));
                fileLocation = br.readLine();
                indexFile = thisDir + "\\data\\index.txt";
                permFile = thisDir + "\\data\\permdex.txt";
                rankFile = thisDir + "\\data\\rankdex.txt";
                distFile = thisDir + "\\data\\distdex.txt";
            }catch(Exception e){e.printStackTrace();};
            libDirectoryField.setText(fileLocation);
        }//end readDirectory
    }//end classThanks,
    Kyle

    Static only because NetBeans complained about it. So I thought maybe it would fix my NullPointerException. I was trying to call that method as soon as the application was started. So I called the method from main. Is there a problem in calling something like this from main while using Swing?
    Basically, I have a directory in a text file. I read that directory and store it to the string fileLocation. Then I want to set the jTextField to have inside it the text of "fileLocation". I know it's executing the readDirectory method and reading in the text and storing it to fileLocation. Now I want to have the jTextField use the fileLocation string as it's text. Could you direct me towards that direction?

  • Array of JPanel and Array of JTextField?

    Hi,
    I try to create array of jpanel and inizialize it in "for" , but when run it give me this error message:
    "Exception in thread "main" java.lang.NullPointerException"
    at the row: "panInsCantante.add(panInsNCC);"
    why?
    (ps. i tried in another code to create array of jtextfield and it give me same error message..)
    here part of code :
          JPanel [] panInsCantante = new JPanel[3];
          for(int i=0;i<=N;i++){
               JPanel panInsNCC= new JPanel();
               panInsNCC.setLayout( new GridLayout(3,1) );
               panInsNCC.add(campoTesto1);
               panInsNCC.add(campoTesto2);
               panInsNCC.add(campoTesto3);
               //panInsCantante[i] = new JPanel();
               //panInsCantante.setLayout( new GridLayout(1,1) );
         panInsCantante[i].add(panInsNCC);

    a question (theoric...)A VERY important question I may add.
    what's the difference between ..
    this instance :
    JPanel [] panInsCantante = new
    JPanel[3];This declares and initializes the array itself, nothing more. No JPanels have been initialized as yet, just the array. It's as if you have now built the shelves to hold the books, but you have no books up there yet...
    and this instance of panInsCantante? :
    panInsCantante[i] = new JPanel();and this initializes each JPanel in the array as you loop through the array. .... and now you have filled the shelves with the books and can use the books.
    You will need them both.
    In all likelihood, the reason for your confusion is that all of your previous arrays were arrays of primative types: int, double, float, and char. In this situation, you don't need to go through the step of initializing the variable.
    But now you are faced for the first time with an array of reference type, an array of Objects. This is a different situation and requires the steps that we have gone through.
    Message was edited by:
    petes1234

  • Read System.in from JTextField

    hi all, I have found this code that redirect System.in and System.out on JTextArea:
    package xyzGui;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class resGui extends javax.swing.JFrame {
        PipedInputStream piOut;
        PipedInputStream piErr;
        PipedOutputStream poOut;
        PipedOutputStream poErr;
        /** Creates new form resGui */
        public resGui() {
            initComponents();
            try {
                // Set up System.out
                piOut = new PipedInputStream();
                poOut = new PipedOutputStream(piOut);
                System.setOut(new PrintStream(poOut, true));
                // Set up System.err
                piErr = new PipedInputStream();
                poErr = new PipedOutputStream(piErr);
                System.setErr(new PrintStream(poErr, true));
                // Create reader threads
                new ReaderThread(piOut).start();
                new ReaderThread(piErr).start();
            catch(Exception e) {
                System.exit(0);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            jScrollPane1 = new javax.swing.JScrollPane();
            consoleArea = new javax.swing.JTextArea();
            commandLine = new javax.swing.JTextField();
            getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
            setResizable(false);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            jScrollPane1.setViewportView(consoleArea);
            getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 610, 200));
            commandLine.addKeyListener(new java.awt.event.KeyAdapter() {
                public void keyPressed(java.awt.event.KeyEvent evt) {
                    commandLineKeyPressed(evt);
            getContentPane().add(commandLine, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 40, 610, -1));
            pack();
        private void commandLineKeyPressed(java.awt.event.KeyEvent evt) {
            if(evt.getKeyCode()==10) {
                String val = commandLine.getText();
                if(val.equals("exit")) {
                    System.exit(0);
                commandLine.setText("");
                consoleArea.append(val+"\n");
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        // Variables declaration - do not modify
        private javax.swing.JTextField commandLine;
        private javax.swing.JTextArea consoleArea;
        private javax.swing.JScrollPane jScrollPane1;
        // End of variables declaration
        class ReaderThread extends Thread
            PipedInputStream pi;
            ReaderThread(PipedInputStream pi)
                this.pi = pi;
            public void run()
                final byte[] buf = new byte[1024];
                try
                    while (true)
                        final int len = pi.read(buf);
                        if (len == -1)
                            break;
                        SwingUtilities.invokeLater(new Runnable()
                            public void run()
                                consoleArea.append(new String(buf, 0, len));                           
                                // Make sure the last line is always visible
                                consoleArea.setCaretPosition(consoleArea.getDocument().getLength());
                catch (IOException e)
    }...I would like, if possible read System.in from JTextField and not from JTextArea:
    Input from text box and output to text area.
    Thanks

    It doesen't work. I would like to create a GUI for a command line application. I would like to send command to my "command line" application using textfield in GUI and not using console. In my sample System.out is redirected on JTextArea I try to redirect JTextFiled value on System.in...

  • JTextField not displaying correctly

    I have a JPanel done using Swing. I have JTextFields on the panel. I am having a problem with the text fields doing all of the following:
    1. erasing the text that was populated into the fields when you click on them to edit
    2. erasing the first character of the text that was populated into the fields when you click on them to edit
    3. not allowing you to edit, but only retype text into the field
    4. completely erasing all of the fields that were populated when you open the panel
    5. erasing all of the fields that were populated when you click on one field to edit
    These seem to be happening randomly, without any pattern.
    The code that we use in the panel, before the Form Editor code, is below. There is a file in the database folder named FormBinder. This file binds objects on the Java forms with the Access database. The FormBinder contains information about the database. It allows the programmer that is creating the form to bind all Java Swing objects to fields in the database. If we need to display a Student�s name in a text box on one of our forms we simply call the bind method in the FormBinder. The bind method accepts the name of the text box and a 6 digit number. This 6 digit number is contained in the database XML document. It represents a specific field in the database. Once this text field is bound to the corresponding field in the database, the displayData method in the FormBinder class actually inserts the value from the database into the text field.
    * StudentGeneralJPanel.java
    * Created on April 12, 2002, 10:00 AM
    package com.asisoftware.placewiz.student;
    import com.asisoftware.database.*;
    import java.awt.Component;
    import java.util.*;
    * @author Chris
    public class StudentGeneralJPanel extends javax.swing.JPanel {
    private FormBinder binder;
    /** Creates new form StudentGeneralJPanel */
    public StudentGeneralJPanel( FormBinder binder ) {
    System.out.println( "constructing" );
    initComponents();
    this.binder = binder;
    //reset binder
    binder.clearBindings();
    //bind text fields
    binder.bind(DisplayNameText, 560022 );
    binder.bind(GreetingText, 560023 );
    binder.bind(FirstText, 560021 );
    binder.bind(MiddleText, 560030 );
    binder.bind(LastText, 560028 );
    binder.bind(AltSurnmText, 560004 );
    binder.bind(StudentNumText, 560033 );
    binder.bind(SSNText, 560040 );
    binder.bind(SystemIDText, 560025 );
    binder.bind(EmailText, 560017 );
    binder.bind(homePhoneJPanel, 560024 );
    binder.bind(altPhoneJPanel, 560003 );
    binder.bind(ResumeCheckBox, 800005 );
    binder.bind(supervisorsEmailText, 800025 );
    binder.bind( (Component)addressJPanel.getLine1Component(), 560001 );
    binder.bind( (Component)addressJPanel.getLine2Component(), 560002 );
    binder.bind( (Component)addressJPanel.getCityComponent(), 560008 );
    binder.bind( (Component)addressJPanel.getStateComponent(), 560041 );
    binder.bind( (Component)addressJPanel.getZipComponent(), 560052 );
    // add the Join to the binder to join tables
    int leftIdentifier = 560025;
    Field left = new Field("", leftIdentifier);
    int rightIdentifier = 800020;
    Field right = new Field("", rightIdentifier);
    Join join = new Join(left, right);
    binder.addJoin( join );
    //populate form
    binder.refreshData();
    //show data on the form
    binder.displayData();
    this.revalidate();
    this.repaint();
    /** 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.
    I THINK THAT WE ARE DOING SOMETHING WRONG WITH THE refreshData(), displayData(), and repaint() FUNCTIONS. HELP, SUGGESTIONS? ANYONE HAVE THE SAME PROBLEM?

    Sounds like FormBinder is your problem. It looks like it manipulates the text fields that are placed in the form and that results in the quirky behavior. I could be wrong. If you are using focus listeners in your text fields that could be the problem but it sounds like that is not what is happening.

  • JTabbedPane with JTextField

    Can anyone provide me with an example on how to incorporate a JTextField into a JTabbedPane? There are many examples of creating JButtons as components of a JTabbedPanes but nothing for JTextFields. Can this be done? I get some wierd compiler errors when I try it?
    Any help will be much appreciated. Thanks.

    Thanks for the quick response but...
    My question was "how to incorporate these fields into a JTabbedPane."
    I'm new to Java so I have "borrowed" a Sun Tutorial JTabbedPane example which includes one JLable component per tab and tried to add a JTextField.
    Here is "my" code.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TabbedPaneDemo extends JFrame {
    // Initialize Screen Text Fields
    private JTextField lastName = null;
    //Vector recordData = new Vector(20);
    public TabbedPaneDemo() {
    ImageIcon icon = new ImageIcon("images/middle.gif");
    JTabbedPane tabbedPane = new JTabbedPane();
    Component panel1 = makeRecordPanel("Teacher Record");
    tabbedPane.addTab("Teacher", icon, panel1, "Update Teacher Information");
    tabbedPane.setSelectedIndex(0);
    Component panel2 = makeRecordPanel("Parent Record");
    tabbedPane.addTab("Parent", icon, panel2, "Update Parent Information");
    Component panel3 = makeRecordPanel("Child Record");
    tabbedPane.addTab("Child", icon, panel3, "Update Child Information");
    //Add the tabbed pane to this panel.
    setLayout(new GridLayout(1, 1));
    add(tabbedPane);
    protected Component makeRecordPanel(String text) {
    JPanel panel = new JPanel(false);
    JLabel label1 = new JLabel("Last Name");
    JTextField lastName = new JTextField(20);
    label1.setHorizontalAlignment(JLabel.LEFT);
    panel.setLayout(new GridLayout(1, 1));
    panel.add(label1);
    panel.add(lastName);
    return panel;
    public static void main(String[] args) {
    JFrame frame = new JFrame("Maintain DayCare Records");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    frame.getContentPane().add(new TabbedPaneDemo(),
    BorderLayout.CENTER);
    frame.setSize(800, 600);
    frame.setVisible(true);
    This compiles OK but when I try to run it I get the following run-time errors.
    java.lang.Error: Do not use TabbedPaneDemo.setLayout() use TabbedPaneDemo.getContentPane().setLayout() instead
         at javax.swing.JFrame.createRootPaneException(JFrame.java:333)
         at javax.swing.JFrame.setLayout(JFrame.java:394)
         at TabbedPaneDemo.<init>(TabbedPaneDemo.java:29)
         at TabbedPaneDemo.main(TabbedPaneDemo.java:53)
    Any thoughts?

  • Using JTextField as an array.

    Hi I would like some help with createing a JTextField array. I cant seem to find anything wrong with my code but it keeps giving me an Error.
    Error Message: java.lang.ArrayIndexOutOfBoundsException
    This is what my code looks like.
    //Declare Component
    JTextField Length[];
    for(int i = 0; i < 5; i++)
    Length[i] = new JTextField("", 5);
    c.gridx = i;
    c.gridy = 0;
    panMiddle.add(Length, c);
    Please let me know what im doing wrong.

    You seem to have several things in error. Here is one way to do this. It creates an array of 4 JTextFields. A frequent beginner's mistake is to initialize the array but to forget to initialize the individual items, something that must be done if the items are objects (i.e., are not primative types such as int).
    public class MyClass extends JPanel
        private JTextField[] textFieldArray = new JTextField[4]; //array declared and initialized
        public MyClass()
            for (int i = 0; i < textFieldArray.length; i++)
                textFieldArray[i] = new JTextField(12); //init each array item here
                panMiddle.add(textFieldArray); // add it to my form here.
    Message was edited by:
    petes1234

  • Validating JTextfield in an Applet

    I am doing a simple assignment for a Java class I am taking. The assignment consists of doing the Tower of Hanoi with just symbols showing the moves of the disks. I have been successful in writing the recursive statement and init() but I am having trouble validating the JTextfield in the applet. I want to validate the entry is only between 1 and 9. Nothing else and no letters. Here is my code at the present time. If anyone could help I would appreciate it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class HWProblem6_37Hanoi extends JApplet implements ActionListener
    /** Initialization method that will be called after the applet is loaded
    into the browser.*/
    JLabel directions;
    JTextField userInput;
    //attach JTextArea to a JScrollPane so user can scroll results
    JTextArea outputArea = new JTextArea(10, 30);
    //Set up applet's GUI
    public void init()
    //obtain content pane and set its layout to FlowLayout
    Container container=getContentPane();
    container.setLayout( new FlowLayout() );
    JScrollPane scroller = new JScrollPane(outputArea);
    //create directions label and attach it to content pane
    directions = new JLabel("Enter a Integer Between 1 and 9: ");
    container.add( directions );
    //create numberField and attach it to content pane
    userInput = new JTextField(10);
    container.add( userInput );
    //register this applet as userInput ActionListener
    userInput.addActionListener( this );
    container.add (scroller);
    public void actionPerformed(ActionEvent event)
    //Initialize variables
    int number = 0;
    while (number == 0)
    number = Integer.parseInt(userInput.getText());
    if ((number<1) || (number >9))
    userInput.setText(" ");
    number =0;
    showStatus("Error: Invalid Input");
    else
    showStatus("Valid Input");
    tower(number,1,2,3);
    public void tower(int n, int needle1/*source*/, int needle2/*destination*/, int needle3/*free space*/)
    if (n >0)
    tower(n-1, needle1, needle3, needle2);
    outputArea.append(needle1 + " -> " + needle3 + "\n");
    tower(n-1, needle2, needle1, needle3);
    }

    How to Use Formatted Text Fields
    http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html

  • JEditorPane Initialization problem

    Hi All,
    I am getting the following error if i am trying to initialize JEditorPane as below,
    JEditorPane j_msgPanel=new JEditorPane("file:\\\\C:\\msgCreator\\blank.html");
    java.net.ConnectException: Operation timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.NetworkClient.openServer(Unknown Source)
    at sun.net.ftp.FtpClient.openServer(Unknown Source)
    at sun.net.ftp.FtpClient.<init>(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Sour
    ce)
    at javax.swing.JEditorPane.getStream(Unknown Source)
    at javax.swing.JEditorPane.setPage(Unknown Source)
    at javax.swing.JEditorPane.<init>(Unknown Source)
    at adx.msg.TabbedMsgCreator.jbInit(TabbedMsgCreator.java:104)
    at adx.msg.TabbedMsgCreator.<init>(TabbedMsgCreator.java:89)
    at adx.msg.Login.submitClicked(Login.java:167)
    at adx.msg.Login.access$000(Login.java:18)
    at adx.msg.Login$2.actionPerformed(Login.java:77)
    at javax.swing.JTextField.fireActionPerformed(Unknown Source)
    at javax.swing.JTextField.postActionEvent(Unknown Source)
    at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
    at javax.swing.SwingUtilities.notifyAction(Unknown Source)
    at javax.swing.JComponent.processKeyBinding(Unknown Source)
    at javax.swing.JComponent.processKeyBindings(Unknown Source)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processKeyEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    For more information, i am using
    java version "1.3.1"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
    Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
    I have no idea why it is going for ftp connection :( when the file referenced is a local file.
    Thanks in Advance.

    Sorry i forgot to add that this works fine with jdk 1.4.1 version

Maybe you are looking for

  • Pre Database Insert / Update Validation

    Hi, I have a maintenance view that allow user to insert / update. Let's say, z_my_table is my table key1 key2 field1 field2 field3 I want to validate whether field1, field2, field3 whether exist in my table before insert / update. However, due to som

  • Ipod shows up in "My Computer" while syncing then disappears when done

    My Ipod has always done this and I have yet to figure out how to fix it. When I plug it into my computer, it shows up on "My Computer" while it updates on Itunes. As soon as it's done updating it disappears like it is not even there. It still shows u

  • Weblogic Server training

    Could anyone point me in the direction some good self-training resources (books, CBT's, etc.) for Weblogic Server - preferably 8.1? We're getting our feet wet with a third-party app that incorporates Weblogic Server 8.1, but we have no experience wit

  • Issues with Signing into a website on Firefox

    When trying to sign into some websites, Example http://syn-gaming.us, I log in correctly then the next page I go to I am instantly logged out. Help please!

  • Problem synching iPhoto library with iPhone

    I was using OS X Lion synching my iPhoto library with my iPhone 3GS with IOS 4 and everything was working perfect. When I updated to IOS 5 start the problem, because doesn't sync all the photos. It's leaving around 100 photos without synchronization.