Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package app2;
- //import static app2.App2.createPanel;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- /**
- *
- * @author Student1
- */
- public class Okno extends JFrame {
- public Okno() {
- setTitle("Калькулятор");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- getContentPane().add(createPanel());
- setBounds(0, 0, 800, 600);
- setVisible(true);
- }
- public static JButton[] createButtons(){
- JButton[] array = new JButton[10];
- //
- //fori + tab
- for(int i = 0; i < array.length; i++){
- String title = "" + i;
- JButton button = new JButton(title);
- array[i] = button;
- }
- return array;
- }
- public static JPanel createPanel() {
- JPanel p = new JPanel();
- //JButton button1 = new JButton("Кнопка1");
- //p.add(button1);
- JButton[] buttons = createButtons();
- for(int i = 0; i < buttons.length; i++){
- JButton button = buttons[i];
- p.add(button);
- }
- return p;
- }
- }
- //alt+shift+F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement