?
Solved

JDialog.setMaximized(true)

Posted on 2004-09-02
7
Medium Priority
?
1,880 Views
Last Modified: 2012-05-05
How can I programatically maximize a JDialog? I don't see any setMaximized(true) that I can use.
0
Comment
Question by:r0ckteacher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11968910
not sure if dialogs can be maximised.
0
 
LVL 3

Expert Comment

by:CI-Ia0s
ID: 11969400
Interesting... You can maximize them but you can't minimize them...
0
 
LVL 3

Expert Comment

by:CI-Ia0s
ID: 11969412
I suppose if you could find out the size of the screen you could just set it to be that big... I don't know think there's any kind of "set maximized" property, though. *looks at API again. Not that I can see, at least... Perhaps through a listener... but again, I don't see any way to actually do it...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:armoghan
ID: 11970336
Frame can be iconfied using
frame1.setState(Frame.ICONIFIED);
but could not see anything in JDialog
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 11970514
No, you can not iconise (minimise) a dialog, because it can not have an icon on the task bar below.
Yes, you can maximise a dialog, using the screen size or the (parent) application size.

Simply get that size and setBounds() it.
This question was asked several times before in EE.
;JOOP!
0
 
LVL 37

Accepted Solution

by:
zzynx earned 150 total points
ID: 11970949
/*
 * MaxDialogDemo.java
 *
 */

import java.awt.*;
import javax.swing.*;
/**
 *
 * @author  zzynx
 */
public class MaxDialogDemo extends javax.swing.JPanel {

    JDialog parentDialog = null;
   
    public MaxDialogDemo(JDialog parent) {
        parentDialog = parent;
        initComponents();
    }
   
    private void initComponents() {
        centerPanel = new javax.swing.JPanel();
        southPanel = new javax.swing.JPanel();
        buttonPanel = new javax.swing.JPanel();
        maxButton = new javax.swing.JButton();
        standardButton = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        add(centerPanel, java.awt.BorderLayout.CENTER);

        maxButton.setText("Maximize");
        maxButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                maxButtonActionPerformed(evt);
            }
        });

        buttonPanel.add(maxButton);

        standardButton.setText("Back to normal");
        standardButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                standardButtonActionPerformed(evt);
            }
        });

        buttonPanel.add(standardButton);

        southPanel.add(buttonPanel);

        add(southPanel, java.awt.BorderLayout.SOUTH);

    }

    private void standardButtonActionPerformed(java.awt.event.ActionEvent evt) {
        parentDialog.hide();
        parentDialog.setSize(600,400);
        parentDialog.setLocationRelativeTo(null);
        parentDialog.show();
    }

    private void maxButtonActionPerformed(java.awt.event.ActionEvent evt) {
        parentDialog.hide();
        parentDialog.setLocation(0,0);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        parentDialog.setSize(screenSize.width, screenSize.height);
        parentDialog.show();
    }
   
   
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JPanel centerPanel;
    private javax.swing.JButton maxButton;
    private javax.swing.JPanel southPanel;
    private javax.swing.JButton standardButton;

   
    static public void main(String[] args) {
      JFrame x = new JFrame("Maximized Framed");
      x.setLocationRelativeTo(null);
      x.setExtendedState(Frame.MAXIMIZED_BOTH);
      x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
      x.setTitle("Maximize Dialog Demo");
      x.setSize(300, 300);
      x.setVisible(true);
     
      JDialog dlg = new JDialog(x, "Demo dialog", true);
      dlg.getContentPane().setLayout(new BorderLayout());
      dlg.getContentPane().add(new MaxDialogDemo(dlg), BorderLayout.CENTER);
      dlg.pack();
     
      dlg.setSize(600,400);
      dlg.setLocationRelativeTo(null); // center
      dlg.show();
    }
}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12003766
Thanks for accepting.

PS. Can you tell me what kind of answer would have deserved an A grade in your opinion?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question