Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: extending JDialog not working in exact size

  1. #1
    Junior Member
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts

    Default extending JDialog not working in exact size

    I have created a class that extends JDialog and i just want to show this JDialog without any parent frames ...The JDialog is displaying but in in the exact size that i have mentioned..
    Following is the code...kindly tell me what is wrong with the code..

    import java.awt.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    public class DialogueTest extends JDialog {

    public DialogueTest() {

    JPanel panel = new JPanel();
    panel.setPreferredSize(new Dimension(0, 20));
    getContentPane().add(panel, BorderLayout.NORTH);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));

    JLabel lblNewLabel = new JLabel("PoolRunner");

    JPanel panel_1 = new JPanel();
    getContentPane().add(panel_1, BorderLayout.CENTER);
    panel_1.setLayout(new BorderLayout(0, 0));

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    panel_1.add(tabbedPane, BorderLayout.CENTER);

    JPanel panel_2 = new JPanel();
    tabbedPane.addTab("New tab", null, panel_2, null);

    this.setSize(1000, 1000);


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


    --- Update ---

    I got the solution...
    Following codes were missing..
    panel.setPreferredSize(new Dimension(500, 20));
    tabbedPane.setPreferredSize(new Dimension(500, 300));

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: extending JDialog not working in exact size

    Please post your code correctly.

Similar Threads

  1. JDialog not working properly
    By agarta in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 24th, 2013, 10:46 PM
  2. Jpanel preffered size exceed the nactual screen size
    By manish.ctae@gmail.com in forum AWT / Java Swing
    Replies: 2
    Last Post: October 31st, 2012, 01:29 AM
  3. Replies: 1
    Last Post: April 30th, 2012, 08:16 AM
  4. How to get Present working Directory(Exact path) in java..?
    By smilyface in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 8th, 2012, 03:42 PM

Tags for this Thread