Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default School Project - Help with JTabbedPane Layout/Formatting of one of the Tabs

    I am new to JAVA, but long time programmer C#, Basic, Pascal.

    Anyway, I am working on a class project with 8 tabs and each tab does something different. The one I am having problems with is a Calculator/Converter of sorts.
    It is supposed to look like this one. I am finding the programming part to be fairly simple, just figuring out the layout is very daunting.

    I think I need to add another panel or figure out how to split the one I have into north and south. There are eventually going to be a few buttons on the bottom.

    School Project - Help with JTabbedPane Layout/Formatting of one of the Tabs-sample1.jpg

    However instead it looks like this:

    School Project - Help with JTabbedPane Layout/Formatting of one of the Tabs-project2.jpg

    I know about GridLayout an tried to do it as 2,5 (two rows, 5 columns):

    School Project - Help with JTabbedPane Layout/Formatting of one of the Tabs-project3.jpg

    My TabbedPane looks like

    Java Code:
    setlCalc(new LengthCalc());
            jp4.setLayout(new GridLayout(2,5));
            jp4.add(getlCalc().getLblMm());
            jp4.add(getlCalc().getLblMeters());
            jp4.add(getlCalc().getLblYards());
            jp4.add(getlCalc().getLblFeet());
            jp4.add(getlCalc().getLblInches());
            jp4.add(getlCalc().getMm());
            jp4.add(getlCalc().getMeters());
            jp4.add(getlCalc().getYards());
            jp4.add(getlCalc().getFeet());
            jp4.add(getlCalc().getInches());
    My lenthCalc file:

    Java Code:
    public class LengthCalc {
    	private JTextField mm = new JTextField(5), meters = new JTextField(5), yards = new JTextField(5), feet = new JTextField(5), inches = new JTextField(5);
    	private JButton convertLength, exitButton;
    	private JLabel lblMm = new JLabel ("Millimeters"), lblMeters = new JLabel ("Meters"), lblYards = new JLabel ("Yards"), lblFeet = new JLabel ("Feet"), lblInches = new JLabel ("Inches") ;
    	
    	public LengthCalc(){
    	
    		
    		
    		
    	}
    I can attach the complete code if it helps.
    Last edited by CarlosSpicyWeiner; 12-12-2012 at 05:30 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: School Project - Help with JTabbedPane Layout/Formatting of one of the Tabs

    Moved from New to Java.

    This Tutorial Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing) should help you to pick a suitable layout. Don't lose sight of the fact that you can nest containers, each with their own layout manager, in an outer container that agan, has its own layout manager.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Custom JTabbedPane layout policy
    By Leanne182x in forum AWT / Swing
    Replies: 0
    Last Post: 02-15-2011, 12:53 PM
  2. How to close all tabs in JTabbedPane?
    By LeonLanford in forum AWT / Swing
    Replies: 8
    Last Post: 06-28-2010, 06:05 PM
  3. Arrangement of tabs in JTabbedPane
    By swapnilnawale in forum AWT / Swing
    Replies: 0
    Last Post: 03-20-2009, 08:27 PM
  4. Adding Tabs to JTabbedPane
    By blackstone in forum AWT / Swing
    Replies: 2
    Last Post: 11-14-2007, 04:15 PM
  5. resize tabs in jtabbedpane
    By osval in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 04:02 AM

Posting Permissions

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