Advertisement
sergAccount

Untitled

Sep 25th, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 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.         //
  44.         JPanel p = new JPanel();
  45.         //JButton button1 = new JButton("Кнопка1");
  46.         //p.add(button1);
  47.         JButton[] buttons = createButtons();
  48.         for(int i = 0; i < buttons.length; i++){
  49.             JButton button = buttons[i];
  50.             p.add(button);
  51.         }
  52.         return p;
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement