Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package alex.lesson5;
- import javax.swing.*;
- import java.awt.*;
- import java.util.ArrayList;
- public class Main {
- public static String[] functions = {
- "+", "-", "*", "/",
- "a", "b", "c", "d",
- "e", "f", "g", " "
- };
- public static String[] digits = {
- "1", "2", "3", "4",
- "5", "6", "7", "8",
- "9", "0", ".", " "
- };
- public static void main(String[] args) {
- JFrame frame = new JFrame();
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.setBounds(100, 100, 385, 240);
- frame.setLayout(null);
- // ArrayList<JButton> digits = new ArrayList<JButton>();
- Container container = frame.getContentPane();
- JTextField field = new JTextField();
- field.setBounds(5, 5, 365, 30);
- container.add(field);
- for ( int j = 0; j < 4; j++) {
- for (int i = 0; i < 3; i++) {
- //String str = Integer.toString(i + 1 + j * 3);
- String str = digits[i + j * 3];
- JButton button = new JButton(str);
- button.setBounds(5 + i * 60, 45 + j * 40, 50, 30);
- container.add(button);
- }
- }
- for ( int j = 0; j < 4; j++) {
- for (int i = 0; i < 3; i++) {
- String str = functions[i + j * 3];
- JButton button = new JButton(str);
- button.setBounds(200 + i * 60, 45 + j * 40, 50, 30);
- container.add(button);
- }
- }
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement