Results 1 to 4 of 4

Thread: JButton does not work in java swing

  1. #1
    Join Date
    Apr 2009
    Posts
    55

    JButton does not work in java swing

    I am working on Java swings. I have a case wherein I have a JButton present inside a JTable.

    I have also written a ButtonRenderer for the same.The problem is that whenever I place i click on the JButton created it does not open anything,the window remains still and nothing happens.

    How could I get rid of this.please help.

  2. #2
    Join Date
    Oct 2008
    Posts
    167

    Re: JButton does not work in java swing

    Code:
    button.setOpaque(false);
    button.setFocusPainted(false);
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
    setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
    setBorder(null) might work, but there is a bug sun explaining it is by design that the UI set a border on a component unless the client sets a non-null border which does not implement the UIResource interface.

    Rather than the JDK itself setting the border to an EmptyBorder when null is passed in, the clients should set an EmptyBorder themselves (a very easy workaround). That way there is no confusion about who's doing what in the code.

  3. #3
    Join Date
    Jan 2009
    Posts
    140

    Re: JButton does not work in java swing

    It is on the frame but you are not working with it. You need to call the setVisible(false) to the Frame which is shown and not to the just created one.

  4. #4
    Join Date
    Jan 2009
    Posts
    143

    Re: JButton does not work in java swing

    You need to write a cell editor in addition to the cell renderer. If you're not using a cell editor for the cell with the button, I don't see how that could be.

Similar Threads

  1. How to handle JButton Click Event in Java Swing
    By Kungfu Pandey in forum Software Development
    Replies: 3
    Last Post: 20-01-2012, 12:13 PM
  2. JButton to send command to Java console
    By Fox28 in forum Software Development
    Replies: 6
    Last Post: 21-07-2010, 10:03 AM
  3. Print in java using Swing
    By Sheenas in forum Software Development
    Replies: 3
    Last Post: 18-11-2009, 09:50 AM
  4. Java Swing and MySQL
    By shelton141 in forum Software Development
    Replies: 1
    Last Post: 22-09-2009, 08:50 AM
  5. Java swing help with repaint()
    By grudge in forum Software Development
    Replies: 4
    Last Post: 23-07-2009, 03:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,535,227.42830 seconds with 17 queries