Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 8th, 2008, 9:26 PM   #1
sackarias
Programmer
 
sackarias's Avatar
 
Join Date: Jan 2006
Posts: 58
Rep Power: 3 sackarias is on a distinguished road
simple GUI assistance

Hello. I have 2 questions about why my GUI seems to be acting up.

1) I have a few buttons that I'm adding to the south of a BorderLayout. When I run the program only the last button I add shows and it consumes the entire south portion. How could I center all the buttons in the south portion so that A) each button is the size equal to the amount of text representing the button and B) are centered in the southern panel so that all 3 buttons together do not consume the entire southern panel.

//this code comes from inside the constructor of my class that extends JFrame
add(jbtQuit, BorderLayout.SOUTH);
        add(jbtNew, BorderLayout.SOUTH);
        add(jbtSubmit, BorderLayout.SOUTH);

2) In the center of the aforementioned class I have a panel. The panel is designated as a separate class extending JPanel. I set this panel's layout to a grid layout, 8x2, for 8 labels and text fields. Anyways, the grid layout is not making sense, or not doing what the book I'm referencing seems to explain. Seeing that this grid layout has 2 columns, I'll refer to each as column 1 for the left or 2 for the right column. Column 1 is all labels, designating their respective text fields in column 2. What is happening is this. The labels in column 1 seem to be "left" justified, and the text fields of column 2 are "center" or "right justified (right if I stretch the frame to a wider size). I would like so that the labels of column 1 are a few pixels away from their respective text fields, rather then basically the width of the frame. It doesn't look very cool to me to have this gigantic space between these types of components. The constructor for the border layout has hor. and vert. gap but they don't seem to do anything?

This is the class I'm adding to the BorderLayout center of another class. It's nothing special, but it's causing me a headache : )

public class Customer extends JPanel{
    
    JLabel jlblCustId = new JLabel("Customer ID");
    JLabel jlblFirst = new JLabel("First Name");
    JLabel jlblLast = new JLabel("Last Name");
    JLabel jlblCity = new JLabel("City");
    JLabel jlblZip = new JLabel("Zip Code");
    JTextField jtfCustId = new JTextField(8);
    JTextField jtfFirst = new JTextField(8);
    JTextField jtfLast = new JTextField(8);
    JTextField jtfCity = new JTextField(8);
    JTextField jtfZip = new JTextField(8);

    Customer()
    {
        setLayout(new GridLayout(8,2));  //had hgap and vgap in there but did nothing
        add(jlblCustId);
        add(jtfCustId);
        add(jlblFirst);
        add(jtfFirst);
        add(jlblLast);
        add(jtfLast);
        add(jlblCity);
        add(jtfCity);
        add(jlblZip);
        add(jtfZip);        
    }
}
If I missed any information that would help someone figure this out just let me know, I'll add more code and provide whatever information necessary.

Thanks a ton.

-Zack
sackarias is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dos based Gui Damienallen C 12 Oct 1st, 2007 10:09 AM
Which is easier for making a GUI program? 357mag Java 6 Jul 29th, 2007 5:08 PM
Programming a simple GUI bulio Other Scripting Languages 12 Jun 9th, 2007 2:29 PM
a simple linking loader for SIC/XE programmingnoob C++ 3 Feb 26th, 2006 11:35 PM
Simple Function Questions meverha1 C++ 16 Sep 12th, 2005 1:25 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC