• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

please help .. please

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
trying to do this UI which gives the customer 3 choices of payment.
worked on it for quite a few nites now ..
i jus need the label to change whenever a button is clicked..
i know that my name is not my real name .. i'll change it ..
can please help .. thanks in advance ..

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
abstract public class abc implements ActionListener{

public static boolean RIGHT_TO_LEFT = false;

public static Container contentPane;
public static String label1;



contentPane.setLayout(new GridLayout(5,1));




/*
JButton[] def = new JButton[2];
def[0] = new JButton("Cash");
def[1] = new JButton("Cash Card");
def[2] = new JButton("ATM");
def[3] = new JButton("");
def[4] = new JButton("Submit");
*/

public static JButton[] def = { new JButton("Cash"),
new JButton("Cash Card"),
new JButton(""),
new JButton("Submit") }
;
for(int i = 0; i < def.length; i++)
{
def[i].addActionListener(this);

if(i == 0)
{

public void actionPerformed(ActionEvent e) {
String label1 = "Please Enter The Amount Inserted";
//return label1;
}
}
else if (i == 1)
{
public void actionPerformed(ActionEvent e) {
String label1 = "Please Insert Your Cashcard";
//return label1;
}
}

else if (i == 2)

{
public void actionPerformed(ActionEvent e) {
String label1 = "Please Enter Your PIN";


//return label1;
}

}

else (i == 4)

{
public void actionPerformed(ActionEvent e) {
String label1 = "Thank You For Using Our System";
//return label1;

}
}


}
contentPane.add(cash);
contentPane.add(cashcard);
contentPane.add(atm);

JTextField textfield = new JTextField(20);

JLabel label = new JLabel(label1);

contentPane.add(textfield);
contentPane.add(label);



/*
JButton cash = new JButton("Cash");
cash.addMouseListener();
JButton cashcard = new JButton("Cash Card");
cashcard.addActionListener();
JButton atm = new JButton("ATM");
atm.addActionListener();


public static void addComponents(Container contentPane) {



if (RIGHT_TO_LEFT) {
contentPane.setComponentOrientation(
ComponentOrientation.RIGHT_TO_LEFT);
}
contentPane.setLayout(new FlowLayout());

JTextField textfield = new JTextField(20);

JLabel label = new JLabel();

contentPane.add(textfield);
contentPane.add(label);

*/



/*
public void mousePressed extends addComponents(MouseEvent e) {

super.label = new JLabel("please enter amount inserted");

}
*/

/*

JButton cashcard = new JButton("Cash Card");

cashcard.addActionListener();


JButton atm = new JButton("ATM");

atm.addActionListener();



contentPane.add(cashcard);
contentPane.add(atm);



*/

/*
class Eavesdropper {

JTextField mytextfield;
public Eavesdropper(JTextField ta) {
mytextfield = ta;
mytextfield.getText();

}
}
*/
/*
public void addComponents()
{
cash.addActionLeader(this);
cash.addActionListener(new cash());

cashcard.addActionListener(this);
cashcard.addActionListener(new cashcard());

atm.addActionListener(this);
atm.addActionListener(new atm());
*/
/*
cash.addActionListener(new ActionListener()

{
public void actionPerformed(ActionEvent e) {

});


}
*/
/*
class cash implements ActionListener {
public void actionPerformed(ActionEvent e) {

}
}
class cashcard implements ActionListener {

public void actionPerformed(ActionEvent e) {

}
}

class atm implements ActionListener {

public void actionPerformed(ActionEvent e) {

}
}

*/
private static void createAndShowGUI() {

JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
//JFrames decorated by tahe Java look and feel
//can't get smaller than their minimum size.
//We specify a skinnier minimum size than the
//content pane will cause the frame to request,
//so that you can see what happens when you
//drag the window so that it's narrower than a
//single row.
JFrame frame = new JFrame("IT1290 Payment System")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


//addComponents(frame.getContentPane());

frame.setSize(500, 600);
frame.setVisible(true);
}
public static void main(String[] args) {

javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't work out what a lot of your code is trying to do, but here's
something based on what I *think* I can see.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi "Seventh Theory" I am no the bartender in this forum, but, ouch, you are killing me.
First I'd like to welcome you to Javaranch. Please feel free to ask all your Java questions here, we really like helping everyone out, and we are really very friendly here.
And here is my "but", I understand being new, mistakes can happen, and don't think I am mad, casue I am not, but you seem to have broken almost all the rules. I know you said you will change your name, so here is the link.
1. First, we will start out with the JavaRanch Naming Policy.
You can change it
here.
2. The title of your thread should be more meaningful towards what you are going to actually post. please help is just very very vague.
3. Under the "Add Reply" button you will find many helpful buttons that can format your post to be more readable. For instance the button titled "CODE" can create tags that when wrapped around actual code will have the code retain all its formatting, including most importantly, your indentation. This makes is readable, and therefore easier for the reader to help you solve your problem.
Mark
p.s read your private messages.
reply
    Bookmark Topic Watch Topic
  • New Topic