Results 1 to 5 of 5
  1. #1
    santhosh_el is offline Member
    Join Date
    Feb 2009
    Posts
    50
    Rep Power
    0

    Default i want to display decimal values in frame window

    dear sir,


    i am created a frame window in java swings.i need to display decimal values in a frame window. here is the code.pls any body can correct my code.


    JFrame frame=new JFrame();
    frame.setVisible(True);
    frame.setSize(200,200);

    System.out.println("value" + ":" + Double.Parsedouble(value1));

    this will display decimal value in console application,same value should be displayed in frame window.

    thanks
    santhosh

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    println() display the string you define on the console. Not on the frame. If you want to display something on the frame, add text on the label and add that label on the frame.

    Better if you can look at the Swing tutorial on the Suns website.

    How to Use Labels.

  3. #3
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    I am kind today :)
    Here you go...

    frame.getContentPane().add(new JLabel(String.valueOf(value1)));

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,229
    Rep Power
    19

    Default

    Read the API for JOptionPane

    db

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Webuser View Post
    I am kind today :)
    Here you go...

    Java Code:
    frame.getContentPane().add(new JLabel(String.valueOf(value1)));
    Initiate a new label, and set the text of it. Get the content pane of the frame ans add the label on that pane. :p

Similar Threads

  1. get percentage formatting to display 2 decimal places
    By gotenks05 in forum New To Java
    Replies: 5
    Last Post: 03-03-2009, 04:57 PM
  2. Replies: 4
    Last Post: 03-03-2009, 12:43 PM
  3. passing values from main page to pop up window
    By vicky in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-29-2008, 03:06 PM
  4. 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
  5. Read/Write of components of frame window
    By Harish kumara M in forum AWT / Swing
    Replies: 0
    Last Post: 09-17-2008, 08:14 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
  •