JToggleButton - Change background when in pressed form

Could anyone please tell me how to change the colour of a JToggleButton when in a pressed state?
I've got a dew number of JToggleButton in a row but its a little difficult which button is in a pressed state so I thought of changing the colour when pressed. I tried changing the Look and Feel but it doesnt make much improvements.
Any other suggestion?
Thanks

Say it with icons?
import java.awt.*;
import java.net.*;
import javax.swing.*;
public class FrameExample  {
    public static void main(String[] args) throws MalformedURLException {
        Icon checked = new ImageIcon(new URL("http://www.oracle.com/technology/tech/blaf/specs/icons/statusindicators/completeind_status.gif"));
        Icon empty = new EmptyIcon();
        JPanel contentPane = new JPanel();
        for(int i=0; i<8; ++i) {
            JToggleButton btn = new JToggleButton("button #" + i);
            btn.setSelectedIcon(checked);
            btn.setIcon(empty);
            contentPane.add(btn);
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(contentPane);
        f.pack();
        f.setVisible(true);
class EmptyIcon implements Icon {
    public int getIconHeight() {return 16;}
    public int getIconWidth() {return 16;}
    public void paintIcon(Component c, Graphics g,int x,int y) {}
}

Similar Messages

  • My airport express seems to be broken -- light is yellow and does not flash and doesn't change even when I press the "reset".  Tried unplugging and reset -- still a solid yellow.

    AX light is yellow and does not flash and doesn't change even when I press the "reset".  Tried unplugging and reset -- still a solid yellow. I assume this is a goner?

    Unfortunately, based on your description, I would have to second that your Express is a "goner." However, before giving up on the unit, be sure that you attempt a "factory default" reset at least 3x just to be sure.

  • Change enctype when submitting a form

    Hi,
    Can anyone please let me know if its possible to change the enctype when submitting a form. I am trying to change the enctype to "multipart/form-data" when upload is clicked, else i want it to be the default.....
    function OnSubmitForm(myform)
    alert('document.pressed : ' + document.pressed );
    if(document.pressed == 'Upload')
    myform.enctype="multipart/form-data";
    alert('enctype: ' + myform.enctype);
    else
    alert('enctype: ' + myform.enctype);
    return true;
    }

    The JavaScript property is encoding (not enctype). The JavaScript encoding form property corresponds to the html enctype form attribute. So the code should be:
    function OnSubmitForm(myform)
    alert('document.pressed : ' + document.pressed );
    if(document.pressed == 'Upload')
    myform.encoding="multipart/form-data";
    alert('enctype: ' + myform.encoding);
    else
    alert('enctype: ' + myform.encoding);
    return true;
    }

  • How do I set the environment to change outputs when I press a button?

    Hi guys!
    This is a question for the Logic pros:
    How do I set up my environment so that when I press a Button on my Midi Controller the Outputs from the Master Channel switch from 1-2 to 3-4 (to hear my music through different loudspeakers)???
    Does somebody know how to do that?
    Thank you in advance!
    Greetings from Germany

    The easiest way is to route your mix to all the outputs you're using. Then set up fader objects in the env that transform toggled cc's from your keyboard switches. Cable those fader objects to the output channel objects. To toggle the Mute on an output channel you'll need to send it a fader message #9, value 0 or 1, on channel 1.
    That would work, as long as you have switches on your keyboard that can transmit toggled cc's.

  • Change background color in XML Forms

    Hi all ,
    I would like to implement this feature
    currently we have xml Form it display Messages for CRM users  but what we would like to implement is develop as stanadard as posible a solution to give more visibility for the newest messages
    i don't mind if background color ,
    with a image  or whatever
    i just check something about implement Custom Renders  but i don't get info to develop on my own  about interfaces to implement  location of jar files
    any help would be apreciate
    Regards

    i get it
    changing html code in undelying xsl file

  • My safari is blocked. When I press a window comes up sasking Are you sure you want to submit this form again and it will not let me cancel or submit

    My safari is blocked. When I press a window comes up sasking Are you sure you want to submit this form again? and it will not allow me to cancel or submit

