import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class GameDifficulty extends JFrame
{
JPanel jp = new JPanel();
JPopupMenu jpm = new JPopupMenu();
JSlider js = new JSlider();
JTextField jtf = new JTextField();
public GameDifficulty()
{
jp =(JPanel)this.getContentPane();
jp.setLayout(null);
jp.setBounds(0,0,400,300);
jpm.setBounds(0,0,400,300);
js.setBounds(100,50,200,60);
// js.setMaximum(100);
js.setMajorTickSpacing(30); //设置滑动条的最大间隔
js.setMinorTickSpacing(10); //设置滑动条的最小间隔
js.setPaintLabels(true); //显示数值标签
js.setPaintTicks(true); //显示最大及最小间隔条
js.setBounds(new Rectangle(40, 59, 216, 47));
jtf.setBounds(150,140,80,30);
jp.add(jpm);
jp.add(js);
jp.add(jtf);
this.setVisible(true);
this.setSize(400,300);
}
public static void main(String [] args)
{
new GameDifficulty();
}
}
以上是我写的,但是跟我想要的效果不一样,首先滚动条不能移动。其次不知道怎么把滚动条的值取出来放到文本框中。望前辈指点!