JButton with Icon question

In the Toolbar I have a JButtons. I created the JButtons with Icons.
When I click on a button it is putting a dotted line right around the Icon. How can I get rid of that? Thanks.

You're talking about the focus rectangle. If memory serves in the SwingSet demo there's an entire panel devoted to buttons and such. You can find something there to help you. The toggle in the example is labeled "Paint Focus", and it does what you want.

Similar Messages

  • JButton with icons

    I need to create JButton with icon but have not much idea. Is there any code sample that may give me some insight? Any help is appreciated in advance.Thanks.

    Icon play = new ImageIcon("images/Play24.gif");
    JButton PlayButton = new JButton(play);

  • Can i paint a JButton with icon?

    i have jbutton with icon and when i push on him i want him to look like when he doesnt Enabled with gray color but i want him to be enable...
    How i do this?

    i dont want to add icon i want to paint the button in gray color
    like you take a jbutton with icon and you do setEnabled(False)
    Thanks

  • JButton with Icon greyed out

    Hi,
    I am writing a minesweeper program and I have a problem with the icons on the JButtons. Initially the button is set with a grey icon to cover the text normally visible on top of it. When the button is pressed two things happen:
    - its icon changes
    - it is disabled by setEnabled(false).
    My problem is that when when I use the setEnabled(false) method the icon is 'greyed' out. Does anyone know of a way round this?
    Thanks,
    Jolyon

    just set the disabledIcon to the desired Icon:
    button.setDisabledIcon(Icon icon );
    the grayed out one is a default Icon calculated by the button if no disabledIcon is provided.
    regards,
    stefan

  • "Packed" JButton with Icon

    Hi,
    This is not really a problem but here we go... I have this class, that just "packs" a JButton so it fits with the Icon on it.
    public class PackedButton extends JButton {
         public PackedButton(Icon icon) {
              super(icon);
              int w = icon.getIconWidth(), h = icon.getIconHeight();
              Dimension d = new Dimension(w + 10, h + 10);
              this.setMaximumSize(d);
              this.setPreferredSize(d);
              this.setMaximumSize(d);
    }This works, but when I start my application, the button doesn't look packed, I have to resize the mainframe to get the correct result...
    An idea? Refresh problem?
    Thanks!
    Jean

    just set the disabledIcon to the desired Icon:
    button.setDisabledIcon(Icon icon );
    the grayed out one is a default Icon calculated by the button if no disabledIcon is provided.
    regards,
    stefan

  • Jbutton with Icon

    Hi guys
    I would like to tune a little bit my graphical Interface.
    and I have used Icon on my J Button.
    But when I load my graphical interface and when I click on my new "Ion Jbutton" I cannot see the button pressed.
    The function is Ok, when I click on the button it works, but visually I cannot see the button "move" when I press it.
    Do you know what I have to change?
    thanks for your help
    ciao
    BR

    but visually I cannot see the button "move" when I press it.Then you are doing something wrong. The button contains a border that goes dark gray (on Windows) when you click the button to indicate the button has been clicked.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.

  • JButton with Icon - when pressed moves Icon

    When I press on a JButton which contains a icon then the icon is moved a little bit each time I press. Can I disable that?
    I need to place clickable images. Is a JButton the best method for this?

    URL url = this.getClass().getResource("weiher_original.jpg");
    ImageIcon icon = new ImageIcon(url);
    btnIcon = new JButton(icon);
    btnIcon.setSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
    btnIcon.setBorderPainted(false);
    btnIcon.setFocusPainted(false);
    getContentPane().add(btnIcon);Now if you press on the icon the image moves a few pixels until the mouse is released.

  • How to put an icon to Jbutton with Jbuilder 5?

    I have tried to make a jbutton with icon on it,
    i create an image icon object and pass it to the jbutton.seticon method...
    When create the image icon, it need the path of the icon file, what is the relative path of image in jbuilder?
    (not absolute e.g file:///)
    Thanks

    What you need to do is
    if your current class is Test and you image file is in the same directory called cat.gif then do the following
    button.setIcon(new ImageIcon(Test.class.getResource("cat.gif")));
    this should work
    if you image file is in the previous directory you just type in "../cat.gif" and if you have a image directory reltaive then you put in "images/cat.gif"
    I hope this helps

  • JButton help, icon +text position

    Hi, is it possible to have JButton with icon on far left and text between the icon and far right hand side?

    Yo can do it by using the setHorizontalTextPosition() method.
    here is one example
    import java.awt.*;//Frame
    import javax.swing.*;
    public class Test extends JFrame
         public Test()//Constructer. Creates the frame
              JButton bt = new JButton("Done", new ImageIcon("image.gif"));
              bt.setHorizontalTextPosition(AbstractButton.LEFT);
              setBounds(300,300,300,300);
              getContentPane().setLayout(new FlowLayout());
              getContentPane().add(bt);
              setVisible(true);//shows on the screen
         public static void main(String[] args)
              new Test();//Creates a new Instance of our class
    }

  • My computer suddenly refuse to start. When I turn it on it gives the startup sound but the screen is grey and after a while a little folder icon with a question mark inside turns up. It doesn't blink. What to do? Nothing happens if I try to start up from

    As I say my computer, a mac mini refuse to start. When I turn it on it gives the startup sound and the screen turns grey and stay that way for a long time. And in the end a small folder icon with a question mark inside (it doesn't blink) turns up in the middle of the screen.
    I have tried to start up from the installation CD holding down the C key on the keyboard. Same result. I have tried different key combinations while starting up. No result or rather same result. Nothing. Is the computer suddenly dead?
    I was about to buy a new computer but I need access to my data on this one (I write this on an iPad) but hven't yet found a way.
    Anybody have any good advice?
    I thought it was a software problem, that the computer couldn't find the startup software or something and maybe it is, but I am beginning to fear that it could be a hardware problem.

    You need to re install OSX. If you have the dmg file downloaded via torrentz this is how you can create a bootable external HD or Flash drive (8 GB+)
    https://discussions.apple.com/message/23957654#23957654
    Peace
    Harry

  • When I went to turn the desktop on, the start up sound came on.  Then the screen was white with an icon flashing. The icon is a file folder with a question mark on it.  I cannot get it to fully turn on.  HELP

    When I went to turn the desktop on, the start up sound came on.  Then the screen was white with an icon flashing. The icon is a file folder with a question mark on it.  I cannot get it to fully turn on.  HELP

    Run a disk repair tool on the hard disk or install a new OS.
    (59898)

  • When turned on MacBook a icon of a folder with a question mark in it keeps flashing, what does this mean?

    MacBook turns on but doesn't go to home screen, instead a folder icon with a question mark on it keeps flashing.

    It means that your mac is unable to boot, try doing a safe boot http://support.apple.com/kb/ht1455 first, if that does not work insert your OSX disc (the one that came with your mac) and boot to that, post back with a report.
    Is your backup 'bootable' (Carbon Copy or SuperDuper) or non-'bootable' (Time Machine)
    Message was edited by: Csound1

  • What does the icon of a folder with a question mark inside mean?

    After an overnight power outage I tried to turn on my iMac this morning, but all I got was clicking sounds and a gray full screen with the icon of a folder with a question mark inside it, blinking. (There's no tool bar that appears anywhere). What does that mean?
    I've tried unplugging the system and waiting a while before attempting another boot. Same screen.
    I recently (a month ago) upgraded to Snow Leopard from my original OS X software. Never had this sort of a problem before.The iMac was purchased around 2005 or 2006. Intel Dual Core processor.
    Thanks for any help on this.

    Thanks, Paul, for the prompt reply.Obviously, your answer isn't what I wanted to hear, but feared. When I get home tonight I'll try finding the install disk and booting from that. Fortunately, I still have a MacBook Pro that is running fine.  Incidentally, I have a Western Digital external Hard Drive that has very little, if anything on it. But since I can't open anything on the iMac, I guess I'll have to see if the install disk works before I try to figure out IF I can use that WD-External drive temporarily rather than replace the HD on the iMac. Any clues on what a replacement drive and labor runs for that sort of iMac repair?
    j

  • My MacBook Pro won't start - it just displays a grey screen with flashing icon of a folder with a question mark in the middle. Help.

    It started while I was using Adobe InDesign, and that program froze, then crashed. When I tried to reopen the program, the error message I received was simply "Error: 16".
    I tried to take a screen shot of the error message for reference, and it gave me a message saying I couldn't because I didn't have access to the files where it would normally store the shot.
    Attached to my computer at the time was my Seagate Free Agent Go-Flex for Mac backup drive.
    So, I closed any open applications, and restarted my computer. But it wouldn't restart. It only displays a grey screen with a flashing icon in the middle of a folder with a question mark on it.
    I have no idea what happened - I wasn't using the machine any differently than usual, and it only had a few basic applicaitons open in addition to InDesign (like Preview, Text Edit, Microsoft Word, iCal).
    I have MacKeeper on my MacBook, and I keep it clean.
    Does anyone out there know what this flashing icon indicates, and if there is anything I can try on my own to fix it?
    Thanks.

    ali har wrote:
    It started while I was using Adobe InDesign, and that program froze, then crashed. When I tried to reopen the program, the error message I received was simply "Error: 16".
    I tried to take a screen shot of the error message for reference, and it gave me a message saying I couldn't because I didn't have access to the files where it would normally store the shot.
    For the Error: 16
    http://kb2.adobe.com/cps/827/cpsid_82744.html
    Seems a uninstall and reinstall of CS is in order.
    Attached to my computer at the time was my Seagate Free Agent Go-Flex for Mac backup drive.
    May or may not be a contributing factor,  may have kicked in at a wrong time or running root code.
    So, I closed any open applications, and restarted my computer. But it wouldn't restart. It only displays a grey screen with a flashing icon in the middle of a folder with a question mark on it.
    Computer can't find a bootable volume.
    https://support.apple.com/kb/TS2570
    I have MacKeeper on my MacBook, and I keep it clean.
    Well that explains it, MacKeeper is almost malware.
    http://applehelpwriter.com/2011/09/21/how-to-uninstall-mackeeper-malware/
    Search the forums here for "MacKeeper" they will tell the whole story, crapware.
    Disconnect all drives, follow the "Grey Screen" instructions and hold Shift key down while booting, if you get into OS X , immediatly backup your files to another drive and disconnect.
    In my opinion you should first check to make sure you have a backup of your data, then just erase the entire internal drive (hold c boot off the 10.6 disk, use Disk Utility), reinstall OS X, same user name, update to 10.6.8, c boot off the 10.6 and Repair Disk (to fix a update error) install your programs and finally return files from backup into the same main user folders like before (Music, Docs, Pictures etc.)
    A pain it is, but you've hosed your system and in the process you might as well rebuild everything and have a fast machine again. So happens to clear MacKrapper, uninstall CS5 and any other junk in your system at the same time. Fresh, clean, lean and mean.
    Learn to Carbon Copy Cloner to a external drive that new pristine boot drive, you can hold the option key and boot from it (even update it), which is a real bacon saver when something like this happens.  Also it's free to use, donations accepted.
    http://www.bombich.com/
    Note: if anything above I've mentioned is too complicated or your not sure, seek the services of a local computer specialist.

  • HT1338 MacBook Pro 13.3: Desktop screen will not come up when turned on.  Screen is blank except for an icon of a folder with a question mark on it, in the middle of an otherwise blank screen, laptop making a clicking noise.

    My MacBook Pro 13.3 MAC OS  X v10.7 laptop will not come up.  Blank screen comes up, no color/desktop, etc., only an icon of a folder in the middle of the screen with a question mark on the folder.  Laptop making a clicking noise. Suggestions? Thanks!

    It's under warranty. Take it in to have Apple fix it.
    The "flashing ?" means the machine can't find the start up disk. The clicking noise is a give away that the drive is damaged.

Maybe you are looking for