Results 1 to 5 of 5
  1. #1
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default disable a java.awt.Button but not greying it out

    Hi guys


    How can I disable(make it unclickable) a java.awt.Button but not grey out the text on it?


    thanks in advance :)

  2. #2
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default

    Or otherwise, is there a way to make an awt label look like a button?

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default

    Is there a reason you're using AWT and not Swing?

  4. #4
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default

    Yes... I am working on a legacy application which was done using AWT in the 1500's or some thing and now have no option but to use AWT :(
    Last edited by alinaqvi90; 10-14-2010 at 04:25 PM.

  5. #5
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default found a solution...

    Hi well

    After struggling a bit found a relatively decent solution incase it helps some one else I am posting it here:

    Add the label to a panel in GridbagLayout with the insets on left , right and top 1 pixel. Make the label and button different colours for e.g.:

    java.awt.Panel panel = new Panel();

    panel.setLayout(new GridBagLayout() );

    label = new label("Button");


    GridBagConstraints c = new GridBagConstraints();
    //constraint settings
    //c.insets = new Insets(top, left, bottom, right);
    c.insets = new Insets(1, 1, 0, 1);
    panel.add(label, c);

    ps: My label background color was blue and I used the panel background color to be white and the labels started looking like buttons. You might need to play around with a few schemes to come up with some thing good :)


    cheers

Similar Threads

  1. Disable Radio button
    By AJG in forum New To Java
    Replies: 3
    Last Post: 05-10-2011, 11:09 AM
  2. Replies: 6
    Last Post: 11-22-2010, 11:55 AM
  3. Disable Save button - Acrobar Reader
    By Deepa in forum New To Java
    Replies: 1
    Last Post: 03-06-2009, 12:15 PM
  4. Disable the WebBrowser Back button
    By Deepa in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 11-26-2008, 09:10 PM
  5. how disable the display of close button on the frame
    By kalanidhi in forum New To Java
    Replies: 6
    Last Post: 11-19-2008, 09:51 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
  •