Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. package division;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import static javax.swing.JFrame.EXIT_ON_CLOSE;
  6. public class DIVISION extends JFrame {
  7.  
  8. int hor,vert,ma,mb;
  9. public DIVISION() {
  10. initComponents();
  11. }
  12.  
  13. private void initComponents() {
  14. Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
  15. vert = sSize.height;
  16. hor = sSize.width;
  17. //Setings of window//
  18. setSize(hor,vert);
  19. setResizable(false);
  20. setUndecorated(true);
  21. setDefaultCloseOperation(EXIT_ON_CLOSE);
  22. //----------------//
  23.  
  24. //Setings of buttons//
  25. ma=(hor/4);//height//
  26. mb=(vert/10);//width//
  27. //------------------//
  28.  
  29. JPanel Menu = new JPanel();
  30. Menu.setLayout(null);Menu.setBackground(Color.red);
  31. JButton MBack = new JButton("Назад");
  32. MBack.setSize(ma, mb);
  33. MBack.setLocation((hor/2)-(ma/2),300);
  34. MBack.addActionListener(new ActionListener() {
  35. public void actionPerformed(ActionEvent evt) {
  36. MBackActionPerformed(evt);
  37. }
  38. });
  39. JButton MSettings = new JButton("Настройки");
  40. MSettings.setSize(ma, mb);
  41. MSettings.setLocation((hor/2)-(ma/2),400);
  42. MSettings.addActionListener(new ActionListener() {
  43. public void actionPerformed(ActionEvent evt) {
  44. MSettingsActionPerformed(evt);
  45. }
  46. });
  47. JButton MExit = new JButton("Выход");
  48. MExit.setSize(ma, mb);
  49. MExit.setLocation((hor/2)-(ma/2),500);
  50. MExit.addActionListener(new ActionListener() {
  51. public void actionPerformed(ActionEvent evt) {
  52. MExitActionPerformed(evt);
  53. }
  54. });
  55. Menu.add(MBack);Menu.add(MSettings);Menu.add(MExit);
  56.  
  57. JPanel SettingsMenu = new JPanel();
  58. JButton SMBack = new JButton("Назад");
  59. SMBack.setSize(ma, mb);
  60. SMBack.setLocation((hor/2)-(ma/2),300);
  61. SMBack.addActionListener(new ActionListener() {
  62. public void actionPerformed(ActionEvent evt) {
  63. SMBackActionPerformed(evt);
  64. }
  65. });
  66. SettingsMenu.add(SMBack);
  67.  
  68. setContentPane(Menu);
  69. SettingsMenu.setVisible(false);
  70.  
  71. }
  72.  
  73. private void MBackActionPerformed(ActionEvent evt) {
  74. //
  75. }
  76.  
  77. private void MSettingsActionPerformed(ActionEvent evt) {
  78. Menu.setVisible(false);
  79. SettingsMenu.setVisible(true);
  80. }
  81.  
  82. private void MExitActionPerformed(ActionEvent evt) {
  83. System.exit(0);
  84. }
  85.  
  86. private void SMBackActionPerformed(ActionEvent evt) {
  87. SettingsMenu.setVisible(false);
  88. Menu.setVisible(true);
  89. }
  90.  
  91. public static void main(String args[]) {
  92. java.awt.EventQueue.invokeLater(new Runnable() {
  93. public void run() {
  94. new DIVISION().setVisible(true);
  95. }
  96. });
  97. }
  98.  
  99. private JPanel Menu;
  100. private JButton MExit;
  101. private JButton MBack;
  102. private JButton MSettings;
  103. private JButton SMBack;
  104. private JPanel SettingsMenu;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement