import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
public class FullScreenWithButton extends JFrame {
public static void main(String[] args) {
final FullScreenWithButton a = new FullScreenWithButton();
JButton b = new JButton("Klick mich");
a.add(b);
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JDialog jd = new JDialog();
JButton jb = new JButton("OK");
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jd.dispose();
}
});
jd.add(jb);
jd.setModal(true);
jd.setSize(100, 100);
jd.setLocationRelativeTo(a);
jd.setVisible(true);
}
});
a.setUndecorated(true);
a.setSize(500, 500);
a.setExtendedState(JFrame.MAXIMIZED_BOTH);
a.setVisible(true);
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}