Custom JButton with different states, any ideas??
Hey, hope you guys can help.
What I want to do is to implement a custom JButton class with different states for the button. The button should have a "pressed" state, where the user has pressed it, and if the action triggered by this pressing gets approved, it should get selected. It will then get a different color and border.
I will have several buttons of this type in one panel, and they can all have different states at any time.
I do not want to use JToggleButton, as it is not the user that decides if it should be selected or not, but the logic "behind" (the dataflow).
So I want like a combination of JButton and JToggleButton...
How do I do this, any ideas, please?
I am not to sure if this is the idea you have in mind but...
This is something i have used before it is a tool bar. the button could be managed by another event it is an event listener at the moment.
As well as update only a specified button rather than all?
public class ToolBar extends JToolBar {
public ToolBar(EventListener el) {
this.setName("ToolBar");
String[] imageFiles = { "Left.gif", "Relationgif", "Reload.gif", "TrafficRed.gif", "Home.gif", "Print.gif", "Help.gif" };
String[] toolbarLabels = { "Entity", "Relationship", "Reload", "Stop", "Home", "Print", "Help" };
Insets margins = new Insets(3, 3, 3, 3);
for(int counter = 0; counter < toolbarLabels.length; counter++) {
ToolBarButton button = new ToolBarButton(imageFiles[counter]);
button.setToolTipText(toolbarLabels[counter]);
button.setMargin(margins);
button.setName(imageFiles[counter]);
button.setVerticalTextPosition(BOTTOM);
button.setHorizontalTextPosition(CENTER);
// button.setMnemonic(KeyStroke.VK_CAPS_LOCK);
button.addActionListener(el);
add(button);
public void setTextLabels(boolean showLabels) {
Component c;
int i = 0;
while((c = getComponentAtIndex(i++)) != null) {
ToolBarButton button = (ToolBarButton)c;
if (showLabels)
button.setText(button.getToolTipText());
else
button.setText("");
//each button on the tool bar is an object of this class
public class ToolBarButton extends JButton {
private static final Insets margins = new Insets(3, 3, 3, 3);
//user selected to view tool bar as image only (default)
public ToolBarButton(Icon icon) {
super(icon);
setMargin(margins);
//user selected to view tool bar as text only
public ToolBarButton(String iconName) {
this(new ImageIcon(iconName));
//user selected to view tool bar as image and text
public ToolBarButton(String iconImage, String iconName) {
this(new ImageIcon(iconImage));
setText(iconName);
}
Similar Messages
-
I want to clean the HDD back to as new but have lost the disks that came with the Macbook Any ideas please
You will need either the system DVD's that came with the MacBook or a retail Snow Leopard DVD...
....call Apple Customer Service to replace your original DVD's ( $ and a serial# required).....1-800-676-2775 -
The Bluetooth low energy protocol is not backward compatible with classic Bluetooth protocol.
My iPhone 4s can not find my sonny in-dash player. However my iPhone 3GS does it. Very disappointed with this.
Any idea how it can be fixed??????Hello,
You are correct, Blue tooth low engergy, BTLE.(only) devices are not backward compatible with Classic bluetooth and cannot connect.
However the Apple 4S and above have Bluetooth 4.0 support.. Hardware wise it has bothClassic Bluetooth, like the 3GS, as well as Bluetooth Low Energy. There is no good reason why your 4s cannot communicate to your Sony in-dash player using the Classic bluetooth that resides in the 4S.
I know that this does not answer the why it does not work, but it should work. Do you have to somehow re-pair the new phone up to the player? Not knowing the model of the Sony it is hard to investigate.
And I hate to ask but are you sure that the Bluetooth radio is on in the phone?
JT -
When I print a photo to my epson printer, it comes out larger than the original photo - so the photo prints beyond the borders. Tried readjusting all sorts of things but nothing helps. I had this same problem with my Canon. any ideas?
Crop to the print size before pringing
LN -
I opened a file on my desktop that I don't remember putting there. We use many photos and I thought it was a photo file I was looking for. It turned out to be a keychain certificate from a client of ours. Does this mean that they were spying on me? What is the deal with that? Any ideas?
Interesting tid bit. I created an AAC of the original file, deleted the original MP3 from my library and also deleted the Clean matched track from the icloud.
Result is that it matched with the explicit version of Mrs. Officer this time.
What I am curious about is which songs this is happening for. I've went thru a few batched of about 500 songs at a time and redownloaded in 256k for many tracks. Sadly we don't have people to bring this to our attention and I have so much music that it's impossible to go thru every song to make sure I am getting the right version. -
I have tried to restore my old iPhone 3, but when i tried the itunes logo and a pic of a USB cable have come up on my phone and now i cant do anything with my phone.Any ideas how i can fix this? I can make/receive call. iPhone 3GS(Ireally don't remember if it's a 3G or 3GS), iOS 3.1.2. Thanks for your help
please help me!!!
-
after lion 10.7.3 update messed my mac had to restore from time machine now Outlook won't connect with microsoft exchange, any idea?
I've had a similar problem. On my first boot up after installing 10.7.4, Firefox would not open. Crashed every time. Safari was not affected. I have no idea if it was related to the flash plugin, but I did install a the latest version of that a couple of weeks ago.
Here's what fixed it: a second boot up. -
Is it possible to create a customer master with different address
Hi Gurus,
Is it possible to create a customer master with different address as we maintain in SAP CRM.
Kindly help me onthis issue \
Regards
KannanHi Kannan,
There are no multiple addresses but you can use multiple unloading ponts for the same address for the ship to Party.
So when you create a Sales order the system will give a pop up with the unloading points allowing you to select the desired one.
I hope I understand your query correctly.
Regards
Yogesh -
Hy i Upgrade my iPhone and now my mp4 Data are in the file Video and i can't make any Playlist with them! Any idea?
I'm having the same issue, i restored my phone to Factory settings, even tried restoring it to my backup, half of my music bought from itunes won't play on my iphone and i'm super annoyed, this only happened once i updated to ios 7.2 so i assume its another glitch to go with my imessages not sending, getting sick of this.
-
Since upgrading to OSx 10.9, I cannot place my music for iPhoto slideshows. The only music that works is the Sample and Theme music that comes with iPhoto. Any idea of what to do about this problem?
In iTunes go File -> Library -> Organise Library -> Reorganise Library.
Then quit and restart iPhoto.
Credit to user keysandfood who figured that one out. -
My Macbook Pro will not print anything from any program. I've reinstalled the drivers. I get an error message in Word that says, "Word could not communicate with printer." Any ideas?
Be sure to try restarting, if you have not done so since this problem occurred. You should also power off the printer while you do the restart...
If that does not help, you can try resetting the printing system. Open System Preferences Print & Scan (or Print & Fax) pane. In the sidebar with list of printers, right (control) click anywhere. Select Reset printing system. You will have to add back your printers after you do this. -
I am trying to use automator to open a safari popup window that will automatically log me into whatever account and I attempted to type up an applescript that utilized the "System Events" function with no avail, any ideas?
Hi
In iMovie'11 (version 9.0.x)
on top menu row - Apple/iMovie/File/Edit/Cut (Can vary dep. on language - in Swedish Apple/iMovie/Arkiv/Redigera/Klipp . . . )
down Cut menu - Slow playback/Raspid Playback/Re-play in Slow Motion and onvards
Here one can select the Pre-Set speeds
Are you familiar with getting 'inspector' to run?
No - but I guess that Double Click on clip/sequense or ctrl-Click on it might open it.
Yours Bengt W -
I keep getting a message that my ID has been disabled when trying to download an app. I have changed password with apple. Any ideas what is wrong?
If you've changed your password and it still shows disabled then try logging out of your account on the iPad by tapping on your id in Settings > iTunes & App Stores and then log back in and see if that 'refreshes' the account on it
If that doesn't fix it then you might need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page -
I have a used ipad mini. I did a reset on it and I am trying to set it back up, but it is still tied to last users iTunes ID and will not let me set it up with mine. Any ideas. I tried setting it back to factory defaults with usb cable, but still no go. How do I activate ipad mini with my iTunes ID.
delete the email account and try again
-
My husband wiped out the library on his itunes account and replaced it with mine. Any ideas on how to get it back? Our laptop does not have his library either. only mine.
How exactly did this happen? Were you using separate iTunes libraries on separate user accounts on the laptop?
B-rock
Maybe you are looking for
-
How do I set up my second Ipod and itunes library (same computer)?
I recently filled up my first Ipod, and want to load my second Ipod's software on the same computer without causing interference and problems with my first ipod and library. How do I load my second ipod's software and create a library just for it, wi
-
Servlet context in application.xml does not appear to work
Hi all, I have created a very simple servlet and an index.html file with a link to it, then packaged it into a WAR file with the appropriate web.xml and ias-web.xml files. I then created an application.xml file referencing only this servlet and addin
-
Can't empty trash bin error: -8003
I'm trying to delete files from my Mac. Whenever I try to empty my trash bin this message appears: Can't complete operation. Error found. (error: -8003) Please help!
-
Will a Serial Number for Photoshop CS5 Work for CS5 Extended?
Hello, I've recently subscribed to Photoshop CS5 and Dreamweaver CS5.5. In my Order History, it says 'Photoshop CS5', not 'Photoshop CS5 Extended'. However the download links in my Order History does not work (yes, I do have Adobe Download Assistant-
-
Hi, I installed ISW and all the required connectors. But when I use the idsync resync command , I always get invalid options error. Trying to sync from ds5.2 to AD idsync resync -D "cn=Directory Manager" -w password -o Sun -c The DN used above is the