java中有没有这样的控件,带两个箭头,点击向上箭头数字增加,点击向下的数字减小???
展开全部
这个叫微调控件,这里有一个例子。
/*
Java Swing, 2nd Edition
By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole
ISBN: 0-596-00408-7
Publisher: O'Reilly
*/
// SwingSpinnerTest.java
//A quick test of various spinners.
//
import java.awt.Container;
import java.awt.GridLayout;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerNumberModel;
public class SwingSpinnerTest extends JFrame {
public SwingSpinnerTest() {
super("JSpinner Test");
setSize(300, 180);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new GridLayout(0, 2));
c.add(new JLabel(" Basic Spinner"));
c.add(new JSpinner());
c.add(new JLabel(" Date Spinner"));
c.add(new JSpinner(new SpinnerDateModel()));
String weekdays[] = new String[] { "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday" };
c.add(new JLabel(" List Spinner"));
c.add(new JSpinner(new SpinnerListModel(weekdays)));
c.add(new JLabel(" Number Spinner"));
c.add(new JSpinner(new SpinnerNumberModel(0, 0, 100, 5)));
c.add(new JLabel(" Rollover List Spinner"));
c.add(new JSpinner(new RolloverSpinnerListModel(weekdays)));
setVisible(true);
}
public static void main(String args[]) {
new SwingSpinnerTest();
}
}
class RolloverSpinnerListModel extends SpinnerListModel {
public RolloverSpinnerListModel(Object[] items) {
super(items);
}
public RolloverSpinnerListModel(List items) {
super(items);
}
public Object getNextValue() {
Object nv = super.getNextValue();
if (nv != null) {
return nv;
}
return getList().get(0);
}
public Object getPreviousValue() {
Object pv = super.getPreviousValue();
if (pv != null) {
return pv;
}
List l = getList();
return l.get(l.size() - 1);
}
}
/*
Java Swing, 2nd Edition
By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole
ISBN: 0-596-00408-7
Publisher: O'Reilly
*/
// SwingSpinnerTest.java
//A quick test of various spinners.
//
import java.awt.Container;
import java.awt.GridLayout;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerNumberModel;
public class SwingSpinnerTest extends JFrame {
public SwingSpinnerTest() {
super("JSpinner Test");
setSize(300, 180);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new GridLayout(0, 2));
c.add(new JLabel(" Basic Spinner"));
c.add(new JSpinner());
c.add(new JLabel(" Date Spinner"));
c.add(new JSpinner(new SpinnerDateModel()));
String weekdays[] = new String[] { "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday" };
c.add(new JLabel(" List Spinner"));
c.add(new JSpinner(new SpinnerListModel(weekdays)));
c.add(new JLabel(" Number Spinner"));
c.add(new JSpinner(new SpinnerNumberModel(0, 0, 100, 5)));
c.add(new JLabel(" Rollover List Spinner"));
c.add(new JSpinner(new RolloverSpinnerListModel(weekdays)));
setVisible(true);
}
public static void main(String args[]) {
new SwingSpinnerTest();
}
}
class RolloverSpinnerListModel extends SpinnerListModel {
public RolloverSpinnerListModel(Object[] items) {
super(items);
}
public RolloverSpinnerListModel(List items) {
super(items);
}
public Object getNextValue() {
Object nv = super.getNextValue();
if (nv != null) {
return nv;
}
return getList().get(0);
}
public Object getPreviousValue() {
Object pv = super.getPreviousValue();
if (pv != null) {
return pv;
}
List l = getList();
return l.get(l.size() - 1);
}
}
追问
我的是jsp页面啊?有没有?
追答
jsp页面即需要用html实现这个功能,可以用图片+javascript。
展开全部
可以在程序里改啊,用最大值减去当前值。
9月
9月
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你要找的是swing里面的JSpinner组件吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有吧,没见过这样的
追问
真的没有吗??我也表达不清楚。我qq1052900950 请加我吧。或者你qq多少。我把图发给你,你看看。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询