    These are your options:
    1. Restore the iPhoto library from the most recent backup that predates the issue.
              Advantages: Always works, if library damage is causing the problem and the backup is intact.
              Disadvantages: Impossible if you don't have a backup. All changes made since the backup are lost.
    2. Repair or rebuild the library. Be sure to back it up first.
              Advantages: May solve the problem with no loss of data.
              Disadvantages: May fail. May take a long time if the library is large.
    3. Scavenge the library with a third-party application called "iPhoto Library Manager," which you can find in a web search. From the application's menu bar (not the iPhoto menu bar), select Library ▹ Rebuild.
              Advantages: All images should be preserved.
              Disadvantages: All books, calendars, and slideshows will be lost.

  • Change background in forms 10g?

    When we compile and run the form in forms 10g output is displayed. Can we change background? Can anybody help me to change the background in forms 10g?

    see you /forms/server/forms.conf file that contains the virtual directories declared
    # Virtual path mapping for Forms Java jar and class files (codebase)
    AliasMatch ^/forms90/java/(..*) "D:\Oracle9i/forms90/java/$1"
    # Virtual path for JInitiator downloadable executable and download page
    AliasMatch ^/forms90/jinitiator/(..*) "D:\Oracle9i/jinit/$1"
    # Virtual path for runform.htm (used to run a form for testing purposes)
    AliasMatch ^/forms90/html/(..*) "D:\Oracle9i/tools/web90/html/$1"
    # Virtual Path form images
    AliasMatch ^/forms90/icons/(..*) "D:\Oracle9i/CGENF61\ADMIN\ICONS\PC/$1"
    ...you can create as many virtual directories as you want.
    Francois

  • FORM 9i when-button-pressed trigger

    I am working on a form that has "Enter Query" and "Exe Query" buttons. In the when-button-pressed trigger associated with "Enter Query" button, I put:
    enter_query;
    In the when-button-pressed trigger associated with "Exe Query" button, I put:
    execute_query;
    (If I put "execute_query;" in when-mouse-clicked trigger it works, but I am kind of certain that there got to be a way to do it with when-button-pressed trigger.)
    The "Enter Query" button works as desired. However, the "Exe Query" button does not work. In fact, all the other buttons do not work unless, I press F8 to execute the query.
    I noticed the problem is the system.mode is changed to enter_query.
    Please give me some clues how to deal with it.
    Thank you.

    Thank you Frank and Dennis.
    I realized the problem is that when system.mode in enter_query. The navigation is restricted to the data block. I then moved all the relevant button into the data block. I have not yet tried what Dennis suggested: set mouse navigation to NO.
    Thank you.
    Jimmy

  • I want to create a vb form in which when i pressed a button then a specific song must be played.

    i want to create a vb form in which when i pressed a button then a
    specific song must be played. will u plx help me to do this..what i mean is that when i pressed that button a audio msut be played. will anyone help

    i want to create a vb form in which when i pressed a button then a specific
    song must be played. will u plx help me to do this..what i mean is that when i pressed that button a audio msut be played. will anyone help
    My.Computer.Audio.Play("C:\Users\John\Desktop\Something.Wav",
    AudioPlayMode.Background) or My.Computer.Audio.Play(My.Resources.SomeWavFileinyourresources,
    AudioPlayMode.Background) will play .Wav files only. And it will play them directly from resources without having to write them to disk to play them first.
    The
    Windows Media Player Control (can be created dynamically and not displayed) or the
    Media Player Class or a third party control that you can download called
    VLC Media Player can all play audio files based on the Codecs they use or have installed. Which would be .Wav, .MP3 and some others as well as you can download third party Codecs that can be provided to your system possibly for the Media Player class to
    use but as plugins I believe for Windows Media Player and VLC Media Player I believe for playing other types of audio and video file formats that they do not directly support with their installed codecs. Although all of these require that a file is available
    from disk or thumbdrive or CD Rom to play and can not directly play resources therefore resources must be written to disk in order to work.
    Microsoft Visual Basic language forum search results for "WindowsMediaPlayer"
    Microsoft Visual Basic language forum search results for "MediaPlayer"
    La vida loca

  • So in the last few days I've noticed that pressing my volume change keys actually isn't changing the volume on my macbook pro at all. When I press the volume up or down keys, it makes the recognisable pop sound but stays at the same volume while the squar

