Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JDialog.setMaximized(true)

Posted on 2004-09-02
7
Medium Priority
?
1,920 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

636 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