Results 1 to 2 of 2
  1. #1
    Itun is offline Member
    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0

    Default JButton Problems

    I create two identical buttons, but they are different on the display.
    Java Code:
            jButton1.setBackground(new java.awt.Color(204, 204, 255));
            jButton1.setForeground(new java.awt.Color(153, 153, 255));
            jButton1.setBorder(null);
            jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            jButton1.setFocusable(false);
            jButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
            jButton1.setPreferredSize(new java.awt.Dimension(8, 8));
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
    
            jButton2.setBackground(new java.awt.Color(204, 204, 255));
            jButton2.setForeground(new java.awt.Color(153, 153, 255));
            jButton2.setBorder(null);
            jButton2.setFocusable(false);
            jButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
            jButton2.setPreferredSize(new java.awt.Dimension(8, 8));

    And when mouse is on or I push the buttons they are also different.
    Last edited by Itun; 03-23-2011 at 06:42 AM.

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    6

    Default

    For better help sooner, create a SSCCE, that
    demonstrates the incorrect behaviour. The picture doesn't help us because we don't know the context of how that code is used. For example we don't know what layout manager you are using.

Similar Threads

  1. JButton ActionListener problems
    By Fortu in forum New To Java
    Replies: 6
    Last Post: 02-05-2011, 04:20 PM
  2. JButton setColor problems
    By brachaalizah in forum AWT / Swing
    Replies: 1
    Last Post: 10-29-2010, 04:10 AM
  3. Replies: 2
    Last Post: 04-21-2010, 06:34 PM
  4. Problems with ActionEvent for JButton
    By TrueBear in forum AWT / Swing
    Replies: 1
    Last Post: 08-24-2009, 04:26 PM
  5. Problems with jButton ActionPerformed
    By susan in forum AWT / Swing
    Replies: 3
    Last Post: 08-07-2007, 04:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •