Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.Event;
- import java.awt.GridLayout;
- import javax.swing.*;
- public class main {
- static JFrame window;
- static JPanel holder;
- static JButton one;
- static JButton two;
- static JButton three;
- static JButton four;
- static JButton five;
- static JButton six;
- static JButton seven;
- static JButton eight;
- static JButton nine;
- static JButton zero;
- static JButton equals;
- static JTextArea text;
- static JTextArea answer;
- static JPanel top;
- static JButton top1;
- static JButton top2;
- static JButton mult;
- static JButton divid;
- static JPanel bottom;
- public static void main(String[] args){
- JFrame window = new JFrame("Calculator");
- JPanel holder = new JPanel();
- JButton one = new JButton("1");
- JButton two = new JButton("2");
- JButton three = new JButton("3");
- JButton four = new JButton("4");
- JButton five = new JButton("5");
- JButton six = new JButton("6");
- JButton seven = new JButton("7");
- JButton eight = new JButton("8");
- JButton nine = new JButton("9");
- JButton zero = new JButton("0");
- JTextArea text = new JTextArea();
- JPanel top = new JPanel();
- JButton top1 = new JButton("+");
- JButton top2 = new JButton("-");
- JButton mult = new JButton("°");
- JButton divid = new JButton("÷");
- JPanel bottom = new JPanel();
- JButton equals = new JButton("=");
- text.getLineWrap();
- text.setSize(25,5);
- //window.add(BorderLayout.NORTH,top);
- ///top.setLayout(new GridLayout(4,3));
- //top.add(top1);
- //top.add(text);
- //top.add(top2);
- holder.setLayout(new GridLayout(5,3));
- holder.add(top1);
- holder.add(text);
- holder.add(top2);
- holder.add(one);
- holder.add(two);
- holder.add(three);
- holder.add(four);
- holder.add(five);
- holder.add(six);
- holder.add(seven);
- holder.add(eight);
- holder.add(nine);
- holder.add(divid);
- holder.add(zero);
- holder.add(mult);
- bottom.add(equals);
- window.add(BorderLayout.SOUTH,bottom);
- //window.add(BorderLayout.PAGE_START, text);
- window.add(BorderLayout.CENTER,holder);
- window.setSize(250,300);
- window.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement