import java.awt.*;
import javax.swing;


public class ATMko extends JFrame
{	
	JPanel p1;
	JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14;
	JTextField t1;
	Container c= getContentPane();
    public ATMko() 
    	{
    	t1=new JTextField("	",100);
    	b1=new JButton("1");
    	b1.setBackground(Color.GRAY);
    	b1.setForeground(Color.BLACK);
    	b2=new JButton("2");
    	b2.setBackground(Color.GRAY);
    	b2.setForeground(Color.BLACK);
    	b3=new JButton("3");
    	b3.setBackground(Color.GRAY);
    	b3.setForeground(Color.BLACK);
    	b4=new JButton("4");
    	b4.setBackground(Color.GRAY);
    	b4.setForeground(Color.BLACK);
    	b5=new JButton("5");
    	b5.setBackground(Color.GRAY);
    	b5.setForeground(Color.BLACK);
    	b6=new JButton("6");
    	b6.setBackground(Color.GRAY);
    	b6.setForeground(Color.BLACK);
    	b7=new JButton("7");
    	b7.setBackground(Color.GRAY);
    	b7.setForeground(Color.BLACK);
    	b8=new JButton("8");
    	b8.setBackground(Color.GRAY);
    	b8.setForeground(Color.BLACK);
    	b9=new JButton("9");
    	b9.setBackground(Color.GRAY);
    	b9.setForeground(Color.BLACK);
    	b10= new JButton("0");
    	b10.setBackground(Color.GRAY);
    	b10.setForeground(Color.BLACK);
    	b11=new JButton("END");
    	b11.setBackground(Color.RED);
    	b11.setForeground(Color.BLACK);
    	b12=new JButton("Enter");
    	b12.setBackground(Color.GREEN);
    	b12.setforeground(Color.BLACK);
    	b13=new JButton("Cancel");
    	b13.setBackground(Color.YELLOW);
    	b13.setforeground(Color.BLACK);
    	b14=new JButton("000");
    	b14.setBackground(Color.GRAY);
    	b14.setforeground(Color.BLUE);
    	
   c.setLayout(new GridLayout());
    
    	b1.setBounds(50,50,20,20);
    	b2.setBounds(50,50,20,20);
    	b3.setBounds(50,50,20,20);
    	b4.setBounds(50,50,20,20);
    	b5.setBounds(50,50,20,20);
    	b6.setBounds(50,50,20,20);
    	b7.setBounds(50,50,20,20);
    	b8.setBounds(50,50,20,20);
    	b9.setBounds(50,50,20,20);
    	b10.setBounds(50,50,20,20);
    	b11.setBounds(50,60,20,20);
    	b12.setBounds(50,60,20,20);
    	b13.setBounds(50,60,20,20);
    	b14.setBounds(50,60,20,20);
    	
    p1.setLayout(new GridLayout());
    	p1.add(b1);p1.add(b2);
    	p1.add(b3);p1.add(b4);
    	p1.add(b5);p1.add(b6);
    	p1.add(b7);p1.add(b8);
    	p1.add(b9);p1.add(b10);
    	p1.add(b11);p1.add(b12);
    	p1.add(b13);p1.add(b14);
    	setSize(500,600);
    	show();
    	}
    	public static void main(String[]args)
    	{
		new ATMko();
		}
	}

This is my errors:
--------------------Configuration: <Default>--------------------
C:\Documents and Settings\Rein\My Documents\ATMko.java:2: package javax does not exist
import javax.swing;
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:5: cannot find symbol
symbol: class JFrame
public class ATMko extends JFrame
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:7: cannot find symbol
symbol : class JPanel
location: class ATMko
JPanel p1;
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:8: cannot find symbol
symbol : class JButton
location: class ATMko
JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14;
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:9: cannot find symbol
symbol : class JTextField
location: class ATMko
JTextField t1;
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:10: cannot find symbol
symbol : method getContentPane()
location: class ATMko
Container c= getContentPane();
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:13: cannot find symbol
symbol : class JTextField
location: class ATMko
t1=new JTextField(" ",100);
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:14: cannot find symbol
symbol : class JButton
location: class ATMko
b1=new JButton("1");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:17: cannot find symbol
symbol : class JButton
location: class ATMko
b2=new JButton("2");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:20: cannot find symbol
symbol : class JButton
location: class ATMko
b3=new JButton("3");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:23: cannot find symbol
symbol : class JButton
location: class ATMko
b4=new JButton("4");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:26: cannot find symbol
symbol : class JButton
location: class ATMko
b5=new JButton("5");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:29: cannot find symbol
symbol : class JButton
location: class ATMko
b6=new JButton("6");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:32: cannot find symbol
symbol : class JButton
location: class ATMko
b7=new JButton("7");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:35: cannot find symbol
symbol : class JButton
location: class ATMko
b8=new JButton("8");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:38: cannot find symbol
symbol : class JButton
location: class ATMko
b9=new JButton("9");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:41: cannot find symbol
symbol : class JButton
location: class ATMko
b10= new JButton("0");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:44: cannot find symbol
symbol : class JButton
location: class ATMko
b11=new JButton("END");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:47: cannot find symbol
symbol : class JButton
location: class ATMko
b12=new JButton("Enter");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:50: cannot find symbol
symbol : class JButton
location: class ATMko
b13=new JButton("Cancel");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:53: cannot find symbol
symbol : class JButton
location: class ATMko
b14=new JButton("000");
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:82: cannot find symbol
symbol : method setSize(int,int)
location: class ATMko
setSize(500,600);
^
C:\Documents and Settings\Rein\My Documents\ATMko.java:83: cannot find symbol
symbol : method show()
location: class ATMko
show();
^
23 errors

Process completed.

i need help it will be pass in 2 hours from now please reply

Member Avatar for ztini

Holy redundancy Batman!

Let's try now with some OOP...and ASCII, but mostly OOP:

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextPane;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;


public class ATM extends JFrame {

	private JTextPane output = new JTextPane();

	public ATM() {
		configLayout();
		configFrame();
	}
	
	private void configFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle("ATM");
		setResizable(false);
		setBounds(400, 200, 351, 400);
		setVisible(true);
	}
	
	private void configLayout() {
		setLayout(new BorderLayout());
		output.setPreferredSize(new Dimension(351, 210));
		output.setFocusable(false);
		output.setFont(new Font("Courier New", Font.PLAIN, 14));
		output.setText(
			"      ___                       ___     " + '\n' +
			"     /  /\\          ___        /__/\\    " + '\n' +
			"    /  /::\\        /  /\\      |  |::\\   " + '\n' +
			"   /  /:/\\:\\      /  /:/      |  |:|:\\  " + '\n' +
			"  /  /:/~/::\\    /  /:/     __|__|:|\\:\\ " + '\n' +
			" /__/:/ /:/\\:\\  /  /::\\    /__/::::| \\:\\" + '\n' +
			" \\  \\:\\/:/__\\/ /__/:/\\:\\   \\  \\:\\~~\\__\\/" + '\n' +
			"  \\  \\::/      \\__\\/  \\:\\   \\  \\:\\      " + '\n' +
			"   \\  \\:\\           \\  \\:\\   \\  \\:\\     " + '\n' +
			"    \\  \\:\\           \\__\\/    \\  \\:\\    " + '\n' +
			"     \\__\\/                     \\__\\/    ");
		add(output, BorderLayout.NORTH);

		JPanel panel = new JPanel();
		add(panel, BorderLayout.CENTER);
		panel.setLayout(new GridLayout(4, 3));
		
		for (int i = 1; i <= 9; i++)
			panel.add(createOperand(i));

		panel.add(createOperator("Cancel"));
		panel.add(createOperand(0));
		panel.add(createOperator("Enter"));
	}
	
	private JButton createOperand(final int text) {
		JButton button = new JButton(Integer.toString(text));
		button.setFocusable(false);
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				output.setText(output.getText() + text);
				// do something clever
			}
		});
		return button;
	}
	
	private JButton createOperator(final String text) {
		JButton button = new JButton(text);
		button.setFocusable(false);
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// do something clever
			}
		});
		return button;
	}
	
	public static void main(String[] args) {
		new ATM();		
	}
}
Member Avatar for ztini

oh, but really you just need to change

line 2 to:

import javax.swing.*;
Member Avatar for ztini

And:

