473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JButton

12 New Member
Hi all

I am having a problem with JButton.

JButton b=new JButton("save") ;

how can i get the name of the JButton b.

Please give the anser for me
Nov 15 '07 #1
6 2131
r035198x
13,262 MVP
Hi all

I am having a problem with JButton.

JButton b=new JButton("save") ;

how can i get the name of the JButton b.

Please give the anser for me
The name is b.
What can I say?
Nov 15 '07 #2
vijaykumarsharma
12 New Member
The name is b.
What can I say?
I want the name of the button as "save".

please give some idea.
Nov 15 '07 #3
r035198x
13,262 MVP
I want the name of the button as "save".

please give some idea.
Here "save" is usually called the text of the label. You get it using the getText() method. Read all about it in the specs for the button class.
Nov 15 '07 #4
JosAH
11,448 Recognized Expert MVP
The ActionEvent can tell the source of the event which is object b (your button)
after you have pressed it.

kind regards,

Jos
Nov 15 '07 #5
vivhbti
1 New Member
Hi Vijay


In Swing there is a facility of getActionComman d & setActionComman d.


While defining button just add below line.
JButton b=new JButton("save") ;
b.setActionComm and("save");

and when you are handling action performed...
public void actionPerformed (ActionEvent e) {
String nameOfButton = e.getActionComm and();

............
...........
............

}


Hi all

I am having a problem with JButton.

JButton b=new JButton("save") ;

how can i get the name of the JButton b.

Please give the anser for me
Nov 15 '07 #6
heat84
118 New Member
Hi Vijay


In Swing there is a facility of getActionComman d & setActionComman d.


While defining button just add below line.
JButton b=new JButton("save") ;
b.setActionComm and("save");

and when you are handling action performed...
public void actionPerformed (ActionEvent e) {
String nameOfButton = e.getActionComm and();

............
...........
............

}
I dont think this code will return the name of the button as requested.
Nov 16 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2215
by: Jeff T. | last post by:
Hi, I have a JMenuBar object that contains a JToolBar object which contains some JButton objects. After I let my applet sit for > 20 minutes, the graphics on those buttons would disappear. There seems to be nothing I can do to reload these graphics. I declare a JToolBar toolBar and call
3
2300
by: Konrad Den Ende | last post by:
Is it possible to do at all? The software will be used on computers with western operative systems (so i guess, JVM will be english) but i'm asured that japanese will be enabled through IME so that all fonts-and-company are installed. -- Kindly Konrad ---------------------------------------------------
4
1677
by: porky008 | last post by:
I put in a next and previous button but it crashes when I run it. I also need it to loop around to the first or last if at the ends. Can some one help me with this? import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.JFrame.*; import java.io.*; class Testing
0
4364
by: Oswald Otte | last post by:
Hello How can I change the look of a disabled JButton? I have made a boardgame with a brown background and brown buttons. I have also put an imageicon on the buttons that has a colored image on it. When I disable the buttons, the colored image is turned into grey which screws up the look of my game. Can I change the grey color on a...
9
1984
by: SimonHeffer | last post by:
I've been asked to give my .NET app the same look and feel to another app written using Java/Swing. My main issue is to do with button/icons. The JButton used by the other app has an icon with a transparent background - this may a consequence of using GIF as the source format. Now I just want to knock-up some simple icons for my app using...
2
2265
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that already exist) in my application using the Design Editor. I go about this by right-clicking on the JButton in the design editor, navigating to...
1
3186
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that already exist) in my application using the Design Editor. I go about this by right-clicking on the JButton in the design editor, navigating to Events...
12
3641
by: yeshello54 | last post by:
So I want to set the background color of a Jbutton. I know that the normal way to do such a thing is down the following way: JButton button = new JButton("xxxx"); button.setBackground(Color.RED); but in my program i add my Jbutton the following way.. horizontalBox2=Box.createHorizontalBox(); horizontalBox2.add(new...
1
2363
by: mlibot | last post by:
My JButton will be disabled when running my program... my JButton will be enabled if the value or parameter are equal to 3... for example: 1 value is path of the file i selected. 2 vaue is path of the directory i selected. 3 value is path of i want to be creating a output. if this three value will complete my JButton will be going to...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.