Results 1 to 7 of 7

Thread: JButton Problem

  1. #1
    wassim is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default JButton Problem

    Hello ,

    i'm a new a java beginner user...

    i'm trying to create a JButton that it contain x^2 , i want the number 2 to appear like a superscript .

    also i have a text field , and i want to display a text with a multiple color in the same text field ....

    so how can i do this ????

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You can try to use HTML mark up in the text used as the button's label.

  3. #3
    wassim is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default

    Dear Fubarable,
    10 for the reply

    i'm using netbeans 6.5 , i've tryed to edite the text of the JButoon , and i've entred something like <b>my text</b> but it doesen't work .
    the display is <b>my text</b>.

    also i've tryed to ented <html><body><b>my text</b> , but also it doesn't work .

  4. #4
    jurka is offline Member
    Join Date
    Jul 2008
    Posts
    67
    Rep Power
    0

    Default

    This code works for me

    Java Code:
    String str = "<html><font color=green>Hello<sup>2</sup></font></html>";
    JButton button = new JButton(str);

  5. #5
    wassim is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default

    ok , now it's ok .....

    thank you very much ,

    The JButoon is ok, but the JTextfield won't to be formatted ....

    The problem was with the body tag <body>.....

    i have another question , can i use css in my application form's so it will be faster to change the design of my application after a time ????
    Last edited by wassim; 02-18-2009 at 10:39 PM.

  6. #6
    jurka is offline Member
    Join Date
    Jul 2008
    Posts
    67
    Rep Power
    0

    Default

    Quote Originally Posted by wassim View Post
    ok , now it's ok .....

    thank you very much ,

    The JButoon is ok, but the JTextfield won't to be formatted ....

    The problem was with the body tag <body>.....

    i have another question , can i use css in my application form's so it will be faster to change the design of my application after a time ????
    I know this possibilty is in QT-jambi but not in Swing :rolleyes:.

  7. #7
    wassim is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default

    thanks for the reply,

    i think i have to download a additional packages or plug ins to the netbeans to use QT-jambi !!!!

Similar Threads

  1. Jbutton not working??
    By rmabrey in forum AWT / Swing
    Replies: 7
    Last Post: 09-24-2008, 06:30 PM
  2. Help with JButton
    By geoffreybarwise in forum New To Java
    Replies: 4
    Last Post: 05-21-2008, 11:48 AM
  3. Need help with JButton event
    By adlb1300 in forum New To Java
    Replies: 2
    Last Post: 11-19-2007, 02:15 AM
  4. Problem with JButton
    By Marcus in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 06:56 AM
  5. Mouse over JButton
    By sandor in forum AWT / Swing
    Replies: 1
    Last Post: 05-17-2007, 10:15 PM

Posting Permissions

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