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?
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)
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?
Not if the painting is done on the cards themselves.
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)
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