Make a JFrame looks like a JDialogTag(s): Swing
Make a JFrame unresizable and with no min/max button. The difference with JDialog is that a JFrame is shown on the taskbar (win) while a JDialog is not.
import java.awt.Dimension; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JRootPane; import javax.swing.SwingUtilities; public class JFrameWithNoMinMax extends JFrame { public JFrameWithNoMinMax() { createAndShowUI(); } private void createAndShowUI(){ setTitle("This JFRAME looks like JDialog"); setSize(new Dimension(500,100)); setUndecorated(true); setResizable(false); getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); //addWindowListener(new WindowAdapter(){ // public void windowClosing(WindowEvent e) { // System.out.println("Window Closing"); // System.exit(0); // } //}); } public static void main(String[] args){ SwingUtilities.invokeLater(new Runnable(){ public void run(){ new JFrameWithNoMinMax().setVisible(true); } }); } }
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com