日期:2014-05-20 浏览次数:20866 次
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTable;
public class SliperController {
JFrame mainWin = new JFrame("滑动条示范");
JPanel JP = new JPanel();
JTable table = new JTable(3, 3);
JSlider slider;
public void init() {
for (int i = 0; i < 9; i++) {
slider = new JSlider();
slider.setPaintTicks(true);
slider.setMajorTickSpacing(20);
slider.setMinorTickSpacing(5);
slider.setPaintLabels(true);
slider.addChangeListener(new MyChangeListener());
JP.add(slider);
}
JP.setLayout(new GridLayout(3, 3));
mainWin.add(new JScrollPane(table), BorderLayout.EAST);
mainWin.add(JP);
mainWin.pack();
mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWin.setVisible(true);
}
public static void main(String[] args) {
new SliperController().init();
}
}
package com.kiritor;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class SliperController implements ChangeListener {
@Override
public void stateChanged(ChangeEvent e) {
// TODO Auto-generated method stub
}
JFrame mainWin = new JFrame("滑动条示范");
JPanel JP = new JPanel();
JTable table = new JTable(3, 3);
JSlider slider;
public void init() {
for (int i = 0; i < 9; i++) {
slider = new JSlider();
slider.setPaintTicks(true);
slider.setMajorTickSpacing(20);
slider.setMinorTickSpacing(5);
slider.setPaintLabels(true);
slider.addChangeListener(this);
JP.add(slider);
}
JP.setLayout(new GridLayout(3, 3));
mainWin.add(new JScrollPane(table), BorderLayout.EAST);
mainWin.add(JP);
mainWin.pack();
mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWin.setVisible(true);
}
public static void main(String[] args) {
new SliperController().init();
}
}