1) b12, b13, b14 should be .setForeground(... not setforeground(...

2) show() - deprecated, use instead: this.setVisisible(true);

3) you need to initialize p1, so change "JPanel p1;" to JPanel p1 = new JPanel();

4) add p1 to your parent frame (e.g. this.). So: this.add(p1);

import java.awt.*;
import javax.swing.*;



public class ATM extends JFrame
{	
	Label l1,l2,l3,l4;
	Panel p1,p2,p3,p4,p5;
	Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13;
	TextField t1,t2,t3,t4;
	Container c=getContentPane();
    public ATMko() 
{
    	l1=new Label("Enter Account Number:");
    	l2=new Label("Enter Pin Number:");
    	l3=new Label("Account Status:");
    	l4=new Label("Account Balance:");
    	
    	t1=new TextField(10);
    	t2=new TextField(10);
    	t3=new TextField(10);
    	t4=new TextField(10);
    	
    	p1=new Panel();
    	p2=new Panel();
    	p3=new Panel();
    	p4=new Panel();
    	
    	b1=new Button("1");
    	b2=new Button("2");
    	b3=new Button("3");	
    	b4=new Button("4");	
    	b5=new Button("5");	
    	b6=new Button("6");
    	b7=new Button("7"); 
    	b8=new Button("8");	
    	b9=new Button("9");
    	b10=new Button("0");
    	b11=new Button("END");
    	b12=new Button("Enter");
    	b13=new Button("Cancel");
    	
    	p1.setLayout(new BorderLayout(1,1));
    	p1.add(l1);p1.add(t1);
    	p2.setLayout(new BorderLayout(1,1));
    	p2.add(l2);p2.add(t2);
    	p3.setLayout(new BorderLayout(1,1));
    	p3.add(l3);p3.add(t3);
    	p4.setLayout(new BorderLayout(1,1));
    	p4.add(l4);p4.add(t4);
    	
    	
    	
    	p5.setLayout(new GridLayout(6,3));
    	p5.add(b1);p5.add(b2);
    	p5.add(b3);p5.add(b4);
    	p5.add(b5);p5.add(b6);
    	p5.add(b7);p5.add(b8);
    	p5.add(b9);p5.add(b10);
    	p5.add(b11);p5.add(b12);
    	p5.add(b13);
    	p5.setBounds(100,100,50,50);
    	
    	
    	setLayout(new BorderLayout(1,3));
    	add(p1);
    	add(p2);
    	add(p3);
    	add(p4);
    	add(p5);
    	setSize(500,500);
    	show();
    	
    	}
    	public static void main(String[]args);
    	{
		new ATM();
		}
	}

thanks for reply btw i revised the earlies i wish i can pass this tommorow

