abhi376
asked on
JSlider on Applet
Hello,
I'm trying to add a JSlider component to java applet. Its not visible on load . when I click on the component its visible again. I tried everything.
I have a background color for the panel which is not visible.
I'm attaching the snaps and code . The class extends JApplet
-Abhi
public void init() {
Container content = getContentPane();
content.setBackground(Color.white);
content.setLayout(new BorderLayout());
JPanel panel = new JPanel();
panel.add(textField);
// panel.add(slider);
panel.setBackground(Color.white);
addButtons(panel);
panel.add(stepButton);
panel.add(resetButton);
panel.add(slider);
add(panel, "North");
}
I'm trying to add a JSlider component to java applet. Its not visible on load . when I click on the component its visible again. I tried everything.
I have a background color for the panel which is not visible.
I'm attaching the snaps and code . The class extends JApplet
-Abhi
that code looks ok, problem appears like its elsewhere in your code
ASKER
I just intialized the slider. I'm not even using it anywhere. Does awt components and swing components togther in a jpanel cause problem ??
yes they can, best not to mix them
ASKER
why is the panel background color now showing up ? I set the panel background color to be grey.
add:
panel.setOpaque(true);
panel.setOpaque(true);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I figured the problem