JButton background turns grey when clicked

Hi,
I have a JButton that I have customised by setting the background colour to beige and hiding the border using setBorderPainted(false). I have also got rid of the outline that normally appears when you click it using setFocusPainted(false).
My problem is that when I run my applet in a browser and I click on a button, the background flashes grey while I'm clicking. This only happens in the browser - when I run it in JBuilder there is no problem. Can you help?
Thanks!
David

Unfortunately, this is a consequence of having the UI logic separated from the button component. In order to change the button's selected/pressed color, you have three options:
1) set the UI to your own custom UI (see http://java.sun.com/products/jfc/tsc/articles/sce/). You don't have to implement a whole new UI, but you'll still have work cut out for you if you're not familiar with this.
2) change the color for ALL the buttons in the application usingUIManager.set("Button.select", new javax.swing.plaf.ColorUIResource(0,0,0)); Obviously, you should specify a good color.
3) create a subclass of JButton, call setContentAreaFilled(false); on it, and paint it yourself.

Similar Messages

  • Why does JButton background color change when  clicking ?

    Hello,
    I have defined :
    JButton mybutton = new JButton(Icon xxx) ;
    with no associated text and I set both foreground and background colors to black, and an empty border.
    This is because the background color of the container which contents this button is also black and I want to see only the button icon.
    When I click on the icon , the button background color becomes grey. How can I change this to make it remains black ?
    Thanks a lot.
    Gege

    Well, the color changes because that is how the look and feel is defined,
    presumably to give better feedback to the user that she has clicked the
    button.
    If you don't want this, you could try using a different L&F which doesn't do this.
    Alternatively, If you've only got the one button, you could just do
        UIManager.put( "Button.select", Color.BLACK );If you have multiple buttons, and you want the other buttons to behave
    normally, you can extend the one button and have it change the color
    while it is pressed, e.g.,
    import java.awt.*;
    import java.io.IOException;
    import java.net.URL;
    import javax.swing.*;
    public class ButtonSelect extends JFrame {
         public ButtonSelect() throws IOException {
              super();
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel panel = new JPanel();
              panel.add( new JButton( "Normal" ) );
              Image img = Toolkit.getDefaultToolkit().getImage( new URL("http://www.google.com/intl/en/images/logo.gif" ) );
              ImageIcon ii = new ImageIcon( img );
              JButton b = new JButton( ii ) {
                   static final private String KEY = "Button.select";
                   public void paint( Graphics g ) {
                        Color save = null;
                        if ( getModel().isArmed() && getModel().isPressed() ) {
                             save = UIManager.getColor( KEY );
                             UIManager.put( KEY, Color.WHITE );
                        super.paint( g );
                        if ( save != null )
                             UIManager.put( KEY, save );
              b.setForeground( Color.WHITE );
              b.setBackground( Color.WHITE );
              b.setFocusPainted( false );
              panel.add( b );
              getContentPane().add( panel );
              pack();
              setVisible( true );
         public static void main( String[] a ) throws IOException {
              new ButtonSelect();
    }

  • I have a problem, all the pictures turns grey when i open a document, i have a Mac computer if that can be any help.. Please can somebody tell me what i am doing wrong. It have not been like this before i have started now??

    I have a problem, all the pictures turns grey when i open a PDF document in acrobat xl pro, iy have not been like this before it started a few days ago. Before it did help if i closed the program but that does not work anymore??

    Now it works!!!! THANK YOU VERY MUSH!!! You made my holiday!! Now i can work! ; )) Happy new year to you!!!

  • Why does black turn grey when creating a pdf from InDesign CS5??

    Why do blacks turn to grey when I create/export a pdf from InDesign CS5?

    Unfortunately, things like this are rarely glitchy little programming errors but deep, by-design, problems with using colour management. Usually you are getting exactly what you asked for, just not what you want, and the more colour management options there are, the more likely this is.
    There are many possible causes, but one of the easiest to do is and hardest to spot is applying a CMYK profile in InDesign export, and a different one through Photoshop settings. This is actually demanding that colours be converted for the worst! Since your print workflow will be different, a work-around of rich black is likely to make things worse.
    So the first thing to check is whether the colours you indended made it to the PDF, indeed. Output Preview is the first tool to use (as well as inspecting plates, you can hover over points to check the colour mix).
    Also, go to your PDF export under the "Output" tab which includes colour and PDF/X. Either send a screen shot, or read off all of the the settings there.

  • Clips turn grey when i drag

    i have clips in i movie6 clips window...when i try to use them and i start dragging them onto the timeline or over to FCP, the clip turns grey and i cannot do anything with it..why is that?

    im having the same problem. cant copy/paste either with those clips because they gray out!

  • Black page background flashes grey when zooming on images

    When I'm previewing my book on iPad I see that when I zoom in on an image (single image gallery widget) the page background which is black flashes grey momentarily. This happens on ipad but not when I preview on the mac.
    Seems like the page wants to revert to the default white background everytime I click an image widget. Any way to set a book wide black background color? I currently create the page background colour by placing a black rectangle object in the background.
    Thanks anyone for any tips!

    It seems there's a default setting when zooming on images that fades the background from white to black (I guess Apple is presuming all pages are white)? Anyone who have pages with colour background notice this?

  • Video turns grey when I try to record it using Quicktime

    I am trying to save chapters of a DVD as movie files so I can share them online (this is a DVD of home movies essentially, so there shouldn't be any copying issues). I have been trying to save the videos using Quicktime's screen recording features, but whenever I click record and have selected the area where the video is playing the video turns to a grey screen. I can still hear the audio playing, but the image remains a grey box until I stop recording. Any suggestions?

    Interesting... is this easy to figure out?
    That would likely depend on what you want to do.
    The simplest approach would be to open the app and navigate to the VIDEO_TS folder on your DVD (or HDD if you already copied the folder to your system). Next select the specific "Title" you wish to transcode if there are more than one on your DVD. Since you indicated you wanted to share "chapter" segments from your DVD, you would then select the "start" and "Through" chapters to be included. (E.g., if you want to share Chapter 5 on Title 1 of your DVD, then select Title 1 in the "Title" pop-up, Chapter 5 in the Chapter Start pop-up, and Chapter 5 in the "Chapter Through" pop-up.) Next, you press the "Toggle Presets" button to open and select a target "Device" or "Regular" preset option as needed. Add the job to your queue window. When all jobs are queued or if you are only processing a single job, press the "Start" icon to initiate processing of your content.
    You can, of course, create and save custom user presets but that implies you know how to use the various tab window options for best encoding results. This app is very powerful but can be used by anyone from a novice just starting out to an experienced pro depending on their level of expertise. If you can access your source content sequentially (i.e., copied to an HDD or have multiple DVD players loaded), you can use it to "Batch Process" multiple VIDEO_TS folders in a single session while you engage in other activities like sleeping or working.
    Any specific questions regarding use not covered by the site manual (see Help menu in app)?

  • JButton - avoid color change when clicked

    Hello All,
    probably this is a simply question, but i didn't find the answer.
    I have some JButtons in my window. When they are clicked, they change
    their background color for a momement (normal behavior). This is what I
    want to avoid. How could I do this?
    Thank you in advance.
    Ralf

    i haven't got the soources at the moment, but check it out from there... it's probably defined in some L&F class, like ButtonUI or something... you'd probably need to create custom *UI class.
    if you extend BasicButtonUI and override protected void paintButtonPressed(), then you may have it do as little as you please.
    easyest way would probably be copying original one, and then have it paint background with original background color, or not to fill it at all..

  • Menu buttons turn grey when rendered

    Hi there,
    I have 2 DVD menus with buttons which were created in Photoshop.  The Colour Sets are assigned by a custom colour set in Encore and work fine in preview (green normal, red highlighted and orange selected.)  When I preview in Encore the menus are the perfect colours.
    When I Build an ISO of the DVD image or a DVD folder however they appear grey on one menu and grey with what appears to be red text misaligned and masked on the other.
    I'm using VLC media player to preview the ISO/ DVD folder.
    Can anyone help?
    Cheers

    (by the way, you can remove or change the font-weight if you
    like)
    Michael Hager
    www.cmhager.com
    "Michael Hager" <[email protected]> wrote in message
    news:eo0d5l$jn0$[email protected]..
    > Use CSS...
    >
    > a:visited { font-weight: bold; color: #CCCCCC;
    text-decoration: none}
    > a:hover { font-weight: bold; color: #FF0000;
    text-decoration: none}
    > a:active { font-weight: bold; color: #6633CC;
    text-decoration: none}
    > a:link { font-weight: bold; color: #CCCCCC;
    text-decoration: none}
    >
    > (set colors as desired)
    >
    >
    >
    > "MariNor" <[email protected]> wrote in
    message
    > news:enudia$71j$[email protected]..
    >> Can anyone help me with my menu buttons? I want to
    have a red text
    >> without
    >> underline, but they turn blue and underlined when I
    hyperlink them. What
    >> can I
    >> do to avoid the automatic formatting for hyperlinks?
    I have the menu
    >> buttons in
    >> a table in the library.
    >>
    >> Earlier I used flash text, but then I first had to
    click at the button to
    >> delete some kind of security filter before I had to
    click again at the
    >> button I
    >> wanted. Anyone that knows something about that? I
    really liked the flash
    >> text
    >> buttons that changed color when you rolled over
    them, but now I can't use
    >> it
    >> because of the extra clicking everyone has to do.
    >>
    >
    >

  • Skillbuilder Modal popup turns black when click submit button

    Hi,
    Ive used the great skill-builder's plug-in to display my page 2 popup modally from page1 by clicking a button and it works as expected. However i realized when i click the Submit button on the popup page it turns black(pls get me right here its the background of the popup page-page2 not the first page-page1 i am talking about) while refreshing.
    apex 4.1.0/Oracle 11g Ent,
    any help please...regards.

    Skillbuilder Modal uses software named "Colorbox" for its modal presentation. The first problem that you had probably occured because you had not yet selected a theme. The position of the close button varies depending on the theme that you select. You selected theme 1, therefore the close button is in the lower right hand corner. Some of the other themes may better suit your taste. There are 5 to choose from. BTW, these themes cannot be easily changed so you pretty much have to decide on 1 of the 5. I think Dan is working on some more options with future releases of SB Modal.

  • Text Mask Created in Motion Turns Grey When Imported Into Apple DVD Studio

    I have some type that is a mask for a flame video that allows the flame to only be seen through the shapes of the letters. This is a black background with the type "punched out" to all the flames to be seen. When import this into Adobe DVD Studio Pro the black background of the masked type turns into a grey. What can I do to get the black appearance I need? Thanks!

    Lets say the following is your square (just four words Top, Right, Bottom, Left)
    The words Top, Right, Bottom, Left can all be on one Photoshop B&W pict file that is used as an overlay, all the words in black over a whit background for instance. Note however, that buttons (when you drag the button area) are limited in how they can be made so it may take a little bit of tinkering to get the button area to be over the particular section of the overlay properly and some designs may not work.
    You can try other methods, succh as buttons over video, but the above is probably the easiest and most reliable way subject to design considerations

  • Background turns blue when opening new file or exiting file.

    Hello,
    I am working in Photoshop cs6 on a PC, Windows 7.  I was working on my Wacom tablet and accidentally dropped my pen tool on the tablet.  When I looked up, my background was blue.  I'm not sure what happened, but I can't figure out how to change it back to white.  It must have changed something, just don't know what.  This happens if I open a "new page" or if I open an exiting file.  I checked preferences, it all seems ok there. 
    Photoshop open normally as seen below.  Second photo show what it looks like when opening a new screen or an existing file.  Any help would be appreciated.
    Thanks

    There's a preference to change the color of the screen.  I'm not at a computer right now that has PS, but you might want to try right clicking with the move tool and see is there is a menu option for changing the color.  Or check the main preferences ctrl/cmd-k.

  • All of a sudden all the links in my page enlarge 100% and turn white when clicked

    Hi - This is my first website and I have learned so much, but now I have a very irritating problem that I'm sure can be fixed by deleting a few lines of code, but I have no idea what to look for. All of a sudden all the links on one page of my site started turning white and enlarging almost 100% when you click on them. We page is at www.goEarthWorX.com/products. It happens to all the links on my page, and now there are weird white lines around one of the top products' names as well. Any help in what is going on would be very appreciated, as the site is almost complete and now I have this problem I just can't figure out on my own. Thank you so much!

    CSS: /products/#7 (You have a LOT of CSS sheets. Try combining into one)
    "the links on one page of my site started turning white and enlarging almost 100% when you click on them"
    a:active {
        color: #FFFFFF;    font-size: 200%;
        font-weight: bold;
        text-decoration: none;
    "now there are weird white lines around one of the top products' names as well"
    .oneColElsCtrHdr #apDiv98 a {
        border-style: solid;    color: #FFFFFF;

  • Screen 'greys' when click MORE INFO and nothing appears

    Hey there,
    I'm having immense difficulty uninstalling an application. It has locked items and so it won't trash. I have tracked these items down and have begun unlocking them by using the list view and drilling down until I get to MORE INFO. At this point the item used to pop up showing Locked and I could just remove the x against locked and so eventually, after doing this countless times, unlock all the offending items and trash the stupid app. But suddenly, after doing this successfully for ages no little screen pops up when I hit GET INFO. Instead it all goes a delicate shade of grey and I can't do anything. I have two questions. 1. What do I do now? and 2. Is there a way to unlock all these things at once by doing it one level higher?
    They are, incidentally, all spreadsheet outlines in an accounting program I use (MYOB Account Edge) and although I have spent lots of time with the MYOB support desk I am a Mac user in a PC world and they are well-meaning but essentially uninformed about their program on this platform, even though they sell the Mac product as well as the PC version.
    I have, incidentally, checked for an uninstall program for this but can't find one, and the support desk also said just put it in the trash.
    Help greatly appreciated. I thought I'd found a way, albeit laborious, with the individual unlockings, and now even that isn't working.

    Is there a way to unlock all these things at once by doing it one level higher?
    Open the Terminal application in your /Applications/Utilities/ folder and enter the following:
    chflags -R nouchg
    followed by a space. Drag the folder into the Terminal window and press Enter. This command will usually unlock all locked items that you're the owner of anywhere inside the folder you dragged into the Terminal window.
    (13954)

  • Have latest updates for mac and iPhoto.  several of "events" now show as grey squares with a plan tree, no thumbnails when scrolling over as before.  Photos show when clicking on icon but not visible as a group.  What gives?

    Have the latest updates on my iMac and iphoto.  Recently several "Event" folders have turned to grey with a palm tree in the corner.  Before there was a "key" photo to help identify the event.  The event title is still at the bottom of the square but no key photo.  When i click on the icon, the photos that it contained show up, but when closed again disappear.  How do I correct this annoyance?
    Also:  One event that contains about 12 photos has a problem---some of the photos when clicked will enlarge and show individually on the screen and print out, while others when clicken on show a black background with an exclamation mark and will not print.  Thoughts?

    Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your iPhoto library database
    LN

Maybe you are looking for

  • Displaying the result of the TOP N query

    Hi all, we are facing a challenging task were we are going to build a query that gives the answer on the question: How many different materials (of the top sold) represent 80% of the total sales in quantity? The result should of the query should be v

  • What exactly does Classic do on the Mac computers?

    Hello, I migrated from a lovely old iMac g4 a while back and now have an iMac running 10.6.8. At some point after migrating everything over for some silly reason I decided I no longer needed Classic on this newer computer (I know, terribly foolish of

  • Dependent selectOneChoice

    Hi, I have a table called Parish with attributes ParishId, CountryId, CityId and AreaId. i have created a custom method in my application module for creating records with parameters the table parameters. I build the dependent selectOneChoices using n

  • Is there an internet browser component in swing or awt?

    Im developing an internet browser using swing, is there any component or that?

  • Data Protection Manager Client

    Hello collegues, is there an option to install Data Protection Manager Client (not the agent itself) for DPM 2012/2012 R2? We need an option for clients to backup/restore their's data on demand with GUI interface. I saw such an application in DPM 201