Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2007

Tip: Looking for answers? Try searching our database.

Mixing absolute positioning with BorderLayout

Thread view: 
Jeff Higgins - 20 Jul 2007 01:14 GMT
Hi,
 I'd like construct a JFrame with two JPanels,
one using no LayoutManager, as shown below.

When I construct my JFrame with the NORTH JPanel
having no LayoutManager, I'm not able to see my JLabel.

How can I show my JLabel with this arrangement.

Thanks for your help.
Jeff Higgins

import java.awt.*;
import javax.swing.*;

public class LayoutTest
{
 LayoutTest() {
   JFrame frame = new JFrame("LayoutTest");
   JPanel displayPanel = new JPanel();
   JPanel controlPanel = new JPanel(new BorderLayout());

   // comment following - label is shown
   displayPanel.setLayout(null);

   JLabel label = new JLabel("Label");
   Dimension d = label.getPreferredSize();
   label.setBounds(75, 75, d.width, d.height);
   displayPanel.add(label);

   frame.setSize(200, 200);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.add(displayPanel, BorderLayout.NORTH);
   frame.add(controlPanel, BorderLayout.SOUTH);
   frame.setVisible(true);
 }

 public static void main(String[] args)
 {
   @SuppressWarnings("unused")
   LayoutTest test = new LayoutTest();
 }
}
Michael Dunn - 20 Jul 2007 02:35 GMT
> Hi,
>  I'd like construct a JFrame with two JPanels,
[quoted text clipped - 4 lines]
>
> How can I show my JLabel with this arrangement.
<snip code>

   displayPanel.setLayout(null);
   displayPanel.setPreferredSize(new Dimension(200,100));
Jeff Higgins - 20 Jul 2007 02:49 GMT
>> Hi,
>>  I'd like construct a JFrame with two JPanels,
[quoted text clipped - 10 lines]
>
:-) Great! Thanks very much.
JH


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.