Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 894
  • Last Modified:

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
0
abhi376
Asked:
abhi376
  • 4
  • 3
1 Solution
 
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
 
objectsCommented:
yes they can, best not to mix them
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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:
It will worked with JApplet and panel. Again Jpanel here messes the things up
0
 
abhi376Author Commented:
I figured the problem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now