hello!
how are you?
i have two rows of JButtons.and i want to set top row JButtons not clickable a while i let bottom row Jbuttons to be clickable and vice versa.
is there a such method you can set JButtons to be immobile?
I would recommend going to Sun's website for this type of question. Just bookmark this site and go there when you have a question about a certain object's methods and such.
Casey is right. It will help you or anyone doing Java programs a lot if you take a look at the Java API. Better still if you can download the whole API so that everytime you need to know the available methods of the Classes in JDK, you wouldn't have to log on to the net.
I have coded an example for you as well in case you didn't get what Casey was trying to say.
public class ButtonTest extends JFrame implements ActionListener
{
JButton top, bottom;
public ButtonTest()
{
setSize(100,100);
getContentPane().setLayout(null);
top = new JButton("Top"
top.setBounds(new Rectangle(10,10,75,25));
top.addActionListener(this);
getContentPane().add(top,null);
bottom = new JButton("Bottom"
bottom.setBounds(new Rectangle(10,40,75,25));
bottom.addActionListener(this);
getContentPane().add(bottom,null);
}
public void actionPerformed(ActionEvent e)
{
String action = e.getActionCommand();
if (action.equals("Top")
{
top.setEnabled(false);
bottom.setEnabled(true);
}
else if (action.equals("Bottom")
{
top.setEnabled(true);
bottom.setEnabled(false);
}
}
public static void main(String[] args)
{
new ButtonTest().show();
}
}
Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best
thanks casey, leon & srikandula..
i have two books, java2 in 21 days & how to program java by deitel. i didn't find anything about it. but i remembered
i heard about it. that was why i posted here(last stop, hoping someone might explain to me).
and this site is very helpful that there are a lot of nice people who takes time to answer and help. my friend told me this site and i have been using this site since then.
yes, i do have installed java API on my home computer.
i didn't see .setEnable under Swing, JButton, under method summary.
i guess i had been looking a wrong place.
again thanks millions, guys.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.