GridBagLayout() hell

Hello,
I have almost completed the GUI for my RAT client although there are layout problems i.e. some elements are not where they should be.
This is what the layout should be like:
/ label / /
/textField / JEditorPane /
/ textField / /
/textField / /
Obviously there are more labels and textFields as shown in the code below. I have tried to edit the properties for each label, textField etc, I have also tried to relate it to the tutorials on Java swing but with no luck. Please help.
import java.net.*;
import javax.swing.text.html.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.applet.Applet;
* Requires RatServer to be running
* set path="C:\Program Files\Java\jdk1.5.0_08\bin"
public class RatClient implements ActionListener
     JTextField host = null;
     JTextField port = null;
     JTextField cmd = null;
     JTextField file = null;
     JEditorPane jep = null;
     BufferedReader in = null;
     JScrollPane scroll = null;
     public Component createComponents()
          JPanel pane = new JPanel(new GridBagLayout());
          GridBagConstraints c = new GridBagConstraints();
          c.fill = GridBagConstraints.HORIZONTAL;
          jep = new JEditorPane();
          c.gridx = 2;
          c.gridy = 0;
          c.ipadx = 40;
          c.ipady = 40;
          c.weightx = 0.0;
          c.gridwidth = 3;
          c.gridheight = -14;
        pane.add(jep, c);
          scroll = new JScrollPane(jep);
          c.gridx = 2;
          c.gridy = 0;
          c.ipadx = 40;
          c.ipady = 40;
          c.weightx = 0.0;
          c.gridwidth = 3;
          pane.add(scroll, c);
          JLabel hostLabel = new JLabel("Enter host: ");
          c.ipadx = 10;
          c.ipady = 10;
          c.gridx = 0;
          c.gridy = 0;
          pane.add(hostLabel, c);
          host = new JTextField("192.168.0.4");
          c.gridx = 0;
          c.gridy = 1;
          pane.add(host, c);
          JLabel portLabel = new JLabel("Enter port: ");
          c.gridx = 0;
          c.gridy = 2;
          pane.add(portLabel, c);
          port = new JTextField("80");
          c.gridx = 0;
          c.gridy = 3;
          pane.add(port, c);
          JLabel cmdLabel = new JLabel("Send a command: ");
          c.gridx = 0;
          c.gridy = 4;
          pane.add(cmdLabel, c);
          cmd = new JTextField("GetInfo");
          c.gridx = 0;
          c.gridy = 5;
          pane.add(cmd, c);
          JLabel fileLabel = new JLabel("Send a file: ");
          c.gridx = 0;
          c.gridy = 6;
          pane.add(fileLabel, c);
          file = new JTextField("C:\\misc.txt");
          c.gridx = 0;
          c.gridy = 7;
          pane.add(file, c);
          JButton button = new JButton("Connect");
          c.gridx = 0;
          c.gridy = 8;
          button.addActionListener(this);
        pane.add(button, c);
        return pane;
private static void Gui()
          //Create and set up the window.
          JFrame frame = new JFrame("RatClient");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          RatClient app = new RatClient();
          Component contents = app.createComponents();
          frame.getContentPane().add(contents);
          //Display the window.
          frame.pack();
          frame.setVisible(true);
    }

Ok heres an SSCCE that shows the incorrect layout.
Ive tried using another panel also but to no avail.
At the moment its not showing the JEditorPane at all.
Please help again.
Cheers
import java.net.*;
import javax.swing.text.html.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.applet.Applet;
* Requires RatServer to be running
* set path="C:\Program Files\Java\jdk1.5.0_08\bin"
public class RatClient2 implements ActionListener
     JTextField host = null;
     JTextField port = null;
     JTextField cmd = null;
     JTextField file = null;
     JEditorPane jep = null;
     BufferedReader in = null;
     JScrollPane scroll = null;
     public Component createComponents()
          JPanel paneForJep = new JPanel(new GridBagLayout());
          GridBagConstraints gbc = new GridBagConstraints();
          jep = new JEditorPane();
          gbc.gridx = 2;
          gbc.gridy = 0;
          gbc.ipadx = 40;
          gbc.ipady = 40;
        paneForJep.add(jep, gbc);
          scroll = new JScrollPane(jep);
          gbc.gridx = 2;
          gbc.gridy = 0;
          gbc.ipadx = 40;
          gbc.ipady = 40;
          paneForJep.add(scroll, gbc);
          JPanel pane = new JPanel(new GridBagLayout());
          GridBagConstraints c = new GridBagConstraints();
          c.fill = GridBagConstraints.HORIZONTAL;
          JLabel hostLabel = new JLabel("Enter host: ");
          c.ipadx = 10;
          c.ipady = 10;
          c.gridx = 0;
          c.gridy = 0;
          pane.add(hostLabel, c);
          host = new JTextField("192.168.0.4");
          c.gridx = 0;
          c.gridy = 1;
          pane.add(host, c);
          JLabel portLabel = new JLabel("Enter port: ");
          c.gridx = 0;
          c.gridy = 2;
          pane.add(portLabel, c);
          port = new JTextField("80");
          c.gridx = 0;
          c.gridy = 3;
          pane.add(port, c);
          JLabel cmdLabel = new JLabel("Send a command: ");
          c.gridx = 0;
          c.gridy = 4;
          pane.add(cmdLabel, c);
          cmd = new JTextField("GetInfo");
          c.gridx = 0;
          c.gridy = 5;
          pane.add(cmd, c);
          JLabel fileLabel = new JLabel("Send a file: ");
          c.gridx = 0;
          c.gridy = 6;
          pane.add(fileLabel, c);
          file = new JTextField("C:\\a.jpg");
          c.gridx = 0;
          c.gridy = 7;
          pane.add(file, c);
          JButton button = new JButton("Connect");
          c.gridx = 0;
          c.gridy = 8;
          button.addActionListener(this);
        pane.add(button, c);
        return pane;
    public void actionPerformed(ActionEvent e)
          String host2 = host.getText();
          String port2 = port.getText();
          String command = cmd.getText();
          String file2 = file.getText();
     private static void Gui()
          //Create and set up the window.
          JFrame frame = new JFrame("RatClient2");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          RatClient2 app = new RatClient2();
          Component contents = app.createComponents();
          frame.getContentPane().add(contents);
          //Display the window.
          frame.pack();
          frame.setVisible(true);
     public static void main(String[] args)
               javax.swing.SwingUtilities.invokeLater(new Runnable()
                    public void run()
                         Gui();
     }I hope this is okay i.e. I have tried my best to conform to the forum rules.

