All pastes #2120216 Raw Edit

Mine

public java v1 · immutable
#2120216 ·published 2012-02-20 20:57 UTC
rendered paste body
import java.awt.*;import javax.swing.*;import java.awt.event.*;public class TipCalc extends JFrame implements ActionListener{		//Declare global variables	private JTextField txtTotalBill;	private JTextField txtTotalPeople;	private JTextField txtTipPerc;		private JButton btnOK;	private JButton btnClear;		private JLabel lblTotalIO;	private JLabel lblTotalpplIO;	private JLabel lblTipPercIO;		public static void main(String[] args) {		new TipCalc();	}	private final static String txt_tipamount = "Tip Amount: ";	private final static String txt_grandtot = "Grand Total: ";	private final static String txt_totalperperson = "Total per Person: ";	private final JLabel lblTipAmount; // lblTotalpPerson lblGrandTotal	private final JLabel lblTotalpPerson;	private final JLabel lblGrandTotal;	public TipCalc() {				/*ImageIcon icon = new ImageIcon("calculator1.png");		JLabel lblTipCalcPic = new JLabel(icon, JLabel.CENTER);		lblTipCalcPic.setHorizontalAlignment(SwingConstants.LEFT);		lblTipCalcPic.setSize(100,100);*/		//Declare and initialize labels for Title, and JTextField information		JLabel lblTipCalc = new JLabel();		Font tFont = new Font("Tahoma", Font.BOLD, 24);		lblTipCalc.setFont(tFont);		lblTipCalc.setText("TIP CALCULATOR");		lblTipCalc.setPreferredSize(new Dimension(250,30));		lblTipCalc.setBounds(150,30, 210,30);		lblTipCalc.setHorizontalAlignment(SwingConstants.CENTER);				JLabel lblTotalBill = new JLabel();		Font gFont = new Font("Arial", Font.BOLD, 14);		lblTotalBill.setFont(gFont);		lblTotalBill.setText("Total Bill:");		lblTotalBill.setPreferredSize(new Dimension(100,30));		lblTotalBill.setBounds(265,90, 100,30);				JLabel lblTotalPeople = new JLabel();		lblTotalPeople.setFont(gFont);		lblTotalPeople.setText("Total People:");		lblTotalPeople.setPreferredSize(new Dimension(100,30));		lblTotalPeople.setBounds(265, 130, 100,30);				JLabel lblTipPerc = new JLabel();		lblTipPerc.setFont(gFont);		lblTipPerc.setText("Tip Percentage:");		lblTipPerc.setPreferredSize(new Dimension(150,30));		lblTipPerc.setBounds(265, 170, 125,30);				lblTipAmount = new JLabel();		lblTipAmount.setFont(gFont);		lblTipAmount.setText("Tip Amount:");		lblTipAmount.setPreferredSize(new Dimension(150,30));		lblTipAmount.setBounds(265, 260, 135, 30);				lblGrandTotal = new JLabel();		lblGrandTotal.setFont(gFont);		lblGrandTotal.setText("Grand Total:");		lblGrandTotal.setPreferredSize(new Dimension(150,30));		lblGrandTotal.setBounds(265, 300, 135,30);				lblTotalpPerson = new JLabel();		lblTotalpPerson.setFont(gFont);		lblTotalpPerson.setText("Total Per Person:");		lblTotalpPerson.setPreferredSize(new Dimension(150,30));		lblTotalpPerson.setBounds(265, 340, 135,30);		JLabel lblTip = new JLabel();		lblTip.setPreferredSize(new Dimension(150,30));		lblTip.setBounds(265, 210, 135, 30);						JLabel lblGT = new JLabel();				JLabel lblTotPpl = new JLabel();				//Initialize both OK and Clear buttons		btnOK = new JButton();		btnOK.setText("OK");		btnOK.setPreferredSize(new Dimension(30,30));		btnOK.setBounds(295, 215, 85,25);		btnOK.addActionListener(this);				btnClear = new JButton();		btnClear.setText("Clear");		btnClear.setPreferredSize(new Dimension(30,30));		btnClear.setBounds(390, 215, 85,25);				//Initialize Text Fields for user input		txtTotalBill = new JTextField();		txtTotalBill.setPreferredSize(new Dimension(30,30));		txtTotalBill.setBounds(400, 90, 95,25);				txtTotalPeople = new JTextField();		txtTotalPeople.setPreferredSize(new Dimension(30,30));		txtTotalPeople.setBounds(400, 130, 95,25);				txtTipPerc = new JTextField();		txtTipPerc.setPreferredSize(new Dimension(30,30));		txtTipPerc.setBounds(400, 170, 95,25);				/*Declare and Initialize a panel		 * Add objects to panel		 */		JPanel panel = new JPanel();		panel.add(lblTipCalc);		panel.add(lblTotalBill);		panel.add(lblTotalPeople);		panel.add(lblTipPerc);		panel.add(lblTipAmount);		panel.add(lblGrandTotal);		panel.add(lblTotalpPerson);				panel.add(btnOK);		panel.add(btnClear);				panel.add(txtTotalBill);		panel.add(txtTotalPeople);		panel.add(txtTipPerc);				panel.add(lblTip);				//panel.add(lblTipCalcPic);				//Functions for JFrame		setContentPane(panel);		setSize(510, 410);		setLocationRelativeTo(null);		setLayout(null);		setResizable(false);		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		setTitle("Tip Calculator");		setVisible(true);					}		public void actionPerformed(ActionEvent arg0) {		// This gets called when OK is raped		//	lblTotalpPerson lblGrandTotal lblTipAmount		lblTotalpPerson.setText(txt_totalperperson+" "+43);		lblGrandTotal.setText(txt_grandtot+" "+43);		lblTipAmount.setText(txt_tipamount+" "+43);			}}