The Artima Developer Community
Sponsored Link

Java Answers Forum
Problem with Layout

1 reply on 1 page. Most recent reply: Jul 2, 2002 12:38 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jacques

Posts: 6
Nickname: pichard
Registered: Jun, 2002

Problem with Layout Posted: Jul 2, 2002 6:59 AM
Reply to this message Reply
Advertisement
I want to create a JPanel with only one JButton wich would be situated on the top of the panel. This JButton's width would be the same as the JPanel and his height would be the half of the JPanel's one.

Hey Hey What Can I Do
and with wich Layout Manager ?


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Problem with Layout Posted: Jul 2, 2002 12:38 PM
Reply to this message Reply

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

public class PanelDemo{
public PanelDemo(){
init();
}

public static void main(String[]args){
new PanelDemo();
}

public void init(){
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(100,300));
JButton button = new JButton("Demo");
button.setPreferredSize(new Dimension(100,150));
panel.add(button);
JFrame frame = new JFrame("Demo");
frame.getContentPane().add(panel,BorderLayout.NORTH);
frame.pack();
frame.setLocationRelativeTo(null);
frame.show();
}
}

Flat View: This topic has 1 reply on 1 page
Topic: SMTP and APPLETS Previous Topic   Next Topic Topic: Needing an analogy

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use