Link to home
Start Free TrialLog in
Avatar of abhi376
abhi376Flag for United States of America

asked on

JSlider on Applet

Hello,

 
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");
}

Open in new window


  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


 User generated image
 User generated image
Avatar of Mick Barry
Mick Barry
Flag of Australia image

that code looks ok, problem appears like its elsewhere in your code
Avatar of abhi376

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
Avatar of abhi376

ASKER

why is the panel background color now showing up ? I set the panel background color to be grey.
add:

panel.setOpaque(true);
ASKER CERTIFIED SOLUTION
Avatar of abhi376
abhi376
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of abhi376

ASKER

I figured the problem