I've been having a problem when using JFrame and Applet in conjuction. Let me start off by saying that individually the code executes fine, but when run through the applet the icons(pictures) disappear but the clicking field remains, so where the icon is I can click and it functions fine but defeats the purpose of GUI. So my questions, can I fix this problem with some simple code like setVisible(true); and how would I go about doing this. Can I somehow integrate the Jframes into the applet or modify the code to work in the applet.
This is a Paint program, the Applet is the main drawing area, the 2 JFrames are a ToolBox and a Color Chooser. I have external images used for them meaning, I call pencil.jpg
public GUIToolBox()
{
Container contentPane = getContentPane();
JPanel panel = new JPanel();
GridLayout layout = new GridLayout(5,1);
layout.setHgap(0);
layout.setVgap(0);
panel.setLayout(layout);
ButtonGroup group = new ButtonGroup();
pencilBox = new JRadioButton(new ImageIcon("Pencil.jpg","pencil"));
pencilBox.addActionListener(this);
group.add(pencilBox);
panel.add(pencilBox);
//etc...
}
In the main, init method
public void init()
{
w = 600;
h = 600;
Graphics2D g2 = (Graphics2D) backg;
backbuffer = createImage(w,h);
backg = backbuffer.getGraphics();
backg.setColor(Color.white);
backg.fillRect(0, 0, w, h);
backg.setColor(Color.black);
addMouseMotionListener(this);
colors = new ColorChooser();
tools = new GUIToolBox();
tools.setSize(24,120);
}