For some reason the Jlist
will not show up on my applet.
It shows up just right of the slider but only when you click on the individual elements.
I tried this.validate()
and this.repaint()
with no luck. Can anyone help me out?
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import java.awt.Graphics;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.ListSelectionModel;
public class HeatingHome extends JApplet implements ActionListener
{
// declare variables here
JRadioButton switchIt = new JRadioButton();
JSlider tempControl = new JSlider(JSlider.VERTICAL, 10, 15, 11);
String[] theRooms = {"Porch", "Kitchen", "Living Room", "Hall", "Bedroom 1", "Bathroom", "Bedroom 2"};
JList roomsList = new JList(theRooms);
public void init()
{
setSize(1000,600);
}
public void paint(Graphics g)
{
super.paint(g);
roomsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
roomsList.setBounds(700, 200, 150, 150);
roomsList.setVisible(true);
roomsList.setEnabled(true);
add(roomsList);
//tempControl.addChangeListener(e);
tempControl.setMajorTickSpacing(10);
tempControl.setPaintLabels(true);
tempControl.setMinorTickSpacing(1);
tempControl.setPaintTicks(true);
tempControl.setBounds(600, 200, 100, 200);
tempControl.setEnabled(true);
add(tempControl);
}
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}