package first;
import javax.swing.*;
import javax.swing.border.TitledBorder;

import java.awt.*;
import java.awt.event.*;
class P extends JPanel
{
	JProgressBar pb=new JProgressBar();///定义进度指示条
	JSlider sb=new JSlider(JSlider.HORIZONTAL,0,100,60);///定义滑杆
	public P()
	{
		setLayout(new GridLayout());
		add(pb);
		sb.setValue(0);///滑杆最开始的位置
		sb.setPaintTicks(true);
		sb.setMajorTickSpacing(20);
		sb.setMinorTickSpacing(5);
		sb.setBorder(new TitledBorder("移动滑竿"));
		pb.setModel(sb.getModel());
		pb.setStringPainted(true);
		add(sb);
	}
}
public class Test  
{
	public static void main(String[] args) 
	{
	    JFrame f=new JFrame("滑杆和进度指示条");
	    f.setSize(300,150);
	    f.add(new P());
	    f.show();
	    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
posted on 2017-05-15 21:09  渡……  阅读(497)  评论(0编辑  收藏  举报