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


 image1
 image2
LVL 6
abhi376Asked:
Who is Participating?
 
abhi376Connect With a Mentor Author Commented:
It will worked with JApplet and panel. Again Jpanel here messes the things up
0
 
objectsCommented:
that code looks ok, problem appears like its elsewhere in your code
0
 
abhi376Author Commented:
I just intialized the slider. I'm not even using it anywhere. Does awt components and swing components togther in a jpanel cause problem ??
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
objectsCommented:
yes they can, best not to mix them
0
 
abhi376Author Commented:
why is the panel background color now showing up ? I set the panel background color to be grey.
0
 
objectsCommented:
add:

panel.setOpaque(true);
0
 
abhi376Author Commented:
I figured the problem
0
All Courses

From novice to tech pro — start learning today.