Results 1 to 5 of 5
  1. #1
    poorbrain is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default Image in Card Layout

    I browsed around on google some and couldn't find anything really. Is there any way or fucntion to display an image on a certain panel in a card layout other than using the drawImage function under paint? because I believe you can't use paint with card layout can right?

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default

    CardLayout is only a layout :)
    You have to put a JPanel or something similar to the container with that layout. Then you can override paintComponent/paint and draw your image on this panel.
    Or you can use a Label and set the image as its icon

    How to Use CardLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

  3. #3
    poorbrain is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default

    like I said I am new to applets...

    but if you paint something, won't it just always stay on the screen when you flip the cards?

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

  5. #5
    poorbrain is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default

    I used the imageicon label way to use the add method to add the image to a panel.

    I was going to use labels for some text, but I want to be able to change the color and size of the text so I want to draw strings on it. how do you paint anything to a certain panel or "card"? like you mentioned?

    the only way I know how to paint is by using this:

    public void paint(Graphics g)
    {

    super.paint(g);
    g.drawString("hi", 0, 0);

    }

    is there even another to paint anywhere else outside of this function?

    I have done a lot of gogole searches searching around, I hat eto keep posting and askin g questions here and being annoying but i appreciate the help

Similar Threads

  1. Image into Grid layout
    By Jaxn77 in forum AWT / Swing
    Replies: 6
    Last Post: 02-10-2011, 03:02 PM
  2. Image into Grid layout
    By Jaxn77 in forum Java Applets
    Replies: 1
    Last Post: 02-10-2011, 03:18 AM
  3. Question Card Layout, Card Management
    By lrichil in forum AWT / Swing
    Replies: 1
    Last Post: 04-22-2010, 10:11 AM
  4. Edit layout Layout please help me
    By manhtungtnk28@gmail.com in forum New To Java
    Replies: 4
    Last Post: 11-23-2009, 08:41 AM
  5. Card Layout
    By Gilbee in forum NetBeans
    Replies: 3
    Last Post: 03-03-2009, 09:37 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
  •