View RSS Feed

fatabass

Look of a Calculator

Rating: 1 votes, 1.00 average.
by , 12-30-2011 at 06:37 PM (973 Views)
Java Code:
package myPackage;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class SimpleCalculator {

	public static void main(String[] args) 
	{
		JFrame myFrame = new JFrame( "Testing" );
		BorderLayout myBorderLayout = new BorderLayout();
		GridLayout myGridLayout = new GridLayout(3,3);
		GridLayout secondGrid = new GridLayout(1,2);
		JPanel numbersPanel = new JPanel();
		JPanel topPanel = new JPanel();
		JTextField myTextField = new JTextField(150);
		JLabel myLabel = new JLabel("Just learning..");
		
		numbersPanel.setLayout(myGridLayout);
		topPanel.setLayout(secondGrid);
		
		JButton but1 = new JButton("1");
		JButton but2 = new JButton("2");
		JButton but3 = new JButton("3");
		JButton but4 = new JButton("4");
		JButton but5 = new JButton("5");
		JButton but6 = new JButton("6");
		JButton but7 = new JButton("7");
		JButton but8 = new JButton("8");
		JButton but9 = new JButton("9");
		
		numbersPanel.add(but1);
		numbersPanel.add(but2);
		numbersPanel.add(but3);
		numbersPanel.add(but4);
		numbersPanel.add(but5);
		numbersPanel.add(but6);
		numbersPanel.add(but7);
		numbersPanel.add(but8);
		numbersPanel.add(but9);
				
		topPanel.add(myTextField);
		topPanel.add(myLabel);
		
		
		myFrame.getContentPane().setLayout(myBorderLayout);
		myFrame.getContentPane().add(numbersPanel,BorderLayout.CENTER);
		myFrame.getContentPane().add(topPanel,BorderLayout.NORTH);
		myFrame.setSize(200,200);
		myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		myFrame.setVisible(true);
	}
}
Name:  LearningSwing.png
Views: 80
Size:  5.5 KB

Submit "Look of a Calculator" to Facebook Submit "Look of a Calculator" to Digg Submit "Look of a Calculator" to del.icio.us Submit "Look of a Calculator" to StumbleUpon Submit "Look of a Calculator" to Google

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments