Advertisement
sergAccount

Untitled

Sep 18th, 2016
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package app2;
  7.  
  8. //import static app2.App2.createPanel;
  9. import javax.swing.JButton;
  10. import javax.swing.JFrame;
  11. import javax.swing.JPanel;
  12.  
  13. /**
  14.  *
  15.  * @author Student1
  16.  */
  17. public class Okno extends JFrame {
  18.  
  19.     public Okno() {
  20.  
  21.         setTitle("Калькулятор");
  22.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  23.         getContentPane().add(createPanel());
  24.         setBounds(0, 0, 800, 600);
  25.         setVisible(true);
  26.     }
  27.    
  28.     public static JButton[] createButtons(){
  29.        
  30.         JButton[] array = new JButton[10];  
  31.         //
  32.         //fori + tab
  33.         for(int i = 0; i < array.length; i++){
  34.             String title = "" + i;
  35.             JButton button = new JButton(title);            
  36.            
  37.             array[i] = button;
  38.         }
  39.         return array;
  40.     }
  41.    
  42.     public static JPanel createPanel() {
  43.         JPanel p = new JPanel();
  44.  
  45.         //JButton button1 = new JButton("Кнопка1");
  46.         //p.add(button1);
  47.  
  48.         JButton[] buttons = createButtons();
  49.         for(int i = 0; i < buttons.length; i++){
  50.             JButton button = buttons[i];
  51.             p.add(button);
  52.         }
  53.         return p;
  54.     }
  55. }
  56.  
  57. //alt+shift+F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement