Results 1 to 3 of 3
  1. #1
    navid is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default adding integer to the JPanel

    Hello everyone,

    I want to add the integer to the panel which is JPanel.

    Is there any method for it?

    because I used panel.setText(number) but it made error.

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

    Default

    setText must take a String, not a number, so you'll have to translate the number into a String. This can be done simply with String.valueOf(number).

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

    Default

    Also, JPanel doesn't have a setText(...) method, so you'll need to use a class that does have that method.

    db

Similar Threads

  1. Adding a JPanel to a JMenu - Focus issues
    By snoopygee in forum AWT / Swing
    Replies: 9
    Last Post: 05-06-2011, 09:53 AM
  2. adding a buffered image over a jpanel
    By fatmat9 in forum New To Java
    Replies: 1
    Last Post: 11-23-2010, 03:23 AM
  3. Having difficulty adding graphics to a JPanel
    By DrKilljoy in forum New To Java
    Replies: 20
    Last Post: 07-20-2010, 08:40 PM
  4. Problem on adding JButton on JPanel NEED HELP
    By boisk in forum AWT / Swing
    Replies: 15
    Last Post: 03-15-2009, 02:27 PM
  5. adding a jpanel in the middle of the script
    By 2o2 in forum AWT / Swing
    Replies: 11
    Last Post: 10-12-2008, 05:50 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
  •