Thanks Ztini

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class ATMko extends JFrame implements ActionListener
{	
	JLabel l1,l2,l3,l4;
	JPanel p1,p2,p3;
	JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15;
	JTextField t1,t2,t3,t4;
	Container c=getContentPane();
    public ATMko() 
{
    	
    	l1=new JLabel("Enter Account Number:",JLabel.CENTER);
    	l2 =new JLabel("Enter Pin Number:",JLabel.CENTER);
    	l3=new JLabel("Account Status:",JLabel.CENTER);
    	l4=new JLabel("Account Balance:",JLabel.CENTER);
    	t1=new JTextField(10);
    	t2=new JTextField(10);
    	t3=new JTextField(10);
    	t4=new JTextField(10);
    	JPanel p1=new JPanel();
    	JPanel p2=new JPanel();
    	JPanel p3=new JPanel();
    	b1=new JButton("1");
    	b1.setBackground(Color.blue);
    	b1.setForeground(Color.white);
    	b2=new JButton("2");
    	b2.setBackground(Color.blue);
    	b2.setForeground(Color.white);
    	b3=new JButton("3");
    	b3.setForeground(Color.white);
    	b3.setBackground(Color.blue);	
    	b4=new JButton("4");
    	b4.setBackground(Color.blue);
    	b4.setForeground(Color.white);	
    	b5=new JButton("5");
    	b5.setBackground(Color.blue);
    	b5.setForeground(Color.white);	
    	b6=new JButton("6");
    	b6.setBackground(Color.blue);
    	b6.setForeground(Color.white);
    	b7=new JButton("7");
    	b7.setBackground(Color.blue);
    	b7.setForeground(Color.white);
    	b8=new JButton("8");
    	b8.setBackground(Color.blue);
    	b8.setForeground(Color.white);	
    	b9=new JButton("9");
    	b9.setBackground(Color.blue);
    	b9.setForeground(Color.white);
    	b10=new JButton("0");
    	b10.setForeground(Color.white);
    	b10.setBackground(Color.magenta);
    	b11=new JButton("END");
    	b11.setBackground(Color.darkGray);
    	b11.setForeground(Color.white);
    	b12=new JButton("Enter");
    	b12.setBackground(Color.red);
    	b12.setForeground(Color.white);
    	b13=new JButton("Deposit");
    	b13.setBackground(Color.gray);
    	b13.setForeground(Color.white);
    	b14=new JButton("Withraw");
    	b14.setBackground(Color.green);
    	b14.setForeground(Color.white);
    	b15=new JButton("Cancel");
    	b15.setBackground(Color.yellow);
    	b15.setForeground(Color.white);
    	p1.addActionListener(this);p2.ActionLister(this);
    	
    	c.setLayout(new GridLayout(3,2));
    	c.add(b1);c.add(b2);
    	c.add(b3);c.add(b4);
    	c.add(b5);c.add(b6);
    	c.add(b7);c.add(b8);
    	c.add(b9);c.add(b10);
    	c.add(b11);c.add(b12);
    	c.add(b14);c.add(b13);
    	c.add(b15);
    	setSize(100,100);
    	show();
    
    	
    	p1.setLayout(new GridLayout(2,1));
    	p1.add(l1);p1.add(t1);
    	p1.add(l2);p1.add(t2);
    	p2.setLayout(new GridLayout(2,1));
    	p2.add(l3);p2.add(t3);
    	p2.add(l4);p2.add(t4);
    	
    	p3.setLayout(new GridLayout(3,1));
    	p3.add(b1);p3.add(b2);
    	p3.add(b3);p3.add(b4);
    	p3.add(b5);p3.add(b6);
    	p3.add(b7);p3.add(b8);
    	p3.add(b9);p3.add(b10);
    	p3.add(b11);p3.add(b12);
    	p3.add(b14);p3.add(b13);
    	p3.add(b15);
    	
    	setLayout(new GridLayout(2,1));
    	add(p1);add(p3);
    	add(p2);
    	setSize(500,200);
    	show();
    	}
    	public void action performed(ActionEvent e)
    
    		i{f (e.getSource()==p1)
    		p1.setVisible(false);
    		p2.setVisible(true);
    	}
    	if (e.getSource()==p2)
    	{	p1.setVisible(true);
    		p2.setVisible(false);
    		{
    	public static void main(String[]args)
    	}
    	{
    	new ATMko();
    	}
	}

ERRORS:

--------------------Configuration: <Default>--------------------
C:\Documents and Settings\Rein\My Documents\ATMko.java:109: '(' expected
        public void action performed(ActionEvent e)
                           ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:109: ';' expected
        public void action performed(ActionEvent e)
                                                   ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:111: ';' expected
            i{f (e.getSource()==p1)
                                   ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:115: illegal start of type
        if (e.getSource()==p2)
        ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:115: <identifier> expected
        if (e.getSource()==p2)
                       ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:115: ';' expected
        if (e.getSource()==p2)
                        ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:115: illegal start of type
        if (e.getSource()==p2)
                         ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:115: ';' expected
        if (e.getSource()==p2)
                             ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:119: illegal start of expression
        public static void main(String[]args)
        ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:119: illegal start of expression
        public static void main(String[]args)
               ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:119: ';' expected
        public static void main(String[]args)
                     ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:119: '.class' expected
        public static void main(String[]args)
                                        ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:119: ';' expected
        public static void main(String[]args)
                                            ^
C:\Documents and Settings\Rein\My Documents\ATMko.java:124: reached end of file while parsing
    }
     ^
14 errors

Process completed.

request i need to show the Panel1 and then the panel2 with the panel 3 help me.thanks

Read your first error, it said that you are missing an open parenthesis right at line 109. In other words, it is a syntax error. You should look at the error message and follow the suggestion...

By the way, code tag please...

@Glenner
1. Please use code tags
2. Do NOT multi post!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.