JButton question

How do you change the background color of a JButton? For instance, I want the button to be the normal gray by default, then when you click it I would like it to turn Yellow.
Any ideas?
Thanks in advance.

JButton jb = new JButton("Button");
jb.setBackground(Color.YELLOW);
jb.setForeground(Color.GREEN);Then take action once the button has been pushed.
Lance

Similar Messages

  • Stupid JButton Question

    Really 2 questions
    1) Ive noticed in the tutorials a high level object in which JButton objects are placed all implement ActionListener, and correspondingly implement
    public void actonPerformed(ActionEvent e)
    somewhere
    Ive been going over some code I wrote a while ago (I forgot how to do all this stuff for my new app from then till now) and I noticed I was always doing
    someButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    executeSomeMethod();
    I realize that if all the buttons invoke independent methods it is probably better to use the second method.
    In the application I am currently developing the buttons are used to select parameters for the method invoked. Im thinking the first method might be better -- I am asking if this is the case, and if it is best to follow the tutorials (I was thinking they might be a bit old, so maybe are out of date)
    This leads up to question 2).
    The buttons select which items to remove from an internal list. Each button ids an item. How do I identify the button when the actionPerformed method is invoked? I know about setActionCommand().
    Q 2a is: Is there a better way to id the button? Each Button is associated with a Card (as in a poker deck), so the cards/buttons are IDd by a byte for suite, and a byte for value. I would like to avoid comparing strings if possible.
    Thanx in advance.

    // Action Command can be anything
    JButton[] but = new JButton[totalButtonCount]; // an array could be used (Vector = best)
    for(int x = 0; x < but.length; x++) {
        but[x] = new JButton(buttonText);
        but[x].setActionCommand("but " + x); // a string with the current index
        addButton(but[x], location);
    // So when parsing
    public void actionPerformed(ActionEvent e) {
       Object source = e.getSource();
        if(source instanceof JButton) {
             JButton but = (JButton) source;
            for(int x = 0; x < totalButtonCount; x++) {
                 if(but.getActionCommand().equals(but[x].getActionCommand) );
                     fireButtonAction(but.getActionCommand());
    } Is this of any help?
    ICE

  • JButton question, with clarification

    here is what i want for my JButton:
    | 1 |
    and here is what is happening:
    | ... |
    the reason I think what is happeneing is happening is because the size of the button is too small, so it is not displaying the "1" inside it.
    the trivial solution of increase the size of the button to allow the label to display is useless for me. I need the size to be 32x32 pixels.
    how do i FORCE the label to display. i have tried messing with the fonts, with the layout, everything.
    plz help.
    thnx.

    All you need to do is set the border to a minimal size, i.e.
         Dimension d = new Dimension (size, size);
              but.setPreferredSize (d);
              // but.setSize (size, size);
              Insets i = new Insets (1,1,1,1);
              but.setMargin (i);
    Here is my whole test program:
    import java.awt.*;
    import javax.swing.*;
    public class ButtonTest extends JPanel {
    JButton but = new JButton ("1");
    public ButtonTest (int size) {
         Dimension d = new Dimension (size, size);
              but.setPreferredSize (d);
              // but.setSize (size, size);
              Insets i = new Insets (1,1,1,1);
              but.setMargin (i);
    add (but);
    public void printSize () {
         Dimension d = but.getSize();
         System.out.println ("width = " +
                                  d.width + " height = " + d.height);
    public static void main (String [] args) {
    JFrame frame = new JFrame ("Border Test");
    Integer s = new Integer (args[0]);
    ButtonTest ats = new ButtonTest(s.intValue());
    frame.getContentPane().add("Center", ats);
    frame.pack();
    //frame.setSize (100, 100);
    frame.setVisible (true);
    ats.printSize();

  • ActionListener of Jbutton Question

    Hi there,
    I am trying to perform a command via JButton by adding an ActionListener to the frame'instance' of my Pointframe:
    public class MainClass {
      public static void main(String[] args)  {
      try {
      byte[] datasend = new byte[50];
      byte[] tempdatareceive= new byte[1000];
      int incomingPackageSize = 0;
      //create instance of GUI
      Pointframe frame = new Pointframe();
      frame.pack();
      frame.show();
      //add Action Listener stuff
          ActionListener SendStream = new ActionListener()
          public void actionPerformed( ActionEvent e ) {
          System.out.println("this works");
      frame.jButton1.addActionListener( SendStream );
      //create Socket to Connect to EmScon-Server
      Socket connectToEsServer = new Socket ("192.168.0.5",700);
      //create Output Stream to send data to Server
      DataOutputStream StreamtoEsServer
      = new DataOutputStream(connectToEsServer.getOutputStream());
      //create Input Stream to send data to Server
      DataInputStream StreamfromEsServer
      = new DataInputStream(connectToEsServer.getInputStream());
    ................Sending commands like above to the console works fine so far.
    But as long as i start to try invoking variable relatedcommands.
    public class MainClass {
      public static void main(String[] args)  {
      try {
      byte[] datasend = new byte[50];
      byte[] tempdatareceive= new byte[1000];
      int incomingPackageSize = 0;
      //create instance of GUI
      Pointframe frame = new Pointframe();
      frame.pack();
      frame.show();
      //add Action Listener stuff
          ActionListener SendStream = new ActionListener()
          public void actionPerformed( ActionEvent e ) {
         StreamtoEsServer.write(datasend);
      frame.jButton1.addActionListener( SendStream );
      //create Socket to Connect to EmScon-Server
      Socket connectToEsServer = new Socket ("192.168.0.5",700);
      //create Output Stream to send data to Server
      DataOutputStream StreamtoEsServer
      = new DataOutputStream(connectToEsServer.getOutputStream());
      //create Input Stream to send data to Server
      DataInputStream StreamfromEsServer
      = new DataInputStream(connectToEsServer.getInputStream());
    ................I receive errmessages like:
    "MainClass.java": Error #: 480 : local variable datasend is accessed from within inner class; needs to be declared final
    "MainClass.java": Error #: 300 : variable StreamtoEsServer not found in anonymous class of method main(java.lang.String[])
    Can please somebody bring light into that?
    What is the best way to implement such stuff in general?
    Any ideas are greatly appreciated.
    Best regards,
    stonee

    Hi,
    try instantiaitng your variable datasend as private variable in the class outside your main-method

  • Another JButton question

    if I use a button image as my JButton, can I still write text over the image?
    consider this:
    JButton bttn = new JButton("a button");
    bttn.setIcon( new javax.swing.ImageIcon("d_eclipse.jpg") );will "a button" still be displayed over the image?

    Can be. There are methods in AbstractButton that control the appearance.
    Check out the API for javax.swing.AbstractButton setHorizontalTextPosition(), setHorizontalAlignment(), setVerticalTextPosition(), setVerticalAlignment().
    http://java.sun.com/j2se/1.4/docs/api/javax/swing/AbstractButton.html

  • Opening new forms using jbutton

    Hi i'm new to java, and i am currentley building an interface which has three buttons(cars,vans,red car). I have managed to create a class that opens a new window when the car button is clicked. However i am unsure of how to create different windows for when the other buttons are clicked.
    Heres my code ive based it on an example i found on here.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    public class Interface extends JPanel implements ActionListener {
    JDialog dialog;
    public Interface(JFrame f)
    dialog = new JDialog(f, "dialog");
    dialog.getContentPane().add(new JLabel("hello world", JLabel.CENTER));
    dialog.setSize(400,300);
    dialog.setLocation(425,200);
    public void actionPerformed(ActionEvent e)
    if(!dialog.isVisible())
    dialog.setVisible(true);
    else
    dialog.toFront();
    public JPanel getPanel()
    JPanel panel = new JPanel();
    JPanel selectPanel = new JPanel();
    JPanel ControlPanel = new JPanel();
    selectPanel.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("Select Piece Type:"),
    BorderFactory.createEmptyBorder(5,5,5,5)));
    JButton cars = new JButton("Cars");
    cars.addActionListener(this);
    JButton vans = new JButton("Vans");
    JButton redcar = new JButton("Red Car");
    selectPanel.add(cars);
    selectPanel.add(vans);
    selectPanel.add(redcar);
    panel.add(selectPanel);
    return panel;
    public static void main(String[] args)
    JFrame f = new JFrame();
    Interface ae = new Interface(f);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(ae.getPanel(), "North");
    f.setSize(400,200);
    f.setLocation(200,200);
    f.setVisible(true);
    Thanks for any help

    Thanks for the reply, i am now having trouble adding buttons to the dialog box. This is the code i am using:
    dialog = new JDialog(f, "dialog");
            dialog.getContentPane().add(new JLabel("hello world", JLabel.CENTER));
            dialog.setSize(400,300);
            dialog.setLocation(425,200);
            JButton buttonQuestion = new JButton( "Question" );
            dialog.getContentPane().add(buttonQuestion);For some reasson this turns the whole dialog pane into a button. So all i get is a dialog box with question in the middle. What i need is the hello world label to be displayed, with the questin button underneath
    Thanks for any help

  • Jbutton to open a htm file in browser - simple question

    not sure where to look for this, but its a simple question
    I just want to get a jbutton (from a jFrame)to open a local htm page eg:
    When pressing the button open:
    C:\Documents and Settings\****\My Documents\profile.htm
    - Open this with any browser
    any pointers to look in the right direction, couldn't find it with search
    I dont want to use a JEditorPane to display the htm, just open any browser
    Edited by: Mr_Tuition on Dec 7, 2007 3:40 AM

    I also wont be able to use it to open an local file which will be set up differently on each computer:
    C:\\Documents and Settings\\***\\My Documents\\JavaProjX\\Preview\\profile.htmI want to use just: Preview\\profile.htm so it opens from the same location with different users, but
    try { Process process = Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE Preview\\profile.htm");}
         catch(IOException e) { System.out.println("could open IE");}opens: http://preview/profile.htm (incorrect location)
    I have just found I can use System.getProperty("user.dir"); to get the location of my program (i think)
    Edited by: Mr_Tuition on Dec 7, 2007 4:25 AM

  • Quick question about JButton...

    All right, so I'm in my first year second semester of computer programming. On Monday of this week we had a test� on this test we had this question:
    Which of the following methods does JButton not have?
    (A) setLabel()     (B) setEnabled()
    (C) setText()     (D) setVisible()
    Now.. I may only be a programming one student but I have taken it upon myself to learn as much as I can about Java gui� and when I saw this question I realized that JButton had all of these methods, as of Java 5.0 it does at least, so I thought maybe the answer he was looking for was the deprecated method (setLabel) so I chose that one. Seems I was wrong; according to my teacher setText is a non-existent method in JButton. Having used setText before I knew that JButton had it so I pulled up the Java docs and showed my teacher� his response was to mumble something about how it does not have this method when using the BreezySwing package, which is what he had been teaching to the class. When I slowly explained to him that he was in fact wrong about that even when using BreezySwing his response was to tell me he�d think about changing the question. I was just wondering, am I right or is my teacher right?

    tell your teacher to grow up and stop teaching people with these silly third-party libraries they'll probably never use again in their career. it's just confusing, as evidenced by his own confusion. tell him I said so, and he's free to discuss the matter here with me if he wants to

  • JButton background color question

    Hi everybody,
    I have a feeling I'm going to get slammed for this, but I have to ask a very general question and hope for an answer.
    I have a JDialog on which buttons don't seem to hold their background color. That is, when I use setBackground, the only color change I get is a very thin outline of the color, and the rest of the button is white. The strange thing about the button is that the white center actually seems transparent--if I change the panel the button is on to another color besides white, the center of the button turns that color.
    I've tried to solve this problem with setOpaque( true ), setContentAreaFilled( true ), setBackground( color ), setForeground( color ), and I'm pretty sure every combination of those.
    Unfortunately, I haven't been able to reproduce this in a test case, so I can't give a SSCCE, although I've tried for a while now to make one.
    So...has anyone ever run into a problem like this and can give me some advice? I'm sorry I can't be more specific, if anyone has a question I'll do my best to answer.
    Thanks,
    Jezzica85

    I have a feeling I'm going to get slammed for this, but I have to ask a very general question and hope for an answer.Why would people be harsh on you? The only risk you take is: vague question => vague answer (or random).
    So...has anyone ever run into a problem like this and can give me some advice? I'm sorry I can't be more specific, if anyone has a question I'll do my best to answer.Never seen that myself, so I'll add a few random questions/thoughts:
    I have a JDialog on which buttons don't seem to hold their background color. That is, when I use setBackground, the only color change I get is a very thin outline of the color, and the rest of the button is white.- are you using a custom JButton subclass? If yes are you certain the subclass does not override paintComponent()?
    - If not, the button is painted by its ButtonUI. Can you tell which UI class is used (sysout(+theButton.getUI()+)?
    The UI is set according to the LookAndFeel.
    - Do you set any special LookAndFeel (+UIManager.setLookAndFeel(...)+, or look and feel's UIDefault properties in your app (generally that is done at startup)?
    - If not, can you tell the current look and feel when you bring up the dialog (+UIManager.getLookAndFeel(...)+, although that can be inferred from the ButtonUI subclass' name.
    I've tried to solve this problem with setOpaque( true ), setContentAreaFilled( true ), setBackground( color ), setForeground( color ), and I'm pretty sure every combination of those.FYI, the ButtonUI paints the button however it sees fit; in particular it doesn't have to respect the colors, opacity, filling... properties.
    Eventually:
    - are you using a custom JDialog subclass (probably, as that's generally how people write dialogs; not the best way IMHO, but there are cases where this is hard to avoid).
    I see you can't provide an SSCCE right ow, but maybe you can try to narrow the list of suspects in your side?
    - Do you reproduce the same problem at startup, if you bring the JDialog up as soon as possible?
    - Do you reproduce the problem with a mere JOPtionpane.showMessageDialog(..., theButton,...)?
    - Do you reproduce the problem outside of the JDialog context (I see you mention using a different JPanel, but is that in the dialog or somewhere else?
    Good luck with your investigations.
    Edited by: jduprez on Sep 30, 2009 8:20 AM

  • Quick question - JButton containing an Image - removing the Images border?

    Hi, I have a JButton with an image inside it.
    I would like the JButton to have a border, but not the image when it is clicked.
    It currently looks like this - here
    As you can see, there are two borders (this is once the button has been clicked).
    The one around the JButton is the one I wish to keep, the one around the ImageIcon is the one I would like removed.
    I am sure there is a simple way to do this - I'm sure I have managed it before.
    part of the code used to create:
    JButton money = new JButton();
    money.setBackground(buttonColor);
    money.setIcon(new ImageIcon ("money.gif");

    That thin blue box is indicating the button has focus. It appears even if the button just shows text and has no icon. Here is an example where I get rid of it on btn1 but not btn2.
    And in the future, please post Swing questions to the Swing forum.
    import java.awt.*;
    import javax.swing.*;
    public class ButtonExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    new ButtonExample().launch();
        void launch() {
            JPanel cp = new JPanel();
            JButton btn1 = new JButton("button 1");
            btn1.setFocusPainted(false);
            JButton btn2 = new JButton("button 2");
            cp.add(btn1);
            cp.add(btn2);
            JFrame frame = new JFrame("ButtonExample");
            frame.setContentPane(cp);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    }

  • Quick question on swing JButton (java programming)

    hi,
    Before you read, i am still a student! so if this question seems silly i am sorry, but i havent been able to find an answer!.
    I am using the following type of code:
    JButton SlowDownB = new JButton(new ImageIcon("Images/slow.jpg"));
    But the problem i have is that i am adding images of various sizes to different buttons, and i want all the buttons to be the same size (in a row). So i set the button sizes as follows:
    SlowDownB = new JButton(new ImageIcon("Images/slow.jpg"));
    SlowDownB.setPreferredSize(new Dimension(60,60));
    SlowDownB.setMaximumSize(new Dimension(60,60));
    SlowDownB.setMinimumSize(new Dimension(60,60));
    But now the problem is that it does not show the whole image :-(, is there a way to make the image/icon resize into the button?
    Thanks in advance to any replies,
    Regards,
    Daniel

    Maybe something like:
    List buttons = new ArrayList();
    // add the buttons to the List.
    Rectangle bigRect = new Rectangle();
    Rectangle r = new Rectangle();
    Dimension d = new Dimension();
    for (Iterator i = buttons.iterator(); i.hasNext();) {
      JComponent comp = (JComponent)i.next();
      r.setSize(comp.getSize(d));
      bigRect.add(r);
    d.width  = bigRect.width;
    d.height = bigRect.height;
    for (Iterator i = buttons.iterator(); i.hasNext();) {
      JComponent comp = (JComponent)i.next();
      comp.setSize(d);
    }

  • I have a question for JButton object

    JButton myButton = new JButton("a");
    if (myButton.getText()=="a"){
    myButton.setText("b");
    When event take place Text's value will become "b" on the myButton, but try again myButton.getText() method get hold of value as has of is "a".
    FtpFrame.java
    import javax.swing.*;
    import java.awt.*;
    public class FtpFrame extends JFrame
    JButton myButton = new JButton(" a ");
    public static void main(String args[])
    FtpFrame window = new FtpFrame("NextJoin Ftp For Java");
    window.setVisible(true);
    public FtpFrame(String title)
    getContentPane().add(myButton,BorderLayout.NORTH);
    myButton.addMouseListener(new FtpHandler(this,myButton.getText()));
    public void settrantxt(String text)
    myButton.setText(text);
    FtpHandler.java
    import javax.swing.*;
    import java.awt.event.*;
    class FtpHandler extends MouseAdapter
    private FtpFrame ftpFrame;
    private String msg = "";
    public FtpHandler(FtpFrame ftpFrame,String msg)
    this.ftpFrame = ftpFrame;
    this.msg = msg;
    public void mouseClicked(MouseEvent e)
    if (1==1)
    endif:{
    if(msg == " a ")
    ftpFrame.settrantxt(" b ");
    break endif;
    if(msg == " b ")
    ftpFrame.settrantxt(" c ");
    break endif;
    if(msg == " c ")
    ftpFrame.settrantxt(" a ");
    break endif;
    public void mousePressed(MouseEvent e)
    public void mouseReleased(MouseEvent e)
    public void mouseEntered(MouseEvent e)
    public void mouseExited(MouseEvent e)
    Thank you very much for your help!!!

    I have change my code.
    if (1==1)
    endif:{
    if(msg.equals(" a "))
    ftpFrame.settrantxt(" b ");
    break endif;
    if(msg.equals(" b "))
    ftpFrame.settrantxt(" c ");
    break endif;
    if(msg.equals(" c "))
    ftpFrame.settrantxt(" a ");
    break endif;
    but question sa old of.
    the text of button is being set to " b " but can't set to " c ".

  • Question related to JButton action event

    Hi All,
    In my application a small issue has poppedup i.e. i am giving a JButton with an action and with that action a .bat file is getting generated and immediately i am making it to get executed by using the runtime class.Now my question is if i keep on firing the same button for 20 times same batch file is getting executed for 20 times.SO i want to control that process something like once the execution is done i need to have an acknowledgement so that i will be getting a chance to fire in the next.
    After first click on the JButton second click should not process anything till the first execution is done.
    How is it possoible to implement this??
    Any help appreciated.
    regards,
    Viswanadh

    Hi Camic and Andre,
    Thanks for the replies i will try out in both the ways and get back to you people.
    And camic as you were saying to go through Process class i have seen and immediately got a question.When i disable the JButton is it a right way that me getting the exitValue of the Process soemthing like
    Process p;
    if ( p.exitValue()==0){
    JButton.setEnabled(true) /enabling button
    }Is this the right way to do???
    regards,
    Viswanadh

  • JButton rotating through pictures(Forgot to mark as question)

    Hi, I have a question about working with pictures on Jbuttons. As some of you may know, I'm working on a Reversi-esque program. I've gotten it working where instead of pictures, the buttons display either Xs(representing black), Os(representing white) and " "(blank). Now instead of x's and o's, I want to use images for my buttons. Though for some reason, it does not work. I was wondering if you could take a look, primarily at the first bit of code, and point out if I'm handling the images wrong?
    Also, I keep the 'Images' folder inside the src folder of my Eclipse code with the two classes.
    Thank you for any help you might have to offer.
    public class ReversiGUI_Square extends JButton{
         ImageIcon black = new ImageIcon("Images/black.jpeg");
         ImageIcon white = new ImageIcon("Images/white.jpeg");
                    ImageIcon blank = new ImageIcon("Image/blank.jpeg");
         //Code that sets from O to blank
         //X to O,
         //Blank to X
         public void rotate(){
              if(equals(black)){
                   setIcon(blank);
              else if (equals(white)){
                   setIcon(black);
              else{
                   setIcon(white);
         public ReversiGUI_Square(){
              super();
              addMouseListener(new MyMouseListener()); //Watches for mouse actions
         public class MyMouseListener extends MouseAdapter{
              public void mouseEntered (MouseEvent e) { }
              public void mouseExited  (MouseEvent e) { }
              public void mousePressed (MouseEvent e) { }
              public void mouseReleased(MouseEvent e) { }
              public void mouseClicked(MouseEvent me){ //If click a button, use the rotate method.
                   rotate();
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //CODE FOR BOARD IS UNCHANGED FROM QUESTION 1
    public class ReversiGUI_Board extends JFrame {
         public int _nrows = 8, _ncols =8;
         public ReversiGUI_Square[][] _guiboard;
    public static void main (String[] args){
         new ReversiGUI_Board();
         public ReversiGUI_Board(){
              super("Reversi");
              _guiboard = new ReversiGUI_Square[_nrows][_ncols];
              setLayout( new GridLayout (_nrows, _ncols));
              for (int i = 0; i < _nrows; i++){
                   for (int j=0; j < _ncols; j++){
                        _guiboard[i][j] = new ReversiGUI_Square();
                        add(_guiboard[i][j]);
              pack();
              setSize(400,400);
              setVisible(true);
    }Edited by: DannyB13 on Nov 24, 2009 5:40 PM

    setIcon(blank);
         public void rotate(){
              Icon img = getIcon();
              if(img.equals(black)){
                   setIcon(blank);
              else if (img.equals(white)){
                   setIcon(black);
              else{
                   setIcon(white);
         }The error for this is at the very top 'setIcon':
    Multiple markers at this line
         - Syntax error on token "blank", VariableDeclaratorId expected after
         this token
         - blank cannot be resolved to a type
    For the other code where an icon is not set,
         public void rotate(){
              Icon img = getIcon();
              if(img.equals(black)){
                   setText(" ");
              else if (img.equals(white)){
                   setIcon(black);
              else{
                   setIcon(white);
         }The code will run up until I push a button, when a large string of errors I can't make heads or tails of comes up.
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at ReversiGUI_Square.rotate(ReversiGUI_Square.java:16)
         at ReversiGUI_Square$MyMouseListener.mouseClicked(ReversiGUI_Square.java:38)
         at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    So basicaly the best idea is to probably set it so that the second the program starts and the board is created, all the buttons are pre-set to the 'blank' image. I have no idea how to go about with that though.
    Edited by: DannyB13 on Nov 24, 2009 6:27 PM

  • JButtons and images question

    hey sorry to disturb people
    quick question about JButtons i have created several buttons all have been cretaed using an ImageIcon, i would now like to be able to change the image on the button when triggered by another event, is there a such method ( a bit like setText) that will allow me to change the image on the button
    thanks very much for your time
    pants3uk

    Reading the API, I find:
    setIcon(..);

Maybe you are looking for

  • Cursor jumps all over when connected to projector

    Hello Hoping someone can help me with this.  I have a MacBook that I connect to a projector frequently.  Recently whenever it's connected to the projector the cursor becomes "jumpy"  sometimes it will not respond and then all of sudden it jumps aroun

  • The correlation issues in OSM

    Hi! There are some questions about correlation in OSM. Can anyone detail the process of extracting jms message by automation plugins? It is said in Developer guide: "This property uses the correlation ID parameter, which is configured in the outbound

  • Init.d script to auto-start opmnctl startall

    Hi, My customer had created init.d script for 'opmnctl startall'. The script given below results in error stating that 'ulimit files cannot be set'. But, checking ulimit for root and oracle shows unlimited. Script: su - oracle -c "/app/oracle/product

  • Retrieving value of selected item in sap.m.list

    var data = {                 details :   [{                           Name : "MuthuKannan",  Age : "22",Location :"Bangalore" },           {  Name : "Sachin Tendulkar",  Age : "35", Location :"Mumbai"  }, var model = new sap.ui.model.json.JSONModel()

  • BufferedImage to ByteBuffer ?

    I have an applications that I am using Robot to do screen capture. The server that I am going to be connecting to from my Java app has a class that can accept org.apache.mina.common.ByteBuffer data. That data will then be encoded and create a video s