Forums Register Login

How to make some buttons to act like push down , push up ... buttons

+Pie Number of slices to send: Send
Hi
Thank you for reading my post.
sorry if my post title is not good enough , i am not english.
In one of my frames i need to have some buttons , for example
there are 4 buttons like : stop , start, next , prev .
I wan to be able to do the following , but i do not know whether there
are standard component for this kind of common requirement in swing or not.

when user press Start , all buttons should become disable and start should stay down.
start will be down until user press stop (stop is like ordinary Jbutton and do not stay down)
after user press stop , start button will come up and all other buttons will become enable.


now my question is : How i can do this ?


Thank you.
+Pie Number of slices to send: Send
use javax.swing.JToggleButton instead of the usual JButton
+Pie Number of slices to send: Send
Hello there,

if you want to inactive or active a button call the following after pressing a button

public void buttonsAfterPressingStartButton(){
northButton.setEnabled(true); // or false
eastButton.setEnabled(true);
southButton.setEnabled(true);
westButton.setEnabled(true);

this method should be called via an actionListner on your startButton.
+Pie Number of slices to send: Send
Hi
So there is no feature in the swing component like :
component index, ... that determine some butons are in same group and if one of them goes down all other in the group come up ?


Thank you
+Pie Number of slices to send: Send
There might be, you could experiment with putting buttons in

//
public class ButtonGroup
extends Object
implements Serializable

This class is used to create a multiple-exclusion scope for a set of buttons. Creating a set of buttons with the same ButtonGroup object means that turning "on" one of those buttons turns off all other buttons in the group.
//

but I think you could do all you wanted by a series of methods called at the appropriate time, for example in my own implementation


public void buttonsAfterSecondCrop(){
northButton.setEnabled(true);
eastButton.setEnabled(true);
eastButton10.setEnabled(true);
southButton.setEnabled(true);
westButton.setEnabled(true);
westButton10.setEnabled(true);
OKButton.setEnabled(true);
if(isTwoSplit){
copyButton.setEnabled(false);
}
//leave blank for now
else if(isThreeSplit){
//prevents copybutton being pressed until OKbutton pressed
//this is so the user can align his second Roi
copyButton.setEnabled(false);
}
}

public void buttonsAfterOK(){
northButton.setEnabled(false);
eastButton.setEnabled(false);
eastButton10.setEnabled(false);
southButton.setEnabled(false);
westButton.setEnabled(false);
westButton10.setEnabled(false);
if(isTwoSplit){
copyButton.setEnabled(false);
saveButton.setEnabled(true);
OKButton.setEnabled(false);
}
//leave blank for now
else if(isThreeSplit && copyCount == ONE_IMAGE_CROPPED){
copyButton.setEnabled(true);
saveButton.setEnabled(false);
OKButton.setEnabled(false);
}
else if(isThreeSplit && copyCount == TWO_IMAGES_CROPPED){
copyButton.setEnabled(false);
saveButton.setEnabled(false);
OKButton.setEnabled(false);
}
}
It was the best of times. It was the worst of times. It was a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1436 times.
Similar Threads
problem with JToggleButton and Toolbar
Integer inheritence problem
Graphics on pushbuttons on an AWT applet
Hosting problem , the Host provider tomcat does not understand .do
Synchronizing question , how to share a resource between thereads.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:00:41.