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);
- //button.setActionCommand("");
- array[i] = button;
- }
- //
- //
- return array;
- }
- //
- public static JPanel createPanel() {
- //
- AppActionListener listener = new AppActionListener();
- JPanel p = new JPanel();
- JButton[] buttons = createButtons();
- for(int i = 0; i < buttons.length; i++){
- JButton button = buttons[i];
- button.addActionListener(listener);
- p.add(button);
- }
- // добавляем кнопку Выход
- JButton exitButton = new JButton("Выход");
- exitButton.setActionCommand(AppCommands.EXIT_COMMAND);
- exitButton.addActionListener(listener);
- p.add(exitButton);
- return p;
- }
- }
- //alt+shift+F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement