Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package freetts;
- public class FreeTTS {
- public static void main(String[] args) {
- new FormTTS().setVisible(true);
- }
- }
- import java.awt.GraphicsDevice;
- import java.awt.GraphicsEnvironment;
- import java.awt.GridBagLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.SwingUtilities;
- public class FormTTS extends JFrame {
- private boolean isFullScreen = false;
- private JButton button;
- public FormTTS() {
- initComponents();
- initFullScreen();
- }
- private void initComponents() {
- setLayout(new GridBagLayout());
- button = new JButton(
- "I'm a smallbutton in a Huge Frame, what the heck?!");
- add(button);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setLocationRelativeTo(null);
- }
- private void initFullScreen() {
- GraphicsEnvironment env = GraphicsEnvironment
- .getLocalGraphicsEnvironment();
- GraphicsDevice device = env.getDefaultScreenDevice();
- isFullScreen = device.isFullScreenSupported();
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setUndecorated(isFullScreen);
- setResizable(!isFullScreen);
- if (isFullScreen) {
- // Full-screen mode
- device.setFullScreenWindow(this);
- validate();
- } else {
- // Windowed mode
- this.pack();
- this.setExtendedState(MAXIMIZED_BOTH);
- this.setVisible(true);
- }
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- new FormTTS().setVisible(true);
- }
- });
- }
- }
- FormTTS ftts = new FormTTS();
- GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- gd.setFullScreenWindow(ftts);
- ftts.setUndecorated(true);
- ftts.setVisible(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement