Results 1 to 3 of 3
  1. #1
    vargihate is offline Member
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    Default Working with Labels on Panels.

    Hi, I’m new here and I have 2 questions.

    1) I have added some labels into a panel and by default they all align in the center of the screen. How do I align them all to the left?
    I have tried using the following but nothing works:

    label = new JLabel(“text”, SwingConstants.LEFT);
    and
    label.setVerticalTextPosition(JLabel.LEFT);
    label.setHorizontalTextPosition(JLabel.LEFT);


    2) I have one panel that contains 2 buttons and works like a main menu.
    If the user clicks on a button a new panel must appear BELOW the panel of the main menu (I have lots of space below). However, the panel appears behind the main menu and therefore cannon be seen unless I set the visibility of the main menu to false.
    Anyone knows how to show the panel below the first one? (so that I will always have the main menu visible)

    Thanks,
    Samantha!

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    The API also makes a note of the WEST and EAST attributes, maybe this will be the answer to your first question?
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  3. #3
    rpwtdj's Avatar
    rpwtdj is offline Member
    Join Date
    Dec 2007
    Posts
    15
    Rep Power
    0

    Default

    1. You need to add a layout manager to your panel first.
    Java Code:
    setLayout(new BorderLayout());
    and then
    Java Code:
    add(yourLabel,BorderLayout.WEST);
    I think this can apply.

    2. You can use 'javax.swing.JSplitPane' to implement your app.

Similar Threads

  1. images, panels and applets
    By jamesfrize in forum Java Applets
    Replies: 3
    Last Post: 03-20-2008, 04:35 PM
  2. Buttons to show new panels
    By Lehane_9 in forum AWT / Swing
    Replies: 1
    Last Post: 03-06-2008, 04:22 PM
  3. Aligning Labels
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-02-2008, 06:26 PM
  4. JMenu calling another Forms/Panels
    By plodos in forum New To Java
    Replies: 2
    Last Post: 12-10-2007, 08:02 AM
  5. Need a tutorial for Studying about Panels
    By ramachandran in forum New To Java
    Replies: 1
    Last Post: 10-25-2007, 09:05 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
  •