Results 1 to 9 of 9
  1. #1
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default Questions On Java GUI Library

    I got a few questions on Java GUI.

    Firstly, how do you change the background picture of a JPanel to a gif. I have only been taught simple GUI like JRadioButton,JButton etc.

    2) How do I import com.sun.java.swing ? I can seem to find the jar file. All I discovered was 421 class files and I dunno what to do?

    3) For those using netbeans, how do you see the code from Desktop Application?

  2. #2
    maxim is offline Member
    Join Date
    Apr 2008
    Posts
    15
    Rep Power
    0

    Default

    to use the swing API

    you just put

    PHP Code:
    import javax.swing.*;
    tutorial here on JButtons with images
    h**p://java.sun.com/docs/books/tutorial/uiswing/components/button.html

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    Here is a post about adding an image to a JPanel. Ignore the first few comments.

  4. #4
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default

    Ummm. how do I change the entire JPanel into a gif picture that I want? Not as background but as foreground?

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

    Default

    If you want to display an image with nothing on top of it, no buttons, textfields, etc, then don't use a JPanel. Place the image into an ImageIcon and then the ImageIcon into a JLabel and then add the JLabel to whereever you want to display your image.

    If you search the Sun tutorials on JLabel and ImageIcon, you'll see much more detail on this and sample code. Good luck.

    Also: if this is not what you want to do, then please post back with more details on your problem. Again, good luck.

  6. #6
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    Fubarable is correct. I was about to say the same thing when I saw his post. I misunderstood your question...

  7. #7
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default

    ok solved. How do you make the [solved] thing?

  8. #8
    devunion is offline Member
    Join Date
    Jun 2008
    Posts
    56
    Rep Power
    0

    Default

    Quote Originally Posted by hitmen View Post
    2) How do I import com.sun.java.swing ? I can seem to find the jar file. All I discovered was 421 class files and I dunno what to do?
    You need NEVER import these packages for your app. the can be used for internal implementation of Swing only.
    Try Controls4J - Advanced Swing Components.

  9. #9
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    7

Similar Threads

  1. Pls i need help with these 2 Java Questions
    By jyde in forum New To Java
    Replies: 23
    Last Post: 11-11-2008, 06:23 AM
  2. Pls i need help with these 2 Java Questions
    By jyde in forum Advanced Java
    Replies: 2
    Last Post: 10-19-2008, 08:33 PM
  3. Java Questions...
    By Xarver in forum New To Java
    Replies: 11
    Last Post: 09-20-2008, 06:37 AM
  4. Few Questions about java
    By Grom in forum NetBeans
    Replies: 11
    Last Post: 09-13-2008, 03:26 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
  •