File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes To Michael Ernest -about changing button labels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "To Michael Ernest -about changing button labels" Watch "To Michael Ernest -about changing button labels" New topic

To Michael Ernest -about changing button labels

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Ok i tried the code but it didn't compile.. and you told me to notify you if it didn't...
here is the code.. thanks for the help so far

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonThing implements ActionListener
{ private JPanel jp;
private JButton jb;
private JLabel jl;
private JFrame jf ;

private int presses = 0; public ButtonThing(String title) {
jf = new JFrame(title);
jp = new JPanel(new BorderLayout());
jb = new JButton("Click Me");
jl = new JLabel();
jp.add(jb, BorderLayout.NORTH);
jp.add(jl, BorderLayout.SOUTH);

jf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0); }

public void actionPerformed(ActionEvent ae) {
jb.setLabel("Thank you for clicking");
jl.setText("Press count: " + presses);
public static void main(String args[]) {
// Run program with:
// java ButtonThing
ButtonThing bt = new ButtonThing(args[0]);

if u can fix this please do.. you help would be greatly appreciated.. yours respectful Avin Sinanan

yours respectfully<br />Avin Sinanan
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Well, sure, but help me out here just a little! What compiler errors did you get?
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
I agree. Here's the link:
subject: To Michael Ernest -about changing button labels
jQuery in Action, 3rd edition