Similar Messages

  • IPhone 5S pre-order HELL!!

    Verizon iPhone 5S PRE-ORDER HELL!! - They screwed up and dragged my situation out for 9 days!!  At the end of it all I'm still missing an iPhone 5S.  9/20 @ midnight I ordered TWO iPhone 5S 16GB silver and received a order confirmation for BOTH phones and a confirmed ship by date of 9/24.  NO notification of anything went wrong.  9/22 - I get a shipping notification from Verizon but only one mobile # is listed.  I call Customer Care and rep just quickly and casually confirms that two phones shipped.  9/23 - I get an email saying they couldn't fulfill my order completely and that the remaining order will ship 9/30.  I call Customer Care again to inquire about this and he the rep went out of his way (great guy) to confirm that two phones have shipped and that I have nothing to worry about.  Said the message was generic and was mistakenly sent out.  9/25 - I receive package and find only ONE iphone!!  I called Customer Care again and this time Adam helped me.  After looking through things, he comes back saying he thinks the iPhone was taken out of the box before shipment, stolen!!!  Had me send him all this information and said the Verizon investigation team is on it to "look" for the iphone. I asked if he could put a new order in and just exchange it for the "misplaced" iPhone.  He said it was not necessary because he believes there is a iphone somewhere.  9/27- Adam leaves me a voice mail saying that it was all a misunderstanding and my iphone should ship 9/30 and he'll be on it.  9/29 - I help my wife activate her iPhone because she tried until 3am the night before with no help.  While I'm on with Customer Care again she, Ida, asks how's my phone service in which I explain to her everything.   She looks into it and says she sees no record of any order or tracking for an iPhone.  Further says the reason one iPhone was placed on hold because a discount was applied to two devices and it could only be used for one.  I told her that I've never been notified by Verizon that something went wrong until today.  And this is after calling Customer Care numerous times.  And NOW I find this out.  She says she's going to look into it as there might be a small chance that there is an iPhone for me.  She said she'll call back by 5pm and txted me her email address.   6:00pm comes and no callback.  It also turns out the email address is bogus.  I call Customer Care again and get another rep who looks into it and does a whole bunch more investigation.  Finally she says there never was an order for my iphone and there will be no iphone shipping tomorrow.  My only choice is to place a new order and I won't get it until 10/14!!!  SERIOUSLY!!! ARGGGGGHHHHHHGGHGHHGG!!! Expletives galore!!!  Talked to the manager Brandon and asked if they can do something for me to compensate me for all this crap I went through.  I've been with Verizon for like 15 years.  He kept on saying "I understand ..blah..blah.. BUT there's nothing we can do" over and over again.  So I said Verizon made a mistake, detected this mistake but didn't notify the customer of this mistake, Customer Care couldn't figure it out until today, and that I'm out of luck?  Does he REALLY understand?  If I had known all this I could have walked to a store on 9/20 and gotten a iphone.  Pre-ordering was suppose to be a convenience provided, right? And I waited because I was led to believe that some iPhone existed..  dragged along for a ride only to find out there was no iphone.   And after all this, I get nothing but "I understand....  But there's nothing we can do..."  So yes people Verizon stinks!!! They do not hold themselves accountable for their mistakes and expects the customer to just take it.   I'll have to admit that not all customer service reps are bad (Ty, Adam, and the very last girl who helped me you guys were awesome!!  Ida you could have made this list until you decided not to call me back and gave me a bogus email).  Customer Care is a mixed bag and have not real authority to help you.  Verizon is about to lose yet another loyal customer and his family soon.  There should be some class action lawsuit for all the iphone 5s issues.  Promises/Contracts made but Verizon completely failed to keep.  They just jerk us along for a ride, dangling that ship date that keeps moving around.
    >> Edited to comply with the Verizon Wireless Terms of Service <<
    Message was edited by: Verizon Moderator

    "Customer Care is a mixed bag and have not real authority to help you." I worked for Verizon before it was Verizon, for several years. I think that you are entirely correct in your assessment of customer care. Reps really can't do much at all. I believe that the key function of reps is 1. hand holding and 2. punching bag. The goal is to get the customer believe that they actually DID something, and got some result! After all the talking, the customer starts to believe that something actually happened to resolved the situation. At least they spoke to SOMEONE! Picture this: the rep is on the computer, wearing a headset, and the calls are coming at them non-stop, and you have 3 minutes to convince this person that you actually helped them! But in the end, as you said, nothing happened!  It is the sad truth of cs.
    I am curious to see if the Moderator leaves this post on the board.

  • GridBagLayout and Panel Border problem

    I have 3 panels like
    A
    B
    C
    and the C panel has a Mouse Listener that on a mouseEntered creates a border around the same panel and on a mouseExited clears that border.
    When this border is created the A and B panels go up a little bit .. they move alone when the border is created.
    Is there any way to fix this problem? Is there any way to get the panels static?
    the code is close to the following:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    import javax.swing.border.TitledBorder;
    import java.awt.event.*;
    import java.text.NumberFormat;
    public class Game extends JFrame implements MouseListener
    JPanel game, options, top, down, middle;
    NumberFormat nf;
    public Game() {
    super("Game");
    nf = NumberFormat.getPercentInstance();
    nf.setMaximumFractionDigits(1);
    JPanel center = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = gbc.BOTH;
    gbc.weighty = 1.0;
    gbc.weightx = 0.8;
    center.add(getGamePanel(), gbc);
    gbc.weightx = 0.104;
    center.add(getOptionsPanel(), gbc);
    Container cp = getContentPane();
    // use the JFrame default BorderLayout
    cp.add(center); // default center section
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setSize(700,600);
    // this.setResizable(false);
    setLocationRelativeTo(null);
    setVisible(true);
    addComponentListener(new ComponentAdapter()
    public void componentResized(ComponentEvent e)
    showSizeInfo();
    showSizeInfo();
    private void showSizeInfo()
    Dimension d = getContentPane().getSize();
    double totalWidth = game.getWidth() + options.getWidth();
    double gamePercent = game.getWidth() / totalWidth;
    double optionsPercent = options.getWidth() / totalWidth;
    double totalHeight = top.getHeight() + middle.getHeight() + down.getHeight();
    double topPercent = top.getHeight() / totalHeight;
    double middlePercent = middle.getHeight() / totalHeight;
    double downPercent = down.getHeight() / totalHeight;
    System.out.println("content size = " + d.width + ", " + d.height + "\n" +
    "game width = " + nf.format(gamePercent) + "\n" +
    "options width = " + nf.format(optionsPercent) + "\n" +
    "top height = " + nf.format(topPercent) + "\n" +
    "middle height = " + nf.format(middlePercent) + "\n" +
    "down height = " + nf.format(downPercent) + "\n");
    private JPanel getGamePanel()
    // init components
    top = new JPanel(new BorderLayout());
    top.setBackground(Color.red);
    top.add(new JLabel("top panel", JLabel.CENTER));
    middle = new JPanel(new BorderLayout());
    middle.setBackground(Color.green.darker());
    middle.add(new JLabel("middle panel", JLabel.CENTER));
    down = new JPanel(new BorderLayout());
    down.setBackground(Color.blue);
    down.add(new JLabel("down panel", JLabel.CENTER));
    // layout game panel
    game = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.fill = gbc.BOTH;
    gbc.gridwidth = gbc.REMAINDER;
    gbc.weighty = 0.2;
    game.add(top, gbc);
    gbc.weighty = 0.425;
    game.add(middle, gbc);
    gbc.weighty = 0.2;
    game.add(down, gbc);
    down.addMouseListener(this);
    return game;
    private JPanel getOptionsPanel()
    options = new JPanel(new BorderLayout());
    options.setBackground(Color.pink);
    options.add(new JLabel("options panel", JLabel.CENTER));
    return options;
    // mouse listener events
         public void mouseClicked( MouseEvent e ) {
    System.out.println("pressed");
         public void mousePressed( MouseEvent e ) {
         public void mouseReleased( MouseEvent e ) {
         public void mouseEntered( MouseEvent e ) {
    Border redline = BorderFactory.createLineBorder(Color.red);
    JPanel x = (JPanel) e.getSource();
    x.setBorder(redline);
         public void mouseExited( MouseEvent e ){
    JPanel x = (JPanel) e.getSource();
    x.setBorder(null);
    public static void main(String[] args ) {
    Game exe = new Game();
    exe.show();
    }

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.*;
    import java.text.NumberFormat;
    public class Game extends JFrame implements MouseListener{
      JPanel game, options, top, down, middle;
      NumberFormat nf;
      public Game() {
        super("Game");
        nf = NumberFormat.getPercentInstance();
        nf.setMaximumFractionDigits(1);
        JPanel center = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = gbc.BOTH;
        gbc.weighty = 1.0;
        gbc.weightx = 0.8;
        center.add(getGamePanel(), gbc);
        gbc.weightx = 0.104;
        center.add(getOptionsPanel(), gbc);
        Container cp = getContentPane();
        // use the JFrame default BorderLayout
        cp.add(center); // default center section
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setSize(700,600);
        // this.setResizable(false);
        setLocationRelativeTo(null);
        setVisible(true);
        addComponentListener(new ComponentAdapter(){
            public void componentResized(ComponentEvent e){
            showSizeInfo();
        showSizeInfo();
      private void showSizeInfo(){
        Dimension d = getContentPane().getSize();
        double totalWidth = game.getWidth() + options.getWidth();
        double gamePercent = game.getWidth() / totalWidth;
        double optionsPercent = options.getWidth() / totalWidth;
        double totalHeight = top.getHeight() + middle.getHeight() + down.getHeight();
        double topPercent = top.getHeight() / totalHeight;
        double middlePercent = middle.getHeight() / totalHeight;
        double downPercent = down.getHeight() / totalHeight;
        System.out.println("content size = " + d.width + ", " + d.height + "\n" +
            "game width = " + nf.format(gamePercent) + "\n" +
            "options width = " + nf.format(optionsPercent) + "\n" +
            "top height = " + nf.format(topPercent) + "\n" +
            "middle height = " + nf.format(middlePercent) + "\n" +
            "down height = " + nf.format(downPercent) + "\n");
      private JPanel getGamePanel(){
        // init components
        top = new JPanel(new BorderLayout());
        top.setBackground(Color.red);
        top.add(new JLabel("top panel", JLabel.CENTER));
        middle = new JPanel(new BorderLayout());
        middle.setBackground(Color.green.darker());
        middle.add(new JLabel("middle panel", JLabel.CENTER));
        down = new JPanel(new BorderLayout());
        down.setBackground(Color.blue);
        down.add(new JLabel("down panel", JLabel.CENTER));
        // layout game panel
        game = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.fill = gbc.BOTH;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.weighty = 0.2;
        game.add(top, gbc);
        gbc.weighty = 0.425;
        game.add(middle, gbc);
        gbc.weighty = 0.2;
        game.add(down, gbc);
        down.addMouseListener(this);
        return game;
      private JPanel getOptionsPanel(){
        options = new JPanel(new BorderLayout());
        options.setBackground(Color.pink);
        options.add(new JLabel("options panel", JLabel.CENTER));
        return options;
      public void mouseClicked( MouseEvent e ) {
        System.out.println("pressed");
      public void mousePressed( MouseEvent e ) {
      public void mouseReleased( MouseEvent e ) {
      public void mouseEntered( MouseEvent e ) {
        Border redline = new CalmLineBorder(Color.red);
        JPanel x = (JPanel) e.getSource();
        x.setBorder(redline);
      public void mouseExited( MouseEvent e ){
        JPanel x = (JPanel) e.getSource();
        x.setBorder(null);
      public static void main(String[] args ) {
        Game exe = new Game();
        exe.setVisible(true);
    class CalmLineBorder extends LineBorder{
      public CalmLineBorder(Color c){
        super(c);
      public CalmLineBorder(Color c, int thick){
        super(c, thick);
      public CalmLineBorder(Color c, int thick, boolean round){
        super(c, thick, round);
      public Insets getBorderInsets(Component comp){
        return new Insets(0, 0, 0, 0);
    }

  • GridBagLayout Problem

    I have a jframe in which i want to display 2 jpanels (panelA, panelB).
    The arrangement for panelA is at cell (1,1) and for panelB at cell(1,3)
    cell(0,0) upper-left
    Here is my code:
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints constr = new GridBagConstraints();
    mainFrame = new JFrame("MAIN-FRAME");
    mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
    aDesktopPane = new JDesktopPane();
    aDesktopPane.setBackground(Color.LIGHT_GRAY);
    aDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    mainFrame.setContentPane(aDesktopPane);
    mainFrame.getContentPane().setLayout(gridBag);
    BuildConstraints(constr,0,1,1,1,30,0);
    constr.fill=GridBagConstraints.BOTH;
    constr.insets = createFeatures.Inset(3,3,3,3);
    JPanel justForLayout = new JPanel(gridBag); //i use this panel for helping me at the arrangment
    justForLayout.setBackground(Color.LIGHT_GRAY);
    mainFrame.getContentPane().add(justForLayout,constr);
    BuildConstraints(constr,1,1,1,1,40,70);
    constr.fill = GridBagConstraints.HORIZONTAL;
    constr.insets = createFeatures.Inset(3,3,3,3);
    mainFrame.getContentPane().add(panelA, constr);
    BuildConstraints(constr,2,1,1,1,30,0);
    constr.fill=GridBagConstraints.BOTH;
    constr.insets = createFeatures.Inset(3,3,3,3);
    JPanel justForLayout2 = new JPanel(gridBag);//i use this panel for helping me at the arrangment
    justForLayout2.setBackground(Color.LIGHT_GRAY);
    mainFrame.getContentPane().add(justForLayout2,constr);
    BuildConstraints(constr,1,3,1,1,0,30);
    constr.fill = GridBagConstraints.HORIZONTAL;
    constr.insets = createFeatures.Inset(3,3,3,3);
    mainFrame.getContentPane().add(panelB, constr);
    public void BuildConstraints (GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) {
         gbc.gridx = gx;
         gbc.gridy = gy;
         gbc.gridwidth = gw;
         gbc.gridheight = gh;
         gbc.weightx = wx;
         gbc.weighty = wy;
    }//end method Buildconstrraints()

    Try this as a demo, you may have to work with it a bit.
           JPanel mainPanel = (JPanel) getContentPane();
            mainPanel.setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            JPanel PanelA = new JPanel();
            PanelA.setBorder(BorderFactory.createEtchedBorder());
            PanelA.add(new JLabel("I'm panel A"));
            JPanel PanelB = new JPanel();
            PanelB.setBorder(BorderFactory.createEtchedBorder());
            PanelB.add(new JLabel("I'm Panel B"));
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            gbc.insets = new Insets(40, 10, 40, 10);    //top,left,bottom,right
            mainPanel.add(PanelA, gbc);
            mainPanel.add(PanelB, gbc);

  • Problem with gridbaglayout in JPanel

    Hello I am trying to display contact information in three serperate Jpanels on tabbbed panes.I would like to get help in configuring maybe just the pane of void showPane1().I need something like
    Searchlb | Combodropname1
    firstnamelb | firstnametxt | lastnamelb | lastnametxt
    Addresslb addresslb.Horizontal-----------------------*-
    citylb | citytxt | statelb | statetxt
    postcodelb | postcodetxt | countrylb | countrytxt
    emaillb | emailtxt | homephonelb | homephonetxt
    faxnumberlb | faxnumbertxt
    Other panes have buttons
    Here`s the code it operates on login of MSAccess table called persons:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    import java.io.*;
    import java.util.Date;
    import java.text.NumberFormat;
    public class Addressbook extends JFrame{
         // Define constant variables
         final static String driver      = "sun.jdbc.odbc.JdbcOdbcDriver";
         final static String url      = "jdbc:odbc:addBKTAFE";
         final static String login      = "LOG-IN";
         final static String tab_login      = "Log-in";
         final static String tab1      = "INQUIRE Personnel Details";
         final static String tab2      = "UPDATE/DELETE Personnel Details";
         final static String tab3      = "INSERT Personnel Details";
         final static String insert      = "SAVE RECORD";
         final static String update           = "UPDATE RECORD";
         final static String delete      = "DELETE RECORD";
         final static String inquire      = "INQUIRE RECORD";
         final static String clear      = " CLEAR ";
         final static String relogin      = "Log-in failed! Please relog-in!";
         final static String norecfound      = "No Record Found!";
         final static String recinserted     = "Record Inserted!";
         final static String recupdated      = "Record Updated!";
         final static String recdeleted      = "Record Deleted!";
         final static String numericerror = "Age should be numeric!";
         final static String information = "INFORMATION";
         final static String error      = "ERROR";
         final static String genexception = "GENERAL EXCEPTION";
         final static String sqlexception = "SQL EXCEPTION";
         final static String confdelete = "CONFIRM DELETE";
         final static String slash      = "/";
         final static String table1      = "persons";
         final static String table2      = "Addresses";
    // Events events = new Events(this);
         // Define variables     for general use
         String sql = ""; // Used to store sql statements
         int pane_number = 0; // Used to indicate what screen needs to be processed
                                       // like resetting input fields and comboboxes
         boolean abort = false;// Used to indicate if error found to avoid further
                                       // processing/validations
         // Define container, panels and tabbedpane
    Container cntr = getContentPane();
    JTabbedPane tpane = new JTabbedPane();
         JPanel      cbpanel1 , cbpanel2 , cbpanel3,
                   panel1 , panel2 , panel3;
         // Setup constraints and type of layout
         GridBagConstraints constraints = new GridBagConstraints();
         GridBagConstraints constraints1 = new GridBagConstraints();
         GridBagConstraints constraints2 = new GridBagConstraints();
         GridBagConstraints constraints3 = new GridBagConstraints();
         GridBagLayout layout = new GridBagLayout ();
         // Define fonts to be used
         Font labelFont = new Font("Arial",Font.PLAIN,12);
         Font buttonFont = new Font("Arial",Font.BOLD,13);
         // Define labels
         JLabel lbUser      = new JLabel("Enter User ID: " );
         JLabel lbPassword      = new JLabel("Enter Password: ");
         JLabel lbSelectName      = new JLabel("Search Name: " );
         JLabel lbFirstName      = new JLabel("First Name: " );
         JLabel lbLastName      = new JLabel("Last Name: " );
         JLabel lbAddress           = new JLabel("Address: " );
         JLabel lbCity           = new JLabel("City" );
         JLabel lbState           = new JLabel("State: " );
         JLabel lbPostcode      = new JLabel("Postcode" );
    JLabel lbCountry           = new JLabel("Country" );
         JLabel lbEmailAddress      = new JLabel("Email Address: " );
    JLabel lbHomeNumber      = new JLabel("Home Phone No.: " );
    JLabel lbFaxNumber      = new JLabel("Fax No.: " );
         // Define combo boxes in third screen (insert pane)
         JComboBox cbName1          = new JComboBox();
         JComboBox cbPersonId1          = new JComboBox();
         // Define combo boxes in second (update/delete pane)
         JComboBox cbName2          = new JComboBox();
         JComboBox cbPersonId2          = new JComboBox();
         // Define buttons, text fields and password field
         JButton btLogin      = new JButton (login );
         JButton btInsert = new JButton (insert );
         JButton btUpdate      = new JButton (update );
         JButton btDelete      = new JButton (delete );
         JButton btInquire      = new JButton (inquire);
         JButton btClear      = new JButton (clear );
         JPasswordField jpPassword           = new JPasswordField(10 );
         JTextField tfUser           = new JTextField("",10 );
         // Inquiry fields on first screen (inquiry pane)
         JTextField tfFirstName1      = new JTextField("",30);
         JTextField tfLastName1           = new JTextField("",30);
         JTextField      tfAddress1          = new JTextField("",30);
         JTextField      tfCity1 = new JTextField("",15);
         JTextField      tfState1 = new JTextField("",15);
         JTextField      tfPostcode1      = new JTextField("",30);
         JTextField      tfCountry1          = new JTextField("",15 );
    JTextField      tfEmailAddress1      = new JTextField("",30);
    JTextField      tfHomeNumber1      = new JTextField("",15);
         JTextField      tfFaxNumber1           = new JTextField("",15 );
         // Input fields on second screen (update/delete pane)
         JTextField tfFirstName2      = new JTextField("",30);
         JTextField tfLastName2          = new JTextField("",30);
         JTextField      tfAddress2          = new JTextField("",30);
         JTextField      tfCity2 = new JTextField("",15);
         JTextField      tfState2 = new JTextField("",15);
         JTextField      tfPostcode2      = new JTextField("",30);
         JTextField      tfCountry2          = new JTextField("",15 );
    JTextField      tfEmailAddress2      = new JTextField("",30);
    JTextField      tfHomeNumber2      = new JTextField("",15);
         JTextField      tfFaxNumber2      = new JTextField("",15 );
         // Input fields on third screen (insert pane)
         JTextField tfFirstName3      = new JTextField("",30);
         JTextField tfLastName3          = new JTextField("",30);
         JTextField      tfAddress3          = new JTextField("",30);
         JTextField      tfCity3 = new JTextField("",15);
         JTextField      tfState3 = new JTextField("",15);
         JTextField      tfPostcode3      = new JTextField("",30);
         JTextField      tfCountry3          = new JTextField("",15 );
    JTextField      tfEmailAddress3      = new JTextField("",30);
    JTextField      tfHomeNumber3      = new JTextField("",15);
         JTextField      tfFaxNumber3           = new JTextField("",15 );
    //------------------------------------------------------------------------------>>>
    //-----------------------Start Addressbook()------------------------------------>>>
    Addressbook(){
    // define listener after adding items to CB to avoid triggering it
         //     cbName1.addItemListener(new ItemListener());
    // public void itemStateChanged(ItemEvent e){
    //--------------------------END Addressbook constructor------------------------------------->>>
    //------------------------------------------------------------------------------>>>
    //------------------------------------------------------------------------------>>>
    //--------------------Start setupLoginPanel()----------------------------------->>>
         // Setup the login screen
         public void setupLoginPanel(){
              // set application title
         setTitle("Address Book Application");
              // center screen
              setLocation((Toolkit.getDefaultToolkit().getScreenSize().width
                                  - getWidth())/2,
                        (Toolkit.getDefaultToolkit().getScreenSize().height
                             - getHeight())/2);
         panel1 = new JPanel();
              // set screen border
              panel1.setBorder(BorderFactory.createTitledBorder(
                                  BorderFactory.createEtchedBorder(),""));
              // add tabbedpane to panel
              tpane.addTab(tab_login, panel1);
              // add panel to container
              cntr.add(tpane);
              // setup layout as GridBagLayout
              constraints.insets = new Insets(2,2,2,2);
              panel1.setLayout(layout);
              // setup User ID label in display area
              lbUser.setFont(labelFont);
              constraints.ipadx = 2;
              constraints.ipady = 2;
              constraints.gridx = 0;
              constraints.gridy = 0;
              constraints.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbUser, constraints);
              panel1.add(lbUser);
              // setup User ID input field in display area
              tfUser.setFont(labelFont);
              constraints.ipadx = 2;
              constraints.ipady = 2;
              constraints.gridx = 1;
              constraints.gridy = 0;
              constraints.fill = GridBagConstraints.HORIZONTAL;
              layout.setConstraints(tfUser, constraints);
              panel1.add(tfUser);
              // setup Password label in display area
              lbPassword.setFont(labelFont);
              constraints.ipadx = 2;
              constraints.ipady = 2;
              constraints.gridx = 0;
              constraints.gridy = 1;
              constraints.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbPassword, constraints);
              panel1.add(lbPassword);
              // setup Password input field in display area
              jpPassword.setEchoChar('*');
              constraints.ipadx = 2;
              constraints.ipady = 2;
              constraints.gridx = 1;
              constraints.gridy = 1;
              layout.setConstraints(jpPassword, constraints);
              panel1.add(jpPassword);
              // setup Login button in display area
              btLogin.setFont(buttonFont);
              constraints.anchor = GridBagConstraints.WEST;
              constraints.gridy = 3;
              constraints.gridx = 1;
              layout.setConstraints(btLogin, constraints);
              panel1.add(btLogin);
              // setup login button listener
              btLogin.addActionListener(new ButtonHandler());
              // allow ALT L to press login button
              btLogin.setMnemonic('l');
    //--------------------End setupLoginPanel()------------------------------------->>>
    //--------------------Start login()--------------------------------------------->>>
         // Validate user input from the login screen based on information from login
         // table (note: manually create/update your login from table LOGIN).
         public void login(){
              String user = tfUser.getText();
              user = user.trim();
              char[] pw = jpPassword.getPassword();
    String password = new String(pw).trim();
              sql = "SELECT * FROM persons WHERE username='"+
                   user+"' AND password='"+password+"'";
              try{
                   // load MS Access driver
                   Class.forName(driver);
              }catch(java.lang.ClassNotFoundException ex){
                   JOptionPane.showMessageDialog(null,ex.getMessage(), error ,
                        JOptionPane.PLAIN_MESSAGE);
              try{
                   // setup connection to DBMS
                   Connection conn = DriverManager.getConnection(url);
                   // create statement
                   Statement stmt = conn.createStatement();
                   // execute sql statement
                   stmt.execute(sql);
                   ResultSet rs = stmt.getResultSet();
                   boolean recordfound = rs.next();
                   if (recordfound){
                        tpane.removeTabAt(0);
                        showPane1();
                        showPane2();
                        showPane3();
                   else{
                        // username/password invalid
                        JOptionPane.showMessageDialog(null,relogin, error,
                             JOptionPane.INFORMATION_MESSAGE);
                        //clear login and password fields
                        tfUser.setText ("");
                        jpPassword.setText("");
                   conn.close();
              }catch(Exception ex){
                   JOptionPane.showMessageDialog(null,ex.getMessage(), genexception,
                        JOptionPane.INFORMATION_MESSAGE);
    //--------------------End login()----------------------------------------------->>>
    //--------------------Start showPane1()----------------------------------------->>>
         // Setup screen 1(inquiry pane) including labels, input fields, comboboxes.
         // Table PERSONS is read to list inquiry parameters.
         void showPane1(){
              panel1 = new JPanel();
              cbpanel1 = new JPanel();
              // set screen border
              panel1.setBorder(BorderFactory.createTitledBorder(
                                  BorderFactory.createEtchedBorder(),""));
              // add tabbedpane to panel
              tpane.addTab(tab1, panel1);
              // setup layout as GridBagLayout
              constraints1.insets = new Insets(2,2,2,2);
              panel1.setLayout (layout);
              cbpanel1.setLayout (layout);
              // setup Name combobox label
              lbSelectName.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 0;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbSelectName, constraints1);
              panel1.add(lbSelectName);
              // setup Name combobox as search key
              cbName1.setFont(labelFont);
              constraints1.ipady = 10;
              constraints1.gridx = 1;
              constraints1.gridy = 0;
              constraints1.gridwidth = 3;
              constraints1.anchor = GridBagConstraints.WEST;
              constraints1.fill = GridBagConstraints.HORIZONTAL;
              layout.setConstraints(cbName1, constraints1);
              panel1.add(cbName1);
              // setup search combobox (Name and corresponding key)
              cbName1.addItem ("Choose one:");
              cbPersonId1.addItem("0");
              // setup First Name label in display area
              lbFirstName.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 1;
              constraints1.anchor = GridBagConstraints.WEST;
              constraints1.fill = GridBagConstraints.NONE;
              constraints1.gridwidth = 1;
              layout.setConstraints(lbFirstName, constraints1);
              panel1.add(lbFirstName);
              // setup First Name input field in display area
              tfFirstName1.setFont(labelFont);
              tfFirstName1.setEditable(false);
              constraints1.gridx = 1;
              constraints1.gridy = 1;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfFirstName1, constraints1);
              panel1.add(tfFirstName1);
              // setup Last Name label in display area
              lbLastName.setFont(labelFont);
              constraints1.gridx = 2;
              constraints1.gridy = 1;
              constraints1.anchor = GridBagConstraints.WEST;
              constraints1.fill = GridBagConstraints.NONE;
              layout.setConstraints(lbLastName, constraints1);
              panel1.add(lbLastName);
              // setup Last Name input field in display area
              tfLastName1.setFont(labelFont);
              tfLastName1.setEditable(false);
              constraints1.gridx = 3;
              constraints1.gridy = 1;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfLastName1, constraints1);
              panel1.add(tfLastName1);
              // setup Address label in display area
              lbAddress.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 2;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbAddress, constraints1);
              panel1.add(lbAddress);
              // setup Address input field in display area
              tfAddress1.setFont(labelFont);
              tfAddress1.setEditable(false);
              constraints1.gridx = 1;
              constraints1.gridy = 2;
              constraints1.gridwidth = 3;
              constraints1.anchor = GridBagConstraints.WEST;
              constraints1.fill = GridBagConstraints.HORIZONTAL;
              layout.setConstraints(tfAddress1, constraints1);
              panel1.add(tfAddress1);
              // setup City label in display area
              lbCity.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 3;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbCity, constraints1);
              panel1.add(lbCity);
              // setup City input field in display area
              tfCity1.setFont(labelFont);
              tfCity1.setEditable(false);
              constraints1.gridx = 1;
              constraints1.gridy = 3;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfCity1, constraints1);
              panel1.add(tfCity1);
              // setup State label in display area
              lbState.setFont(labelFont);
              constraints1.gridx = 2;
              constraints1.gridy = 3;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbState, constraints1);
              panel1.add(lbState);
              // setup State input field in display area
              tfState1.setFont(labelFont);
              tfState1.setEnabled(false);
              constraints1.gridx = 3;
              constraints1.gridy = 3;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfState1, constraints1);
              panel1.add(tfState1);
              // setup Postcode label in display area
              lbPostcode.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 4;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbPostcode, constraints1);
              panel1.add(lbPostcode);
              // setup Address input field in display area
              tfPostcode1.setFont(labelFont);
              tfPostcode1.setEditable(false);
              constraints1.gridx = 1;
              constraints1.gridy = 4;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfPostcode1, constraints1);
              panel1.add(tfPostcode1);
              // setup Country label in display area
              lbCountry.setFont(labelFont);
              constraints1.gridx = 2;
              constraints1.gridy = 4;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbCountry, constraints1);
              panel1.add(lbCountry);
              // setup Country input field in display area
              tfCountry1.setFont(labelFont);
              tfCountry1.setEditable(false);
              constraints1.gridx = 3;
              constraints1.gridy = 4;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfCountry1, constraints1);
              panel1.add(tfCountry1);
              // setup Email Address label in display area
              lbEmailAddress = new JLabel ("Email Address:");
              lbEmailAddress.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 5;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbEmailAddress, constraints1);
              panel1.add(lbEmailAddress);
              // setup Email Address input field in display area
              tfEmailAddress1.setFont(labelFont);
              constraints1.gridx = 1;
              constraints1.gridy = 5;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfEmailAddress1, constraints1);
              panel1.add(tfEmailAddress1);
              // setup Home Phone Number label in display area
              lbHomeNumber.setFont(labelFont);
              constraints1.gridx = 2;
              constraints1.gridy = 5;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbHomeNumber, constraints1);
              panel1.add(lbHomeNumber);
              // setup Home Phone Number input field in display area
              tfHomeNumber1.setFont(labelFont);
              tfHomeNumber1.setEditable(false);
              constraints1.gridx = 3;
              constraints1.gridy = 5;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfHomeNumber1, constraints1);
              panel1.add(tfHomeNumber1);
              // setup Fax Number label in display area
              lbFaxNumber.setFont(labelFont);
              constraints1.gridx = 0;
              constraints1.gridy = 6;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbFaxNumber, constraints1);
              panel1.add(lbFaxNumber);
              // setup Fax Number input field in display area
              tfFaxNumber1.setFont(labelFont);
              tfFaxNumber1.setEditable(false);
              constraints1.gridx = 1;
              constraints1.gridy = 6;
              constraints1.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfFaxNumber1, constraints1);
              panel1.add(tfFaxNumber1);
    // indicate inquiry pane
              pane_number = 1;
              // read table get the list of names in CB search key
         accessDBInit();
              // define listener after adding items to CB to avoid triggering it
              cbName1.addItemListener(new ComboBoxHandler());
    //--------------------End showPane1()------------------------------------------->>>
    //--------------------Start showPane2()----------------------------------------->>>
         // Setup screen 2(update and delete pane) including labels, input fields,
         // comboboxes, and buttons. Table PERSONS is read to list inquiry parameters.
         void showPane2(){
              panel2 = new JPanel();
              cbpanel2 = new JPanel();
              labelFont = new Font("Arial",Font.PLAIN,12);
              buttonFont = new Font("Arial",Font.BOLD,12);
              // set screen border
              panel2.setBorder(BorderFactory.createTitledBorder(
                   BorderFactory.createEtchedBorder(),""));
              // add tabbedpane to panel
              tpane.addTab(tab2, panel2);
              // setup layout as GridBagLayout
              constraints2.insets = new Insets(2,2,2,2);
              panel2.setLayout (layout);
              cbpanel2.setLayout (layout);
              // setup Name combobox label
              lbSelectName.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 0;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbSelectName, constraints2);
              panel1.add(lbSelectName);
              // setup Name combobox as search key
              cbName2.setFont(labelFont);
              constraints2.ipady = 10;
              constraints2.gridx = 1;
              constraints2.gridy = 0;
              constraints2.gridwidth = 3;
              constraints2.anchor = GridBagConstraints.WEST;
              constraints2.fill = GridBagConstraints.HORIZONTAL;
              layout.setConstraints(cbName1, constraints2);
              panel1.add (cbName1);
              // setup search combobox (Name and corresponding key)
              cbName1.addItem ("Choose one:");
              cbPersonId1.addItem("0");
              // setup First Name label in display area
              lbFirstName.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 1;
              constraints2.anchor = GridBagConstraints.WEST;
              constraints2.fill = GridBagConstraints.NONE;
              constraints2.gridwidth = 1;
              layout.setConstraints(lbFirstName, constraints2);
              panel1.add(lbFirstName);
              // setup First Name input field in display area
              tfFirstName2.setFont(labelFont);
              tfFirstName2.setEditable(false);
              constraints2.gridx = 1;
              constraints2.gridy = 1;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfFirstName2, constraints2);
              panel1.add(tfFirstName2);
              // setup Last Name label in display area
              lbLastName.setFont(labelFont);
              constraints2.gridx = 2;
              constraints2.gridy = 1;
              constraints2.anchor = GridBagConstraints.WEST;
              constraints2.fill = GridBagConstraints.NONE;
              layout.setConstraints(lbLastName, constraints2);
              panel1.add(lbLastName);
              // setup Last Name input field in display area
              tfLastName2.setFont(labelFont);
              tfLastName2.setEditable(false);
              constraints2.gridx = 3;
              constraints2.gridy = 1;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfLastName2, constraints2);
              panel1.add(tfLastName2);
              // setup Address label in display area
              lbAddress.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 2;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbAddress, constraints2);
              panel1.add(lbAddress);
              // setup Address input field in display area
              tfAddress2.setFont(labelFont);
              tfAddress2.setEditable(false);
              constraints2.gridx = 1;
              constraints2.gridy = 2;
              constraints2.gridwidth = 3;
              constraints2.anchor = GridBagConstraints.WEST;
              constraints2.fill = GridBagConstraints.HORIZONTAL;
              layout.setConstraints(tfAddress2, constraints2);
              panel1.add(tfAddress2);
              // setup City label in display area
              lbCity.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 3;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbCity, constraints2);
              panel1.add(lbCity);
              // setup City input field in display area
              tfCity2.setFont(labelFont);
              tfCity2.setEditable(false);
              constraints2.gridx = 1;
              constraints2.gridy = 3;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfCity2, constraints2);
              panel1.add(tfCity2);
              // setup State label in display area
              lbState.setFont(labelFont);
              constraints2.gridx = 2;
              constraints2.gridy = 3;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbState, constraints2);
              panel1.add(lbState);
              // setup State input field in display area
              tfState2.setFont(labelFont);
              tfState2.setEnabled(false);
              constraints2.gridx = 3;
              constraints2.gridy = 3;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfState2, constraints2);
              panel1.add(tfState2);
              // indicate inquiry pane
              pane_number = 1;
              // setup Address label in display area
              lbPostcode.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 4;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbPostcode, constraints2);
              panel1.add(lbPostcode);
              // setup Address input field in display area
              tfPostcode2.setFont(labelFont);
              tfPostcode2.setEditable(false);
              constraints2.gridx = 1;
              constraints2.gridy = 4;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfPostcode2, constraints2);
              panel1.add(tfPostcode2);
              // setup Country label in display area
              lbCountry.setFont(labelFont);
              constraints2.gridx = 2;
              constraints2.gridy = 4;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbCountry, constraints2);
              panel1.add(lbCountry);
              // setup Country input field in display area
              tfCountry2.setFont(labelFont);
              tfCountry2.setEditable(false);
              constraints2.gridx = 3;
              constraints2.gridy = 4;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfCountry2, constraints2);
              panel1.add(tfCountry2);
              // setup Email Address label in display area
              lbEmailAddress = new JLabel ("Email Address:");
              lbEmailAddress.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 5;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbEmailAddress, constraints2);
              panel1.add(lbEmailAddress);
              // setup Email Address input field in display area
              tfEmailAddress2.setFont(labelFont);
              constraints2.gridx = 1;
              constraints2.gridy = 5;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfEmailAddress2, constraints2);
              panel1.add(tfEmailAddress2);
              // setup Home Phone Number label in display area
              lbHomeNumber.setFont(labelFont);
              constraints2.gridx = 2;
              constraints2.gridy = 5;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbHomeNumber, constraints2);
              panel1.add(lbHomeNumber);
              // setup Home Phone Number input field in display area
              tfHomeNumber2.setFont(labelFont);
              tfHomeNumber2.setEditable(false);
              constraints2.gridx = 3;
              constraints2.gridy = 5;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfHomeNumber2, constraints2);
              panel1.add(tfHomeNumber2);
              // setup Fax Number label in display area
              lbFaxNumber.setFont(labelFont);
              constraints2.gridx = 0;
              constraints2.gridy = 6;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbFaxNumber, constraints2);
              panel1.add(lbFaxNumber);
              // setup Fax Number input field in display area
              tfFaxNumber2.setFont(labelFont);
              tfFaxNumber2.setEditable(false);
              constraints2.gridx = 1;
              constraints2.gridy = 6;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfFaxNumber2, constraints2);
              panel1.add(tfFaxNumber2);
              // setup UPDATE button in display area
              btUpdate.setFont(buttonFont);
              constraints2.gridx = 3;
              constraints2.gridy = 7;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(btUpdate, constraints2);
              panel2.add(btUpdate);
              // setup DELETE button in display area
              btDelete.setFont(buttonFont);
              constraints2.gridx = 1;
              constraints2.gridy = 7;
              constraints2.anchor = GridBagConstraints.WEST;
              layout.setConstraints(btDelete, constraints2);
              panel2.add(btDelete);
              btUpdate.addActionListener(new ButtonHandler());
              btDelete.addActionListener(new ButtonHandler());
              // allow ALT U to press update button
              btUpdate.setMnemonic('u');
              // allow ALT D to press delete button
              btDelete.setMnemonic('d');
              // read table get the list of names in combo box search key
    accessDBInit();
              // define listener after adding items to CB to avoid triggering it
              cbName2.addItemListener(new ComboBoxHandler());
    //--------------------End showPane2()------------------------------------------->>>
    //--------------------Start showPane3()----------------------------------------->>>
         // Setup screen 2(insert pane) including labels, input fields, comboboxes,
         // and buttons.
         void showPane3(){
              panel3      = new JPanel();
              // set screen border
              panel3.setBorder(BorderFactory.createTitledBorder(
                   BorderFactory.createEtchedBorder(),""));
              // add tabbedpane to panel
              tpane.addTab(tab3, panel3);
              // setup layout as GridBagLayout
              constraints3.insets = new Insets(2,2,2,2);
              panel3.setLayout (layout);
              // setup First Name label in display area
              JLabel lbFirstName = new JLabel("First Name:");
              lbFirstName.setFont(labelFont);
              constraints3.gridx = 0;
              constraints3.gridy = 0;
              constraints3.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbFirstName, constraints3);
              panel3.add(lbFirstName);
              // setup First Name input field in display area
              tfFirstName3.setFont(labelFont);
              constraints3.ipady = 8; // adjust heigth of input field
              constraints3.gridx = 1;
              constraints3.gridy = 0;
              constraints3.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfFirstName3, constraints3);
              panel3.add(tfFirstName3);
              // setup Last Name label in display area
              lbLastName = new JLabel("Last Name: ");
              lbLastName.setFont(labelFont);
              constraints3.gridx = 2;
              constraints3.gridy = 0;
              constraints3.anchor = GridBagConstraints.WEST;
              layout.setConstraints(lbLastName, constraints3);
              panel3.add(lbLastName);
              // setup Last Name input field in display area
              tfLastName3.setFont(labelFont);
              constraints3.gridx = 3;
              constraints3.gridy = 0;
              constraints3.anchor = GridBagConstraints.WEST;
              layout.setConstraints(tfLastName3, constraints3);
              panel3.add(tfLastName3);
              // setup Middle Name label in display area
              lbAddress = new JLabel("Address: ");
              lbAddress.setFont(labelFont);
              constraints3.gridx = 0;
              constraints3.gridy = 1;
              constraints3.anch

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class andy extends JFrame {
      // Define constant variables
      final static String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
      final static String url = "jdbc:odbc:addBKTAFE";
      final static String login = "LOG-IN";
      final static String tab_login = "Log-in";
      final static String tab1 = "INQUIRE Personnel Details";
      final static String tab2 = "UPDATE/DELETE Personnel Details";
      final static String tab3 = "INSERT Personnel Details";
      final static String tab4 = "PRINT";
      final static String insert = "SAVE RECORD";
      final static String update = "UPDATE RECORD";
      final static String delete = "DELETE RECORD";
      final static String inquire = "INQUIRE RECORD";
      final static String clear = " CLEAR ";
      final static String relogin = "Log-in failed! Please relog-in!";
      final static String norecfound = "No Record Found!";
      final static String recinserted = "Record Inserted!";
      final static String recupdated = "Record Updated!";
      final static String recdeleted = "Record Deleted!";
      final static String numericerror = "Age should be numeric!";
      final static String information = "INFORMATION";
      final static String error = "ERROR";
      final static String genexception = "GENERAL EXCEPTION";
      final static String sqlexception = "SQL EXCEPTION";
      final static String confdelete = "CONFIRM DELETE";
      final static String slash = "/";
      final static String table1 = "persons";
      final static String table2 = "Addresses";
      // Define container, panels and tabbedpane
      Container cntr = getContentPane();
      JTabbedPane tpane = new JTabbedPane();
      JPanel cbpanel1 , cbpanel2 , cbpanel3,
             panel1 , panel2 , panel3, panel4;
      // Define fonts to be used
      Font labelFont = new Font("Arial",Font.PLAIN,12);
      Font buttonFont = new Font("Arial",Font.BOLD,13);
      // Define labels
      JLabel lbUser = new JLabel("Enter User ID: " );
      JLabel lbPassword = new JLabel("Enter Password: ");
      JLabel lbSelectName = new JLabel("Search Name: " );
      JLabel lbFirstName = new JLabel("First Name: " );
      JLabel lbLastName = new JLabel("Last Name: " );
      JLabel lbAddress = new JLabel("Address: " );
      JLabel lbCity = new JLabel("City: " );
      JLabel lbState = new JLabel("State: " );
      JLabel lbPostcode = new JLabel("Postcode: " );
      JLabel lbCountry = new JLabel("Country: " );
      JLabel lbEmailAddress = new JLabel("Email Address: " );
      JLabel lbHomeNumber = new JLabel("Home Phone No.: " );
      JLabel lbFaxNumber = new JLabel("Fax No.: " );
      // Define combo boxes in third screen (insert pane)
      JComboBox cbName1     = new JComboBox();
      JComboBox cbName2     = new JComboBox();
      JComboBox cbName3     = new JComboBox();
      JComboBox cbPersonId1 = new JComboBox();
      JComboBox cbPersonId2 = new JComboBox();
      JComboBox cbPersonId3 = new JComboBox();
      // Inquiry fields on first screen (inquiry pane)
      JTextField tfFirstName1 = new JTextField("",30);
      JTextField tfLastName1 = new JTextField("",30);
      JTextField tfAddress1 = new JTextField("",30);
      JTextField tfCity1 = new JTextField("",15);
      JTextField tfState1 = new JTextField("",15);
      JTextField tfPostcode1 = new JTextField("",30);
      JTextField tfCountry1 = new JTextField("",15 );
      JTextField tfEmailAddress1 = new JTextField("",30);
      JTextField tfHomeNumber1 = new JTextField("",15);
      JTextField tfFaxNumber1 = new JTextField("",15 );
      // Input fields on second screen (update/delete pane)
      JTextField tfFirstName2 = new JTextField("",30);
      JTextField tfLastName2 = new JTextField("",30);
      JTextField tfAddress2 = new JTextField("",30);
      JTextField tfCity2 = new JTextField("",15);
      JTextField tfState2 = new JTextField("",15);
      JTextField tfPostcode2 = new JTextField("",30);
      JTextField tfCountry2 = new JTextField("",15);
      JTextField tfEmailAddress2 = new JTextField("",30);
      JTextField tfHomeNumber2 = new JTextField("",15);
      JTextField tfFaxNumber2 = new JTextField("",15);
      // Input fields on third screen (inset details pane)
      JTextField tfFirstName3 = new JTextField("",30);
      JTextField tfLastName3 = new JTextField("",30);
      JTextField tfAddress3 = new JTextField("",30);
      JTextField tfCity3 = new JTextField("",15);
      JTextField tfState3 = new JTextField("",15);
      JTextField tfPostcode3 = new JTextField("",30);
      JTextField tfCountry3 = new JTextField("",15);
      JTextField tfEmailAddress3 = new JTextField("",30);
      JTextField tfHomeNumber3 = new JTextField("",15);
      JTextField tfFaxNumber3 = new JTextField("",15);
      GridBagLayout layout = new GridBagLayout();
      GridBagConstraints constraints = new GridBagConstraints();
      public andy() {
        super("Address Book Application");
        showPane1();
        showPane2();
        showPane3();
        showPane4();
        cntr.add(tpane, "Center");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(900,385);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((screenSize.width  - getWidth())/2,
                    (screenSize.height - getHeight())/2);
        setVisible(true);
      // Setup screen 1(inquiry pane) including labels, input fields, comboboxes.
      // Table PERSONS is read to list inquiry parameters.
      void showPane1() {
        panel1 = new JPanel();
        cbpanel1 = new JPanel();
        // set screen border
        panel1.setBorder(BorderFactory.createTitledBorder(
          BorderFactory.createEtchedBorder(),""));
        // add tabbedpane to panel
        tpane.addTab(tab1, panel1);
        // setup layout as GridBagLayout
        constraints.insets = new Insets(2,2,2,2);
        panel1.setLayout (layout);
        cbpanel1.setLayout (layout);
        // setup Name combobox label
        lbSelectName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        layout.setConstraints(lbSelectName, constraints);
        panel1.add(lbSelectName);
        // setup Name combobox as search key
        cbName1.setFont(labelFont);
        constraints.ipady = 10;
        constraints.gridwidth = constraints.REMAINDER;
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(cbName1, constraints);
        panel1.add(cbName1);
        // setup search combobox (Name and corresponding key)
        cbName1.addItem ("Choose one:");
        cbPersonId1.addItem("0");
        // setup First Name label in display area
        lbFirstName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbFirstName, constraints);
        panel1.add(lbFirstName);
        // setup First Name input field in display area
        tfFirstName1.setFont(labelFont);
        tfFirstName1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfFirstName1, constraints);
        panel1.add(tfFirstName1);
        // setup Last Name label in display area
        lbLastName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbLastName, constraints);
        panel1.add(lbLastName);
        // setup Last Name input field in display area
        tfLastName1.setFont(labelFont);
        tfLastName1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfLastName1, constraints);
        panel1.add(tfLastName1);
        // setup Address label in display area
        lbAddress.setFont(labelFont);
        constraints.gridwidth = 1;
        constraints.anchor = GridBagConstraints.EAST;
        layout.setConstraints(lbAddress, constraints);
        panel1.add(lbAddress);
        // setup Address input field in display area
        tfAddress1.setFont(labelFont);
        tfAddress1.setEditable(false);
        constraints.gridwidth = constraints.REMAINDER;
        constraints.anchor = GridBagConstraints.WEST;
        constraints.weightx = 1.0;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        layout.setConstraints(tfAddress1, constraints);
        panel1.add(tfAddress1);
        // setup City label in display area
        lbCity.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        constraints.fill = GridBagConstraints.NONE;
            layout.setConstraints(lbCity, constraints);
        panel1.add(lbCity);
        // setup City input field in display area
        tfCity1.setFont(labelFont);
        tfCity1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfCity1, constraints);
        panel1.add(tfCity1);
        // setup State label in display area
        lbState.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbState, constraints);
        panel1.add(lbState);
        // setup State input field in display area
        tfState1.setFont(labelFont);
        tfState1.setEnabled(false);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfState1, constraints);
        panel1.add(tfState1);
        // setup Postcode label in display area
        lbPostcode.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbPostcode, constraints);
        panel1.add(lbPostcode);
        // setup Address input field in display area
        tfPostcode1.setFont(labelFont);
        tfPostcode1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfPostcode1, constraints);
        panel1.add(tfPostcode1);
        // setup Country label in display area
        lbCountry.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbCountry, constraints);
        panel1.add(lbCountry);
        // setup Country input field in display area
        tfCountry1.setFont(labelFont);
        tfCountry1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfCountry1, constraints);
        panel1.add(tfCountry1);
        // setup Email Address label in display area
        lbEmailAddress.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbEmailAddress, constraints);
        panel1.add(lbEmailAddress);
        // setup Email Address input field in display area
        tfEmailAddress1.setFont(labelFont);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfEmailAddress1, constraints);
        panel1.add(tfEmailAddress1);
        // setup Home Phone Number label in display area
        lbHomeNumber.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbHomeNumber, constraints);
        panel1.add(lbHomeNumber);
        // setup Home Phone Number input field in display area
        tfHomeNumber1.setFont(labelFont);
        tfHomeNumber1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfHomeNumber1, constraints);
        panel1.add(tfHomeNumber1);
        // setup Fax Number label in display area
        lbFaxNumber.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbFaxNumber, constraints);
        panel1.add(lbFaxNumber);
        // setup Fax Number input field in display area
        tfFaxNumber1.setFont(labelFont);
        tfFaxNumber1.setEditable(false);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfFaxNumber1, constraints);
        panel1.add(tfFaxNumber1);
        // indicate inquiry pane
        // pane_number = 1;
        // read table get the list of names in CB search key
        // accessDBInit();
        // define listener after adding items to CB to avoid triggering it
        // cbName1.addItemListener(new ComboBoxHandler());
      //--------------------End showPane1()------------------------------------------->>>
      //--------------------Start showPane2()----------------------------------------->>>
      void showPane2() {
        panel2 = new JPanel();
        cbpanel2 = new JPanel();
        // set screen border
        panel2.setBorder(BorderFactory.createTitledBorder(
          BorderFactory.createEtchedBorder(),""));
        // add tabbedpane to panel
        tpane.addTab(tab2, panel2);
        // setup layout as GridBagLayout
        constraints.ipady = 0;
        panel2.setLayout (layout);
        cbpanel2.setLayout (layout);
        // setup Name combobox label
        lbSelectName = new JLabel("Search Name: ");
        lbSelectName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        layout.setConstraints(lbSelectName, constraints);
        panel2.add(lbSelectName);
        // setup Name combobox as search key
        cbName2.setFont(labelFont);
        constraints.ipady = 10;
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(cbName2, constraints);
        panel2.add(cbName2);
        // setup search combobox (Name and corresponding key)
        cbName2.addItem ("Choose one:");
        cbPersonId2.addItem("0");
        // setup UPDATE button in display area
        JButton btUpdate = new JButton("Update");
        btUpdate.setFont(buttonFont);
    //    btUpdate.addActionListener(new ButtonHandler());
        btUpdate.setMnemonic(KeyEvent.VK_U);
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(btUpdate, constraints);
        panel2.add(btUpdate);
        // setup DELETE button in display area
        JButton btDelete = new JButton("Delete");
        btDelete.setFont(buttonFont);
    //    btDelete.addActionListener(new ButtonHandler());
        btDelete.setMnemonic(KeyEvent.VK_D);
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(btDelete, constraints);
        panel2.add(btDelete);
        // setup First Name label in display area
        lbFirstName = new JLabel("First Name: ");
        lbFirstName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbFirstName, constraints);
        panel2.add(lbFirstName);
        // setup First Name input field in display area
        tfFirstName2.setFont(labelFont);
        tfFirstName2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfFirstName2, constraints);
        panel2.add(tfFirstName2);
        // setup Last Name label in display area
        lbLastName = new JLabel("Last Name: ");
        lbLastName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbLastName, constraints);
        panel2.add(lbLastName);
        // setup Last Name input field in display area
        tfLastName2.setFont(labelFont);
        tfLastName2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfLastName2, constraints);
        panel2.add(tfLastName2);
        // setup Address label in display area
        lbAddress = new JLabel("Address: ");
        lbAddress.setFont(labelFont);
        constraints.gridwidth = 1;
        constraints.anchor = GridBagConstraints.EAST;
        layout.setConstraints(lbAddress, constraints);
        panel2.add(lbAddress);
        // setup Address input field in display area
        tfAddress2.setFont(labelFont);
        tfAddress2.setEditable(true);
        constraints.gridwidth = constraints.REMAINDER;
        constraints.anchor = GridBagConstraints.WEST;
        constraints.weightx = 1.0;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        layout.setConstraints(tfAddress2, constraints);
        panel2.add(tfAddress2);
        // setup City label in display area
        lbCity = new JLabel("City: ");
        lbCity.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        constraints.fill = GridBagConstraints.NONE;
        layout.setConstraints(lbCity, constraints);
        panel2.add(lbCity);
        // setup City input field in display area
        tfCity2.setFont(labelFont);
        tfCity2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfCity2, constraints);
        panel2.add(tfCity2);
        // setup State label in display area
        lbState = new JLabel("State: ");
        lbState.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbState, constraints);
        panel2.add(lbState);
        // setup State input field in display area
        tfState2.setFont(labelFont);
        tfState2.setEnabled(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfState2, constraints);
        panel2.add(tfState2);
        // setup Postcode label in display area
        lbPostcode = new JLabel("Postcode: ");
        lbPostcode.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbPostcode, constraints);
        panel2.add(lbPostcode);
        // setup Address input field in display area
        tfPostcode2.setFont(labelFont);
        tfPostcode2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfPostcode2, constraints);
        panel2.add(tfPostcode2);
        // setup Country label in display area
        lbCountry = new JLabel("Country: ");
        lbCountry.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbCountry, constraints);
        panel2.add(lbCountry);
        // setup Country input field in display area
        tfCountry2.setFont(labelFont);
        tfCountry2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfCountry2, constraints);
        panel2.add(tfCountry2);
        // setup Email Address label in display area
        lbEmailAddress = new JLabel ("Email Address: ");
        lbEmailAddress.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbEmailAddress, constraints);
        panel2.add(lbEmailAddress);
        // setup Email Address input field in display area
        tfEmailAddress2.setFont(labelFont);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfEmailAddress2, constraints);
        panel2.add(tfEmailAddress2);
        // setup Home Phone Number label in display area
        lbHomeNumber = new JLabel("Home Phone No.: ");
        lbHomeNumber.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbHomeNumber, constraints);
        panel2.add(lbHomeNumber);
        // setup Home Phone Number input field in display area
        tfHomeNumber2.setFont(labelFont);
        tfHomeNumber2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfHomeNumber2, constraints);
        panel2.add(tfHomeNumber2);
        // setup Fax Number label in display area
        lbFaxNumber = new JLabel("Fax No.: ");
        lbFaxNumber.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbFaxNumber, constraints);
        panel2.add(lbFaxNumber);
        // setup Fax Number input field in display area
        tfFaxNumber2.setFont(labelFont);
        tfFaxNumber2.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfFaxNumber2, constraints);
        panel2.add(tfFaxNumber2);
      //-----------------------------End showpane2()---------------------------------->>
      //--------------------Start showPane3()----------------------------------------->>>
      void showPane3() {
        panel3 = new JPanel();
        // cbpanel3 = new JPanel();
        // set screen border
        panel3.setBorder(BorderFactory.createTitledBorder(
          BorderFactory.createEtchedBorder(),""));
        // add tabbedpane to panel
        tpane.addTab(tab3, panel3);
        // setup layout as GridBagLayout
        panel3.setLayout(layout);
        constraints.ipady = 0;
        panel3.setLayout (layout);
        // cbpanel3.setLayout (layout);
        // setup Name combobox label
        lbSelectName = new JLabel("Search Name: ");
        lbSelectName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        layout.setConstraints(lbSelectName, constraints);
        panel3.add(lbSelectName);
        // setup Name combobox as search key
        cbName3 = new JComboBox();
        cbName3.setFont(labelFont);
        constraints.ipady = 10;
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(cbName3, constraints);
        panel3.add(cbName3);
        // setup search combobox (Name and corresponding key)
        cbName3.addItem ("Choose one:");
        cbPersonId3.addItem("0");
        // setup INSERT button in display area
        JButton btInsert = new JButton("Insert");
        btInsert.setFont(buttonFont);
    //    btInsert.addActionListener(new ButtonListener());
        btInsert.setMnemonic(KeyEvent.VK_S);
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(btInsert, constraints);
        panel3.add(btInsert);
        // setup CLEAR button in display area
        JButton btClear = new JButton("Clear");
        btClear.setFont(buttonFont);
    //    btClear.addActionListener(new ButtonListener());
        btClear.setMnemonic(KeyEvent.VK_C);
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(btClear, constraints);
        panel3.add(btClear);
        // setup First Name label in display area
        lbFirstName = new JLabel("First Name: ");
        lbFirstName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbFirstName, constraints);
        panel3.add(lbFirstName);
        // setup First Name input field in display area
        tfFirstName3.setFont(labelFont);
        tfFirstName3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfFirstName3, constraints);
        panel3.add(tfFirstName3);
        // setup Last Name label in display area
        lbLastName = new JLabel("Last Name: ");
        lbLastName.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbLastName, constraints);
        panel3.add(lbLastName);
        // setup Last Name input field in display area
        tfLastName3.setFont(labelFont);
        tfLastName3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfLastName3, constraints);
        panel3.add(tfLastName3);
        // setup Address label in display area
        lbAddress = new JLabel("Address: ");
        lbAddress.setFont(labelFont);
        constraints.gridwidth = 1;
        constraints.anchor = GridBagConstraints.EAST;
        layout.setConstraints(lbAddress, constraints);
        panel3.add(lbAddress);
        // setup Address input field in display area
        tfAddress3.setFont(labelFont);
        tfAddress3.setEditable(true);
        constraints.gridwidth = constraints.REMAINDER;
        constraints.anchor = GridBagConstraints.WEST;
        constraints.weightx = 1.0;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        layout.setConstraints(tfAddress3, constraints);
        panel3.add(tfAddress3);
        // setup City label in display area
        lbCity = new JLabel("City: ");
        lbCity.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        constraints.fill = GridBagConstraints.NONE;
        layout.setConstraints(lbCity, constraints);
        panel3.add(lbCity);
        // setup City input field in display area
        tfCity3.setFont(labelFont);
        tfCity3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfCity3, constraints);
        panel3.add(tfCity3);
        // setup State label in display area
        lbState = new JLabel("State: ");
        lbState.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbState, constraints);
        panel3.add(lbState);
        // setup State input field in display area
        tfState3.setFont(labelFont);
        tfState3.setEnabled(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfState3, constraints);
        panel3.add(tfState3);
        // setup Postcode label in display area
        lbPostcode = new JLabel("Postcode: ");
        lbPostcode.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbPostcode, constraints);
        panel3.add(lbPostcode);
        // setup Address input field in display area
        tfPostcode3.setFont(labelFont);
        tfPostcode3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfPostcode3, constraints);
        panel3.add(tfPostcode3);
        // setup Country label in display area
        lbCountry = new JLabel("Country: ");
        lbCountry.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbCountry, constraints);
        panel3.add(lbCountry);
        // setup Country input field in display area
        tfCountry3.setFont(labelFont);
        tfCountry3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfCountry3, constraints);
        panel3.add(tfCountry3);
        // setup Email Address label in display area
        lbEmailAddress = new JLabel ("Email Address: ");
        lbEmailAddress.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbEmailAddress, constraints);
        panel3.add(lbEmailAddress);
        // setup Email Address input field in display area
        tfEmailAddress3.setFont(labelFont);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfEmailAddress3, constraints);
        panel3.add(tfEmailAddress3);
        // setup Home Phone Number label in display area
        lbHomeNumber = new JLabel("Home Phone No.: ");
        lbHomeNumber.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = constraints.RELATIVE;
        layout.setConstraints(lbHomeNumber, constraints);
        panel3.add(lbHomeNumber);
        // setup Home Phone Number input field in display area
        tfHomeNumber3.setFont(labelFont);
        tfHomeNumber3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        constraints.gridwidth = constraints.REMAINDER;
        layout.setConstraints(tfHomeNumber3, constraints);
        panel3.add(tfHomeNumber3);
        // setup Fax Number label in display area
        lbFaxNumber = new JLabel("Fax No.: ");
        lbFaxNumber.setFont(labelFont);
        constraints.anchor = GridBagConstraints.EAST;
        constraints.gridwidth = 1;
        layout.setConstraints(lbFaxNumber, constraints);
        panel3.add(lbFaxNumber);
        // setup Fax Number input field in display area
        tfFaxNumber3.setFont(labelFont);
        tfFaxNumber3.setEditable(true);
        constraints.anchor = GridBagConstraints.WEST;
        layout.setConstraints(tfFaxNumber3, constraints);
        panel3.add(tfFaxNumber3);
      //-----------------------------End showpane3()---------------------------------->>
      //-----------------------------Start showPane4()-------------------------------->>
      void showPane4() {
    //    qtm = new QueryTableModel();
    //    JTable table = new JTable(qtm);
    //    String query = "SELECT FirstName, LastName, HomePhone, " +
    //                   "FROM Addresses ORDER By LastName";
    //    qtm.setQuery(query);
        JPanel demoPanel = new JPanel();
        demoPanel.setPreferredSize(new Dimension(400,500));
        demoPanel.setBackground(Color.pink);
        demoPanel.add(new JLabel("Demo Panel in place of table",
                                  SwingConstants.CENTER));
        JScrollPane scrollPane = new JScrollPane(demoPanel);
        panel4 = new JPanel();
    //    pane_number = 4;
        panel4.setLayout(layout);
        constraints.ipady = 0;
    //    labelFont = new Font("Arial", Font.PLAIN, 12);   defined above
        buttonFont = new Font("Arial", Font.PLAIN, 13);
       // set screen border
       panel4.setBorder(
         BorderFactory.createTitledBorder(
           BorderFactory.createEtchedBorder(), ""));
       // add panel to tabbed pane
       tpane.addTab(tab4, panel4);
       JLabel lbPrint = new JLabel("Print");
       lbPrint.setFont(labelFont);
       constraints.anchor = constraints.EAST;
       layout.setConstraints(lbPrint, constraints);
       panel4.add(lbPrint);
       JButton btPrint = new JButton("Print");
       btPrint.setFont(buttonFont);
    //   btPrint.addActionListener(new ButtonListener());
       btPrint.setMnemonic(KeyEvent.VK_P);
       constraints.anchor = constraints.WEST;
       constraints.gridwidth = constraints.REMAINDER;
       layout.setConstraints(btPrint, constraints);
       panel4.add(btPrint);
       constraints.weighty = 1.0;
       constraints.fill = constraints.BOTH;
       constraints.anchor = constraints.CENTER;
       layout.setConstraints(scrollPane, constraints);
       panel4.add(scrollPane);
      public static void main(String[] args) {
        new andy();
    }

  • How can I display JTextFields correctly on a JPanel using GridBagLayout?

    I had some inputfields on a JPanel using the boxLayout. All was ok. Then I decided to change the panellayout to GridBagLayout. The JLabel fields are displayed correctly but the JTextField aren't. They are at the JPanel but have a size of 0??? So we cannot see what we type in these fields... Even when I put some text in the field before putting it on the panel.
    How can I display JTextFields correctly on a JPanel using GridBagLayout?
    here is a shortcut of my code:
    private Dimension sFieldSize10 = new Dimension(80, 20);
    // Create and instantiate Selection Fields
    private JLabel lSearchAbrText = new JLabel();
    private JTextField searchAbrText = new JTextField();
    // Set properties for SelectionFields
    lSearchAbrNumber.setText("ABR Number (0-9999999):");
    searchAbrNumber.setText("");
    searchAbrNumber.createToolTip();
    searchAbrNumber.setToolTipText("enter the AbrNumber.");
    searchAbrNumber.setPreferredSize(sFieldSize10);
    searchAbrNumber.setMaximumSize(sFieldSize10);
    public void createViewSubsetPanel() {
    pSubset = new JPanel();
    // Set layout
    pSubset.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    // Add Fields
    gbc.gridy = 0;
    gbc.gridx = GridBagConstraints.RELATIVE;
    pSubset.add(lSearchAbrNumber, gbc);
    // also tried inserting this statement
    // searchAbrNumber.setText("0000000");
    // without success
    pSubset.add(searchAbrNumber,gbc);
    pSubset.add(lSearchAbrText, gbc);
    pSubset.add(searchAbrText, gbc);
    gbc.gridy = 1;
    pSubset.add(lSearchClassCode, gbc);
    pSubset.add(searchClassCode, gbc);
    pSubset.add(butSearch, gbc);
    }

    import java.awt.*;
    import java.awt.event.*;
    import javax .swing.*;
    public class GridBagDemo {
      public static void main(String[] args) {
        JLabel
          labelOne   = new JLabel("Label One"),
          labelTwo   = new JLabel("Label Two"),
          labelThree = new JLabel("Label Three"),
          labelFour  = new JLabel("Label Four");
        JLabel[] labels = {
          labelOne, labelTwo, labelThree, labelFour
        JTextField
          tfOne   = new JTextField(),
          tfTwo   = new JTextField(),
          tfThree = new JTextField(),
          tfFour  = new JTextField();
        JTextField[] fields = {
          tfOne, tfTwo, tfThree, tfFour
        Dimension
          labelSize = new Dimension(125,20),
          fieldSize = new Dimension(150,20);
        for(int i = 0; i < labels.length; i++) {
          labels.setPreferredSize(labelSize);
    labels[i].setHorizontalAlignment(JLabel.RIGHT);
    fields[i].setPreferredSize(fieldSize);
    GridBagLayout gridbag = new GridBagLayout();
    JPanel panel = new JPanel(gridbag);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(5,5,5,5);
    panel.add(labelOne, gbc);
    panel.add(tfOne, gbc);
    gbc.gridwidth = gbc.RELATIVE;
    panel.add(labelTwo, gbc);
    gbc.gridwidth = gbc.REMAINDER;
    panel.add(tfTwo, gbc);
    gbc.gridwidth = 1;
    panel.add(labelThree, gbc);
    panel.add(tfThree, gbc);
    gbc.gridwidth = gbc.RELATIVE;
    panel.add(labelFour, gbc);
    gbc.gridwidth = gbc.REMAINDER;
    panel.add(tfFour, gbc);
    final JButton
    smallerButton = new JButton("smaller"),
    biggerButton = new JButton("wider");
    final JFrame f = new JFrame();
    ActionListener l = new ActionListener() {
    final int DELTA_X = 25;
    int oldWidth, newWidth;
    public void actionPerformed(ActionEvent e) {
    JButton button = (JButton)e.getSource();
    oldWidth = f.getSize().width;
    if(button == smallerButton)
    newWidth = oldWidth - DELTA_X;
    if(button == biggerButton)
    newWidth = oldWidth + DELTA_X;
    f.setSize(new Dimension(newWidth, f.getSize().height));
    f.validate();
    smallerButton.addActionListener(l);
    biggerButton.addActionListener(l);
    JPanel southPanel = new JPanel(gridbag);
    gbc.gridwidth = gbc.RELATIVE;
    southPanel.add(smallerButton, gbc);
    gbc.gridwidth = gbc.REMAINDER;
    southPanel.add(biggerButton, gbc);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(panel);
    f.getContentPane().add(southPanel, "South");
    f.pack();
    f.setLocation(200,200);
    f.setVisible(true);

  • Need to connect to upgraded Oracle EBS R12 version from R11. The current ODI set up is pointing to R11, Can i use the same connection to point to R12? Please hele experts..

    Need to connect to upgraded Oracle EBS R12 version from R11. The current ODI set up is pointing to R11, Can i use the same connection to point to R12? Please hele experts...
    Rp

    1. in physical connections part can i use the same work schema
    2. Can i use same contexts created or do i need to create everything as new and then try?
    Thanks,
    Rp.
    Hi,
    As you mentioned that you just upgraded the database, so the data is same and schema is same you can connect with the same work schema.
    Yes, you can use the same contexts , but need to do Reverse Engineering for your new database.
    And about data server, i think you also have no need to create new data server, if hostname,sid and port etc are same as these were with R11(consult with your DBAs regarding it)

  • Hello i forgot my i cloud password..anyone can help me to find my password.i already make a new apple id..but my icloud use another account..so how to reset my iCloud account plz hel me

    hello i forgot my i cloud password..anyone can help me to find my password.i already make a new apple id..but my icloud use another account..so how to reset my iCloud account plz hel me

    Making a new Apple ID is not a good idea, since you have to reset the password for that Apple ID anyway. All of your purchases are tied to the Apple ID that the iCloud account was created under. So, you have to retrieve the password for that Apple ID in order to sign into iCloud anyway.
    Go to Manage your Apple ID, and click on the Reset Password option (Apple - My Apple ID). Sign on with the Apple ID that the iCloud account was created under, and answer the security questions. If you do not remember the answers to the Security Questions, contact Apple Support to have them reset:
    ACCOUNT SECURITY CONTACT NUMBERS
    Cheers,
    GB

  • How can I control the size of a cell in the GridBagLayout?

    Hi,Swing Gurus
    I am developing a swing-based program using JBulider5 enterprise.
    It seems to me that the GridBagLayout is really a hard nut!
    How can I control the size of a cell in the GridBagLayout?
    It seems that I cann't control the size of a cell directly.
    But how the size of a particular cell is determined when I switch the layout manager from XYLayout to GridBagLayout?
    Thx in advance!
    Regards,
    Justine

    hi,i have not done what you are asking but there are fields like
    COLUMNWIDTH, MINSIZE, MAXGRIDSIZE, PREFEREDSIZE to which you can set the appropriate values and test for your need.hope this helped.bye martian.

  • Here is my GridBagLayout version of the code

         public void constructGUI()
               c= getContentPane();
              //Construct the menus and their listeners
              JMenu filemenu = new JMenu("File");
              JMenuItem saveas= new JMenuItem ("Save Amortization As");
              saveas.addActionListener(new ActionListener(){
                   public void actionPerformed (ActionEvent e)
                        JFileChooser filechooser = new JFileChooser ();
                        filechooser.setFileSelectionMode ( JFileChooser.FILES_ONLY);
                        int result = filechooser.showSaveDialog (null);
                        if (result== JFileChooser.CANCEL_OPTION)
                             return;
                        File filename = filechooser.getSelectedFile();
                        if (filename==null||filename.getName().equals (" "))
                             JOptionPane.showMessageDialog( null, "Invalid File Name", "Invalid FileName", JOptionPane.ERROR_MESSAGE );
                        else {
                             try
                                  System.out.println("I am ready to create the streams");
                                  FileOutputStream file = new FileOutputStream(filename, true);
                                  OutputStreamWriter filestream = new OutputStreamWriter(new BufferedOutputStream(file));
                                  String info= "The data is based on"+"\n";
                                  filestream.write(info);
                                  System.out.println("I wrote the first string called info");
                                  String interestdata= "INTEREST:"+" "+interest+"\n";
                                  filestream.write(interestdata);
                                  String timedata="The amortization period is:"+" "+time+"\n";
                                  filestream.write(timedata);
                                  String loandata="The money borrowed is:"+" "+moneyFormat.format(loannumber)+"\n";
                                  filestream.write(loandata);
                                  String totals= "Total of Payments Made:"+" " +moneyFormat.format(totalpayments)+"\n"+"Total Interest Paid:"+"  "+moneyFormat.format(totalinterest)+"\n";
                                  filestream.write(totals);
                                  String filestring = "PAYMENT NUMBER"+"   " + "PAYMENT" + "   " + " PRINCIPLE" + "   " + "INTEREST" +"   " + " BALANCE" + "\n";
                                  filestream.write(filestring);
                                  double loannumberkf= loannumber;
                                  System.out.println(timenumber);
                                  for (int j=1; j<=timenumber ; j++ )
                                       double principlekf=payment-loannumberkf*z;
                                       double balancef=loannumberkf-principlekf;
                                       String display ="\n"+ Integer.toString(j)+"                " + moneyFormat.format(payment)+"        "+ moneyFormat.format(principlekf)+ "     "+moneyFormat.format(loannumberkf*z)+ "     "+ moneyFormat.format(balancef)+"\n";
                                       filestream.write(display);
                                       loannumberkf=loannumberkf-principlekf;
                                  filestream.flush();
                                  file.close();
                             catch ( IOException ioException )
                                  JOptionPane.showMessageDialog (null, "File Does not exist", "Invalid File Name", JOptionPane.ERROR_MESSAGE);
                        }//end of else
                 } //end anonymous inner class
              filemenu.add(saveas);
              JMenuItem exit= new JMenuItem ("Exit");
              exit.addActionListener( new ActionListener() {
                        public void actionPerformed (ActionEvent e)
                             System.exit(0);
                   } //end anonymous inner class
              ); // end call to ActionListener
              filemenu.add(exit);
              JMenuItem summaries=new JMenuItem ("Save Summaries As");
              MenuHandler menuhandler= new MenuHandler();
              summaries.addActionListener(menuhandler);
              filemenu.add(summaries);
              //construct the second JMenu
              JMenu colorchooser=new JMenu("Color Chooser");
              JMenuItem colorchooseritem=new JMenuItem("Choose Color");
              colorchooseritem.addActionListener (new ActionListener() {
                                  public void actionPerformed(ActionEvent e)
                                       color=JColorChooser.showDialog(Mortgagecalculation.this, "Choose a Color", color);
                                       c.setBackground(color);
                                       c.repaint();
                         ); //end of registration
              colorchooser.add(colorchooseritem);
              //third menu
              JMenu service = new JMenu("Services");
              JMenuItem s1= new JMenuItem ("Display Amortization");
              JMenuItem s2= new JMenuItem ("Calender");
              service.add(s1);
              service.add(s2);
              //Create menu bar and add the two JMenu objects
              JMenuBar menubar = new JMenuBar();
              setJMenuBar(menubar);
              menubar.add(filemenu); // end of menu construction
              menubar.add(colorchooser);
              menubar.add(service);
              //set the layout manager for the JFrame
              gbLayout = new GridBagLayout();
              c.setLayout(gbLayout);
              gbConstraints = new GridBagConstraints();
              //construct table and place it on the North part of the Frame
              JLabel tablelabel=new JLabel ("The Table below displays amortization values after you press O.K. on the payments window. Payments window appears after you enter the values for rate, period and loan");
              mydefaulttable = new DefaultTableModel();
                   mydefaulttable.addColumn("PAYMENT NUMBER");
                   mydefaulttable.addColumn ("PAYMENT AMOUNT");
                   mydefaulttable.addColumn ("PRINCIPLE");
                   mydefaulttable.addColumn ("INTEREST");
                   mydefaulttable.addColumn("LOAN BALANCE");
              Box tablebox=Box.createVerticalBox();   
              mytable=new JTable(mydefaulttable);
              tablelabel.setLabelFor(mytable);
              JScrollPane myscrollpane= new JScrollPane (mytable);
              tablebox.add(tablelabel);
              tablebox.add(myscrollpane);
              //gbConstraints.weightx = 100;
              //gbConstraints.weighty = 50;
              //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.NORTH;
              addComponent(tablebox,0,0,3,1,GridBagConstraints.NORTH);
            //c.add (tablebox, BorderLayout.NORTH);
              //create center panel
              JLabel panellabel=new JLabel("Summarries");
              MyPanel panel =new MyPanel();
              panel.setSize (10, 50);
              panel.setBackground(Color.red);
              panellabel.setLabelFor(panel);
              Box panelbox=Box.createVerticalBox();
              panelbox.add(panellabel);
              panelbox.add(panel);
              //gbConstraints.weightx = 50;
              //gbConstraints.weighty = 100;
            //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.CENTER;
              addComponent(panelbox,1,1,1,1,GridBagConstraints.CENTER);
              //c.add (panelbox, BorderLayout.CENTER);
              //add time in the SOUTH part of the Frame
              Panel southpanel=new Panel();
              southpanel.setBackground(Color.magenta);
              Date time=new Date();
              String timestring=DateFormat.getDateTimeInstance().format(time);
              TextField timefield=new TextField("The Date and Time in Chicago is:"+" "+timestring, 50);
              southpanel.add(timefield);
              //gbConstraints.weightx = 100;
              //gbConstraints.weighty = 1;
              //gbConstraints.fill = GridBagConstraints.HORIZONTAL;
              gbConstraints.anchor = GridBagConstraints.SOUTH;
              addComponent(southpanel,0,2,3,1,GridBagConstraints.SOUTH);
              //c.add(southpanel, BorderLayout.SOUTH);
              //USE "BOX LAYOUT MANAGER" TO ARRANGE COMPONENTS LEFT TO RIGHT WITHIN THE SOUTH PART OF THE FRAME
              //Create a text area to output more information about the application.Place it in a box and place box EAST
              Font f=new Font("Serif", Font.ITALIC+Font.BOLD, 16);
              string="-If you would like to exit this program\n"+
              "-click on the exit menu item \n"+
                   "-if you would like to save the table as a text file \n"+
                   "-click on Save As menu item \n"+"-You can reenter new values for calculation\n"+
                   " as many times as you would like.\n"+
                   "-You can save the summaries also on a different file\n"+
                   "-Files are appended";
              JLabel infolabel= new JLabel ("Information About this Application", JLabel.RIGHT);
              JTextArea textarea=new JTextArea(25,25);
              textarea.setFont(f);
              textarea.append(string);
              infolabel.setLabelFor(textarea);
              Box box =Box.createVerticalBox();
              box.add(infolabel);
              box.add(new JScrollPane (textarea));
              //gbConstraints.weightx = 50;
              //gbConstraints.weighty = 100;
              //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.SOUTHEAST;
              addComponent(box,2,1,1,1,GridBagConstraints.SOUTHEAST);
              //c.add(box, BorderLayout.EAST);
              //Create the text fields for entering data and place them in a box WEST
              Panel panelwest = new Panel();
              //create the first panelwest and place the text fields in it
              Box box1=Box.createVerticalBox();
              JLabel rate= new JLabel ("Enter Rate", JLabel.RIGHT);
              interestfield=new JTextField ("Enter Interest here and press Enter", 15);
              rate.setLabelFor(interestfield);
              box1.add(rate);
              box1.add(interestfield);
              JLabel period=new JLabel("Enter Amortization Periods", JLabel.RIGHT);
              timenumberfield=new JTextField("Enter amortization period in months and press Enter", 15);
              period.setLabelFor(timenumberfield);
              box1.add(period);
              box1.add(timenumberfield);
              JLabel loan=new JLabel("Enter Present Value of Loan", JLabel.RIGHT);
              loanamountfield =new JTextField ("Enter amount of loan and press Enter", 15);
              loan.setLabelFor(loanamountfield);
              box1.add(loan);
              box1.add(loanamountfield);
              JLabel submit = new JLabel("Press Submit Button to Calculate", JLabel.RIGHT);
              submitbutton= new JButton("SUBMIT");
              submit.setLabelFor(submitbutton);
              box1.add(submit);
              box1.add(submitbutton);
              panelwest.add(box1);
              //Add the panel to the content pane
              //gbConstraints.weightx = 50;
              //gbConstraints.weighty = 100;
              //gbConstraints.fill = GridBagConstraints.BOTH;
              gbConstraints.anchor = GridBagConstraints.SOUTHWEST;
              addComponent(panelwest,0,1,1,1,GridBagConstraints.SOUTHWEST);
              //c.add(panelwest, BorderLayout.WEST);
              //Event handler registration for text fields and submit button
              TextFieldHandler handler=new TextFieldHandler();
              interestfield.addActionListener(handler);
              timenumberfield.addActionListener(handler);
              loanamountfield.addActionListener(handler);
              submitbutton.addActionListener(handler);
              setSize(1000, 700);   
              setVisible(true);
              System.out.println("repainting table, constructor");
              System.out.println("I finished repainting. End of ConstructGUI");
         } // END OF CONSTUCTGUI
         // addComponent() is developed here
         private void addComponent(Component com,int row,int column,int width,int height,int ancor)
              //set gridx and gridy
              gbConstraints.gridx = column;
              gbConstraints.gridy = row;
              //set gridwidth and gridheight
              gbConstraints.gridwidth = width;
              gbConstraints.gridheight = height;
              gbConstraints.anchor = ancor;
              //set constraints
              gbLayout.setConstraints(com,gbConstraints);
              c.add(com);          
         

    Quit cross-posting (in different forums) every time you have a question.
    Quit multi-posting (asking the same questions twice) when you ask a question.
    Start responding to your old questions indicating whether the answers you have been given have been helpfull or not.
    Read the tutorial before asking a question. Start with [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use GridBag Layout. Of course its the most difficult Layout Manager to master so I would recommend you use various combinations of the other layout managers to achieve your desired results.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Audigy 4 pro sound card HELL please advise!!!

    hi all,
    right i'll TRY to keep it simple!.....
    BEFORE my (recently brand new) hard dri've died and caused me all sorts of probs (and ?300) my soundcard was fine it was :
    windows 7
    audigy 4
    cubase 4
    daniel k's drivers (i think OR it was the one that came with the card)
    with this i HAD the option of acti've X driver OR creative asio (used this as was much much better)
    SINCE it died i've tried everything for days and days of hell to get this driver on, heres the symptoms:
    using the CD that came with the audigy it takes 45 mins to load and then tells me there is NO sound card fitted (tried this 3 or 4 times)..
    i physically took t?he card out (twice) and it made no difference and still didnt recognise any card fitted.
    i've had to system restore a few times to get it 'see' ANY driver.....i've also downloaded some drivers but same symptoms as above.
    using the acti've x the latency is a prob though i have adjusted it to make it work BUT am thinking this is one of the reasons my cubase freezes / crashes / and now makes crackling noise especially when using a reverb vst.
    the whole system was great B4 this and i've lost 3 or 4 days and am now at the throwing it out of the window phase.
    BEFORE it handled superior drummer as a VST and midi / audio files + reverbs all at the same time NO problem.
    the current set up is almost identical and in fact a tickle better than B4 so WHY wont it see a sound card ?when trying a different dirver?
    HELP! Si in Brighton.

    ta...yes it does.
    works (almost) fine with the acti've X driver, apart from telling me line/mic is NOT available....spent all day (again) trying to get the 3.8 daniel K pack on there.....came back with 'somethings wrong' meessage each time.
    it just baffles me that my hard dri've
    cd rom AND now (maybe) the card all ferk up at exactly the same time!
    i recorded afterwards and it was fine for hours.....
    cheers si

  • How to see the borders of a "display area" in GridBagLayout

    I would like to see the display area of a JPanel .
    I use this technique:
    panel.setBorder(new TitledBorder(new LineBorder(Color.blue, 2), "DisplayArea?"));
    //Is this correct?
    If not, how can I see the borders of a display area (as opposed to the borders of a JPanel ) of a JPanel ?
    note: I am new to Swing, so I am using the word "display area" in the context of what I read in the API for java.awt.GridBagLayout .
    Maybe there is no real concept of a "display area"?
    I am trying to get the JPanel to expand to the borders of its "display area", but I can't see what is going on. Either I am not expanding the JPanel, or the "display area" is smaller than I would think.
    Thanks.
    Edited by: rikasai on May 3, 2009 2:07 AM

    I think your basic problem lies in this "note: I am new to Swing,",
    and quite probably do not have a sufficient understanding of layoutManagers,
    in particular the one associated with JFrame.
    your problem reads as though you have a JPanel that you have sized to (e.g.) 400,200
    and added this to a JFrame, sized at (e.g.) 600,400, and you expect this to give you a
    100 blank area around the panel.
    the nature of a JFrame's default layoutManager is that if you add something to it,
    via frame.add(panel), it will be added to the default area of the frame (CENTER), and
    it will take all the available space. So, whether you specify 400,200 or 50,50 etc,
    the panel will take up all of the available space in the contentPane of the 600,400 frame.

  • How to control the maximum size of a component in a GridBagLayout

    Here is a small program that demonstrates my issue (it's originally from a big program that I couldn't attach here).
    I have a GridBagLayout with some components in it. Some of the components are JEditorPane (displaying some HTML) within JPanel and are individally scrollable.
    Here we go:
    - when I resize the main panel, every components will resize accordingly to their weight (which is here the same for all of them): fine
    - when I reduce the size of the main panel until it reaches all the preferred size of each component, the scrollPane of the main panel appears so that the user can scroll: not fine
    The behaviour I'm looking for is: when I reduce the size of the main panel, when it reaches the preferred size of the components, I would like that the JEditorPane (which are in JPanel with BorderLayout/CENTER) display their individual scrollbars so that I can see all the JEditor panes at the same time without having to scroll the main window.
    If the user continues to reduce the size of the main panel, then, at one point, display the scrollpane of the main panel.
    See what I mean? How to control this?
    Here is the code:
    @SuppressWarnings("serial")
    public final class CGridBagLayout2 extends JFrame {
         JPanel mainPanel;
         private final JScrollPane scrollPane;
         private JPanel panelize(Component component, String localization) {
              JPanel output = new JPanel(new BorderLayout());          
              output.add(component, localization);
              return output;
        public void addComponentsToMainPanel() {
              mainPanel.setLayout(new GridBagLayout());
              GridBagConstraints c = new GridBagConstraints();
              c.weightx = 1.0;
              c.fill = GridBagConstraints.BOTH;
              String TEST_BIGTEXT = "<html><body><h2>Path</h2>toto/tutu/tata/TestN<h2>Prerequisites</h2>blah blah blah blah<br/><b>blah blah</b> blah blah\nblah blah <u>blah</u> blahblah blah blah<h2>Description</h2>blah blah blah blah<br/><b>blah blah</b> blah blah\nblah blah <u>blah</u> blahblah blah blah blah\nblah blah blah <br/>lah blah blah <br/>lah blah blah blah blah blah blah blah FIN</body></html>";
              for (int index=0; index<10; index++) {
                   c.gridheight = 5; // nb Testcases for this test
                   c.anchor = GridBagConstraints.FIRST_LINE_START; // align all the components top-left aligned
                   c.gridy = index;
                   JLabel a = new JLabel("AAAAA");
                   c.gridx = 0;
                   mainPanel.add(panelize(a, BorderLayout.NORTH), c);
                   JLabel b = new JLabel("BBBBB");
                   c.gridx = 1;
                   mainPanel.add(panelize(b, BorderLayout.NORTH), c);
                   JEditorPane d = new JEditorPane("text/html", TEST_BIGTEXT);               
                   c.gridx = 2;
                   mainPanel.add(panelize(d, BorderLayout.CENTER), c);
                   JEditorPane e = new JEditorPane("text/html", TEST_BIGTEXT);               
                   c.gridx = 3;
                   mainPanel.add(panelize(e, BorderLayout.CENTER), c);
                   index++;
         public CGridBagLayout2() {
              super("GridBagLayout");
              mainPanel = new JPanel();
              addComponentsToMainPanel();
              scrollPane = new JScrollPane(mainPanel);
              setContentPane(scrollPane);
         public static void main(String[] args) {
              Frame frame;
              WindowListener exitListener;
              exitListener = new WindowAdapter() {
                   @Override
                   public void windowClosing(WindowEvent e) {
                        Window window = e.getWindow();
                        window.setVisible(false);
                        window.dispose();
                        System.exit(0);
              frame = new CGridBagLayout2();
              frame.addWindowListener(exitListener);
              frame.setPreferredSize(new Dimension(1000, 800));
              frame.pack();
              frame.setVisible(true);
    }Many thanks in advance, I'm getting crazy on this one :)

    Ok, thanks for this information, I thought I had seen this happening in the past when embedding a component in the center area of a JPanel with BorderLayout.
    Anyway, as I said I tested with JScrollPane as well and it does not change anything.
    Here is the code modified:
    @SuppressWarnings("serial")
    public final class CGridBagLayout2 extends JFrame {
         JPanel mainPanel;
         private final JScrollPane scrollPane;
         private JPanel panelize(Component component, String localization) {
              JPanel output = new JPanel(new BorderLayout());          
              output.add(component, localization);
              return output;
        public void addComponentsToMainPanel() {
              mainPanel.setLayout(new GridBagLayout());
              GridBagConstraints c = new GridBagConstraints();
              c.weightx = 1.0;
              c.fill = GridBagConstraints.BOTH;
              String TEST_BIGTEXT = "<html><body><h2>Path</h2>toto/tutu/tata/TestN<h2>Prerequisites</h2>blah blah blah blah<br/><b>blah blah</b> blah blah\nblah blah <u>blah</u> blahblah blah blah<h2>Description</h2>blah blah blah blah<br/><b>blah blah</b> blah blah\nblah blah <u>blah</u> blahblah blah blah blah\nblah blah blah <br/>lah blah blah <br/>lah blah blah blah blah blah blah blah FIN</body></html>";
              for (int index=0; index<10; index++) {
                   c.gridheight = 5; // nb Testcases for this test
                   c.anchor = GridBagConstraints.FIRST_LINE_START; // align all the components top-left aligned
                   c.gridy = index;
                   JLabel a = new JLabel("AAAAA");
                   c.gridx = 0;
                   mainPanel.add(panelize(a, BorderLayout.NORTH), c);
                   JLabel b = new JLabel("BBBBB");
                   c.gridx = 1;
                   mainPanel.add(panelize(b, BorderLayout.NORTH), c);
                   JEditorPane d = new JEditorPane("text/html", TEST_BIGTEXT);               
                   c.gridx = 2;
                   mainPanel.add(panelize(new JScrollPane(d), BorderLayout.CENTER), c);
                   JEditorPane e = new JEditorPane("text/html", TEST_BIGTEXT);               
                   c.gridx = 3;
                   mainPanel.add(panelize(new JScrollPane(e), BorderLayout.CENTER), c);
         public CGridBagLayout2() {
              super("GridBagLayout");
              mainPanel = new JPanel();
              addComponentsToMainPanel();
              scrollPane = new JScrollPane(mainPanel);
              setContentPane(scrollPane);
         public static void main(String[] args) {
              Frame frame;
              WindowListener exitListener;
              exitListener = new WindowAdapter() {
                   @Override
                   public void windowClosing(WindowEvent e) {
                        Window window = e.getWindow();
                        window.setVisible(false);
                        window.dispose();
                        System.exit(0);
              frame = new CGridBagLayout2();
              frame.addWindowListener(exitListener);
              frame.setPreferredSize(new Dimension(1000, 800));
              frame.pack();
              frame.setVisible(true);
    }Edited by: eric_gavaldo on Sep 15, 2010 2:18 PM

  • Even I cant believe this is happening again! i'm once again asking for help with my account.  Since im very sick I ask that u look into my account and read the hell verizon has put me through and assist ending the hell once and for all even if that means

    Even I cant believe this is happening again! i'm once again asking for help with my account.  Since im very sick I ask that u look into my account and read the hell verizon has put me through and assist ending the hell once and for all even if that means ending my contract, i just want the hell over. I went into my bill tonight and the mess was still there I paid $110. that's what I owe

    I guess I spoke too soon!  I really can't believe this nightmare is not over yet! My account is still wrong.  The credit that I was due totaled $63.00  I am looking at a message on my phone saying that $21.01 was credited which makes my balance $219.72.  I received a text the following day that says, I processed your credit of $30.00 and your new balance $216.73 how is that possible?  None of the late fees were credited and the amount due for my monthly charges are wrong.  Before any changes were made to my data plan back in Nov. My monthly charges were $140.00, I needed my hot spot back and i was told that the hot spot will increase my bill $10 for each phone that totals $20.  The customer rep that change my data plan at that time also gave me a credit of $20 to compensate for the increase until I had time to talk with customer service about the mix-up with my Hot spot. I originally had the hot spot, but the rep that change my plan almost a year prior told me nothing was changing except I was getting more for less money.  I explained to that rep that I need my hot spot 4 times a year...and I don't want my plan to have any changes. To verify what I'm telling u check my account and see that I called from Albany New York wanting to know where my hot spot was and I was told I didn't have the hot spot on my account since the last data change!  I lost money once again due to the verizon rep's.  so my current data plan the rep promised would increase $20 which makes my monthly charges that were $140 prior to the change $160 after the hot spot was returned to my account.  Then I was given a $12 credit per month for 12 months because of so many mistakes made to my account so with that $12 credit my monthly charges should $148 + surcharges + taxes and that's not what I see. I do know this much right now my account is in such a shambles I can hardly see the light at the end if there is an end!  I need real help!
    >> Personal information removed by Verizon Moderator to comply with the Verizon Wireless Terms of Service <<

  • 8.0.5 on redhat 6.0 HELL!

    Hi
    I have just spent a weekend trying to get the above to work. I
    will admit that I am no unix guru or oracle dba, but I do have
    5+ years tinkering in unix and 1 year with oracle.
    But this weekend has been hell. The installer is a joke and the
    procedure that has to be followed for redhat 6 is another one.
    After following all the steps I still could not get the database
    created! Numerous errors! I made it by hand using a 7.3 NT
    script with alot of tweeking.
    The plan was to see how apps server works, but I am way to
    scared to try that, probably because I still have not been able
    to start up the listner and some help the docs have been. (start
    listener this way! - and if it doesn't start??)
    I am homing oracle will take a feather out of mircosofts cap on
    how to write an installer!
    cheers
    null

    I must admit that it was a bit difficult at first but I found
    specific instructions on the web. There are 5 packages that you
    must download from redhat and a patch from Oracle.
    I have VERY limited experience with both Oracle and Unix and I
    was able to install 8.0.5 on a P120/4g in about 3 hours (after I
    found the directions). It took about 4 hours for me to distill
    the correct modifications to the init.d script in order to bring
    listener/dbms up/down correctly, but for a complete novice it
    was not as difficult as I had imagined.
    E-mail me if you want that URL.
    David Kropman (guest) wrote:
    : Hi
    : I have just spent a weekend trying to get the above to work. I
    : will admit that I am no unix guru or oracle dba, but I do have
    : 5+ years tinkering in unix and 1 year with oracle.
    : But this weekend has been hell. The installer is a joke and
    the
    : procedure that has to be followed for redhat 6 is another one.
    : After following all the steps I still could not get the
    database
    : created! Numerous errors! I made it by hand using a 7.3 NT
    : script with alot of tweeking.
    : The plan was to see how apps server works, but I am way to
    : scared to try that, probably because I still have not been
    able
    : to start up the listner and some help the docs have been.
    (start
    : listener this way! - and if it doesn't start??)
    : I am homing oracle will take a feather out of mircosofts cap
    on
    : how to write an installer!
    : cheers
    null

Maybe you are looking for

  • Link to a new site that opens within my site

    Can someone tell me how I can create a link to an external site, where the site opens up within the body of my site? Do I need a javascript for this? Thanks in advance.

  • Question on adding one function to a submenu

    hi,dear all. I added one function to a menu. my question is I can find it from the forms navigator page but why I can not find it from the initial navigation web page ?? thanks in advance.

  • Error in report program

    Hello , I am  getting following message ''In Unicode programs, the "Ó" character cannot appe 20 RELACIÓNIE(000050)'' when i am trying to call another ALV output from one layout using USER_COMMAND in French language. In english language , the program

  • Finding ALL MP3's on system and multiple drives??

    I have thousands of MP3 files however with iTunes always copying and importing files I've lost track and think I have double and even triple of the same songs scattered across 3 hard drives. My question is, how do I use the Finder to get all my MP3's

  • How disable Bex Analyser in ALV

    Hi Everybody, how can i disable the context menu function 'BEx Analyser' within my export button in ALV? I just diable under spro->NetWeaver->Application Server->WD4A->disable Java depended functions in alv. I try also the following function: lr_cl_s