Results 1 to 5 of 5

Thread: Java GUI

  1. #1
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts

    Java GUI

    This is becoming increasingly annoying by the minute. I want two columns, one with JLabels and one with JTextFields, they go in columns fine, but i can't resize them and they're smack bang in the middle. I want the left column to be on the left side and the JTextFields to the right of the left hand column but all parallel to each other.

    This is the current code in the current method doing it:

    Code:
        public void createNewInvoice() {
            frame.getContentPane().removeAll();
            
            String helpText = "\n1. Enter first name"
                              + "\n\n2. Enter last name"
                              + "\n\n3. Enter address"
                              + "\n\n4. Ensure correct information has been entered"
                              + "\n\n5. Click \"Create Invoice\"";
            
            JTextArea help = new JTextArea(helpText, 12, 30);
            help.setFont(new Font("Arial", Font.PLAIN, 10));
            help.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Help"));
            help.setLineWrap(true);
            help.setWrapStyleWord(true);
            help.setColumns(12);
            help.setEditable(false);
            
            /***** LEFT COLUMN ******/
            JPanel text = new JPanel(new GridLayout(0,1));
            JLabel firstNameText = new JLabel("First Name:");
            JLabel lastNameText = new JLabel("Last Name:");
            JLabel addressLineOne = new JLabel("House Name/Number:");
            JLabel addressLineTwo = new JLabel("Street Name:");
            JLabel addressLineThree = new JLabel("County:");
            JLabel addressLineFour = new JLabel("Country:");
            JLabel postCodeText = new JLabel("Post Code:");
            text.add(firstNameText);
            text.add(lastNameText);
            text.add(addressLineOne);
            text.add(addressLineTwo);
            text.add(addressLineThree);
            text.add(addressLineFour);
            text.add(postCodeText);
            /***********************/
            
            JPanel input = new JPanel(new GridLayout(0,1));
            JTextField firstName = new JTextField();
            JTextField lastName = new JTextField();
            JTextField addressOne = new JTextField();
            JTextField addressTwo = new JTextField();
            JTextField addressThree = new JTextField();
            JTextField addressFour = new JTextField();
            JTextField postCode = new JTextField();
            input.add(firstName);
            input.add(lastName);
            input.add(addressOne);
            input.add(addressTwo);
            input.add(addressThree);
            input.add(addressFour);
            input.add(postCode);
            
            JPanel main = new JPanel(new FlowLayout());
            main.add(text);
            main.add(input);
    
            frame.getContentPane().add(main, BorderLayout.CENTER);
            frame.getContentPane().add(help, BorderLayout.WEST);
            
            frame.getContentPane().invalidate();
            frame.getContentPane().validate();
            frame.getContentPane().repaint();
        }
    *growls*

    EDIT: Screeny



    EDIT: Think i got it working now



    Yup, i think that's it, just a few more configurations and i'm done
    Last edited by Kezzer; 04-05-2005 at 12:31 PM.

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    Nice it looks good so far. You are encouraging me to post screenies of my app as well. I did borrow some code from the demos that come with the JDK and modified a decent amount to make it work better with my app...hehe who needs to reinvent the wheel?!

    Your app looks like it is for a commercial purpose though while mine is not. Mine will be closed source but free to use for a while until later on when I will open it up. Problem is I dunno who will be interested!

  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Well it looks a lot better and today i'm really chuffed as THE main feature of the app now works, it's not completely done but i couldn't get my head around it. I'll post screenies of each page when i get it done

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    So what does this app do if you dont mind my asking?

  5. #5
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    It quotes a customer on a box, you can add/edit/delete boxes from an invoice and save them to file etc. It's quite advanced, requires quite a bit of OOP too. I've got about 20 classes so far, each with an average of 200 LOC

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Best book to learn JAVA 2?
    By Taz in forum Software
    Replies: 16
    Last Post: 27-08-2005, 08:54 PM
  2. Java constructor question
    By suryad in forum Software
    Replies: 9
    Last Post: 03-05-2005, 08:23 AM
  3. Java Linux
    By Raz316 in forum Software
    Replies: 8
    Last Post: 06-04-2005, 09:35 AM
  4. Potential HUGE source of free Java games / apps
    By PriestJPN in forum Smartphones and Tablets
    Replies: 4
    Last Post: 03-11-2004, 01:59 AM
  5. Java vs .NET
    By DaBeeeenster in forum Software
    Replies: 2
    Last Post: 11-09-2003, 02:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •