Files
openide/platform/platform-tests/testSrc/com/intellij/ui/CustomDialogTest.java
Vladimir Krivosheev 57764d700b mark classes final
GitOrigin-RevId: 6414b6f2119c82c7567987dd30b35cab5491d9e2
2022-12-30 06:58:01 +00:00

46 lines
1.5 KiB
Java

// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
public final class CustomDialogTest {
public static void main(String[] args) {
final JFrame frame = new JFrame("Custom Dialog Test");
frame.setLocation(0, 0);
frame.setSize(800, 600);
frame.setVisible(true);
final JDialog dialog = new JDialog(frame, true);
dialog.setSize(400, 200);
dialog.setUndecorated(true);
Container contentPane = dialog.getContentPane();
contentPane.setLayout(new BorderLayout());
JButton button = new JButton("Minimize");
button.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
frame.setExtendedState(JFrame.ICONIFIED);
}
}
);
contentPane.add(button, BorderLayout.CENTER);
dialog.setVisible(true);
frame.addWindowStateListener(
new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
if (e.getOldState() == JFrame.ICONIFIED && (e.getNewState() == JFrame.NORMAL || e.getNewState() == JFrame.MAXIMIZED_BOTH)) {
dialog.setVisible(true);
}
}
}
);
}
}