    So in the last few days I’ve noticed that pressing my volume change keys actually isn’t changing the volume on my macbook pro at all. When I press the volume up or down keys, it makes the recognisable pop sound but stays at the same volume while the squares go up or down. I mute it but my computer still makes sound. It’s the same with the volume control up the top of the screen, too. I slide it up and down and it doesn’t change the volume at all. The only way I can change the volume is with my speakers or the program I’m in (iTunes, VLC etc). I restarted and it seems to be okay then I go to change it a couple minutes later and it’s back to not working again.
    I’ve checked my settings- the “use all F1, F2, etc. keys as standard fuction keys” is not switched on, and I have tried a suggestion of moving the com.apple.systempreferences.plist file out of the library and onto the desktop and restarting and neither of those seem to make any difference whatsoever. I’ve tried to find online forums but the only suggestions I found were those two and they didn’t work.
    I’m just annoyed because I usually have the worst luck with technology but my macbook had been going strong and I got it because of the apparent lack of things that could go wrong, but of course even if there is one thing that could go wrong it will happen to me.
    Please help!

    You migh give resetting your NVRAM a try:
    http://support.apple.com/kb/ht1379

  • Calling a report from forms - FRM-40735 when-button-pressed raised unhandle

    Hi,
    I created a form to generate a pdf report.
    its not going too well, so i need some help.
    my form only has one button , when pressed I want it to generate a report in pdf format.
    i created a when-button-pressed trigger and the following code is below:
    I also create a web service proxy jar file,
    the jar file is in the FORMS_BUILDER_CLASSPATH, and the jar file is imported from forms builder without any issues.
    As of now I am hard coding everything in the code below to see if it works.
    The error I am getting  FRM-40735 when-button-pressed raised unhandled exception ORA-105100 i dont know why ?
    This error is occurring at this line of code, please help, this is my first time doing something like this.
    obj := publicreportserviceclient.new(); DECLARE
    param_name varchar2(200);
    un varchar2(200);
    pw varchar2(200);
    out_file varchar2(200);
    obj ORA_JAVA.JOBJECT;
    BEGIN
    obj := publicreportserviceclient.new();
    param_name := 'EMP';
    un := 'Administrator';
    pw := 'Oracle123';
    out_file := 'D:\DevSuiteHome_1\j2ee\home\default-web-app'||'output';
    publicreportserviceclient.callRunReport(obj,'/~administrator/Learn/Test1/Test1.xdo','EMP','141414',un,
    pw,'pdf','New_Template',out_file);
    web.show_document('http://jmenge-de.de.oracle.com:8889/j2ee/' || 'output');
    exception
      --check for ORA-105101
      when ORA_JAVA.EXCEPTION_THROWN then
         message('Java Exception : '
          || Exception_.toString(ORA_JAVA.LAST_EXCEPTION));
          ORA_JAVA.CLEAR_EXCEPTION;
          return;
      --check for ORA-105100
      when ORA_JAVA.JAVA_ERROR then
                   message('Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR);
              return;
    END;This is my java function
        public void callRunReport (String reportPath, String paramName, String  paramValue, String
        username, String password, String format, String template, String outFile) {
        try {
                bip_webservice.proxy.PublicReportServiceClient myPort = new bip_webservice.proxy.PublicReportServiceClient();
                // Calling runReport
                ReportRequest repRequest = new ReportRequest();
                repRequest.setReportAbsolutePath(reportPath);
                repRequest.setAttributeTemplate(template);
                repRequest.setAttributeFormat(format);
                repRequest.setAttributeLocale("en-US");
                repRequest.setSizeOfDataChunkDownload(-1);
               ParamNameValue[] paramNameValue = new ParamNameValue[1];
                paramNameValue[0] = new ParamNameValue();
                paramNameValue[0].setName(paramName);
                String[] values = new String[1];
                values[0] = paramValue;
                paramNameValue[0].setValues(values);
                repRequest.setParameterNameValues(paramNameValue);
                ReportResponse repResponse = new ReportResponse();
                repResponse = myPort.runReport(repRequest,username,password);
                byte[] baReport = repResponse.getReportBytes();
                FileOutputStream fio = new FileOutputStream(outFile);
                fio.write(baReport);
                fio.close();
            } catch (Exception ex) {
                        ex.printStackTrace();
        }Thanks - please help

    If there is a way to make it work with Bi publisher, Please let me know.
    I need to something to make it work with BI publisher.
    thanks,
    Edited by: Rooney on May 27, 2010 1:27 PM

  • How can print a report from form 6i,  when I press a button?

    hi Friends,
    How can print a report from form 6i, when I press a button?
    When i press a button from Form 6i, the report should print through printer.
    I have done it by using report parameter DESTYPE Printer but problem is that when I press a button printer dialogue box appear and then I give command Print to printer, I don’t want to show Printer dialogue box.
    I want when I press a button form Forms 6i , printer will print my report directly.
    Please send me the solution of this problem.
    Best regards,
    Shahzad

    Hi
    If You are using Client server application then to passing to Add all Print Parameter in the Host Command.
    Means Print command in unix to Host(lp.............) and Other Parameter to file name of the report to print.
    If You not Use Client Server Application the Also Passing a Host Command in Button-Pressed Event and Run.

  • E book" it tells me that the bI have prepared a photobook, made a pdf and when I press "buy the book is missing photos on one ore more pages. The book does not miss any photos or text, all layouts are ok, the background color is ok. Can anybody help me?

    I have prepared a photo book, made a pdf and when I press "buy thhe book" it tells me that the book is missing photos on one ore more pages. The book does not miss any photos or text, all layouts are ok, the background color is ok. Can anybody help me?

    You are missing one or more photos - youprobably have a page background that requires a photo which is behind a page with photos on it - all pages must either have a photo or be a color - if you have a gray background it requires a photo - look through the book carefully and be sure to look at the background on any full page photos - you will find one or more missing photos
    LN

  • When I send or receive e-mail, the mail gets changed significantly from its' original form.....typestyle, size of letters, symbols, page layout, color, everything changes.....is there a way to fix that?.....

    When I send or receive e-mail (Thunderbird).....the mail gets changed significantly from its original form.....typestyle, font size, symbols, page layout, color.....everything changes.....is there a way to fix that so my the original form of the mail is not changed?.....

    Just to recap, this is a collection of ports I have collected over time for people who needed this information when setting up the HP ePrint app so that they could view their email from within the app.  I am certain other applications also need this information.  Although lengthy, I could not find a more comprehensive place to retrieve this information.  Feel free to post additional information, faulty information, or other related topics below as this is simply a collection of data and it would be practically impossible to test all of them. Thank you!
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • HT3275 When I press "select backup location" in the Time Machine section of System Preferences, my external hard drive doesn't appear as an option.  How do I change this?

    When I press "select backup location" in the Time Machine section of System Preferences, my external hard drive doesn't appear as an option.  How do I change this?  My external hard drive is a FreeAgent GoFlex Drive.

    Hi, what Format is the external Drive?
    They usually come PC Formatted for Fat32/MSdos, or NTFS... is there anything on it now?
    How to format your disks...
    http://www.kenstone.net/fcp_homepage/partitioning_tiger.html
    (To Install OSX on an IntelMac the Drive it needs the GUID Partitioning scheme mentioned at the bottom.)
    Thanks to Pondini, Formatting,  Partitioning, Verifying,  and  Repairing  Disks...
    http://Pondini.org/OSX/DU.html

Maybe you are looking for

  • How to reorder images in Shared Photo Streams

    I share several Photo Streams and when i add an image that is older it appears as the most recent not in the correct date order. Is there a way to correct this behaviour...... I undersand the principles of a Photo Stream but i am trying to use the Sh

  • Cannot Sign Into Ichat -won't recognize any password

    Hi folks - A couple of days ago I woke my Mac (Imac 27" 2.8 ghz Intel Core i7 running OSX 10.7.5) and had a message from Ichat (ver. 6.0.2) (which I always have open) saying AOL Instant Messenger password 'Ichat can't log in to ------username----- be

  • Speed up encoding in Final Cut Studio 2

    I just thought this was worth sharing. It may have already been posted but really valuable if you haven't read this before! http://newmacusers.com/speed-up-encoding-in-final-cut-studio-2/17/ Have fun everyone!

  • HELP. My brother is being charged for broadband. h...

    Can someone please help my brother is being charged for bt broadband that he doesn't have after being charged £125 installation fee for a bt man to sit in his van for an hour and not do a thing. After numerous phone calls to resolve this he asked me

  • How to recover renamed .dbx files

    Hi,My team begun to have troubles with large.dbx files.. 600 to 700Mb these files were stored in a folder called inbox_store.dbx (automatic storage through filter)I renamed the folder directly in the .dbx storage folder as Storage_backupAfter opening