Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. package freetts;
  2.  
  3. public class FreeTTS {
  4.  
  5. public static void main(String[] args) {
  6.  
  7.  
  8. new FormTTS().setVisible(true);
  9.  
  10.  
  11. }
  12. }
  13.  
  14. import java.awt.GraphicsDevice;
  15. import java.awt.GraphicsEnvironment;
  16. import java.awt.GridBagLayout;
  17. import javax.swing.JButton;
  18. import javax.swing.JFrame;
  19. import javax.swing.SwingUtilities;
  20.  
  21. public class FormTTS extends JFrame {
  22. private boolean isFullScreen = false;
  23. private JButton button;
  24.  
  25. public FormTTS() {
  26. initComponents();
  27. initFullScreen();
  28. }
  29.  
  30. private void initComponents() {
  31. setLayout(new GridBagLayout());
  32. button = new JButton(
  33. "I'm a smallbutton in a Huge Frame, what the heck?!");
  34. add(button);
  35.  
  36. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  37. setLocationRelativeTo(null);
  38. }
  39.  
  40. private void initFullScreen() {
  41. GraphicsEnvironment env = GraphicsEnvironment
  42. .getLocalGraphicsEnvironment();
  43. GraphicsDevice device = env.getDefaultScreenDevice();
  44. isFullScreen = device.isFullScreenSupported();
  45. setDefaultCloseOperation(EXIT_ON_CLOSE);
  46. setUndecorated(isFullScreen);
  47. setResizable(!isFullScreen);
  48. if (isFullScreen) {
  49. // Full-screen mode
  50. device.setFullScreenWindow(this);
  51. validate();
  52. } else {
  53. // Windowed mode
  54. this.pack();
  55. this.setExtendedState(MAXIMIZED_BOTH);
  56. this.setVisible(true);
  57. }
  58. }
  59.  
  60. public static void main(String[] args) {
  61. SwingUtilities.invokeLater(new Runnable() {
  62. public void run() {
  63. new FormTTS().setVisible(true);
  64. }
  65. });
  66. }
  67. }
  68.  
  69. FormTTS ftts = new FormTTS();
  70.  
  71. GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  72. gd.setFullScreenWindow(ftts);
  73.  
  74. ftts.setUndecorated(true);
  75. ftts.setVisible(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement