Changing function of a buttom.

Consider the following:-

ID [_______]
Name [_______]
Marks [_______]


This is a form which I have made. What i need is When I click on NEW button, if textboxes should be cleared and the text on the NEW button should change to SAVE. the EDIT button should be disabled and CLOSE should change to CANCEL.

I am able to change the text of the buttons using settext command but their function should is not changing ie, even though now it displays to be a save button but functions as new button. can anybody tell me how to implement this functionality.

Questions by vrijesh28

Showing Answers 1 - 1 of 1 Answers

Hi Dude..

It's a a very simple problem what u need to do is ..

 JButton n1=new JButton("New");
JButton n1=new JButton("Save");

public void actionPerformed(ActionEvent e)
       //Write your code here
       //Write your code here

This way check the actionCommand string instead of checking from JButton's name
i.e.  if(e.getSource()==n1)

This will help your to come to a Solution..
u can change the  functionality accordingly....

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions