SWING日历面版控件(WINDOWS标准样式),可嵌入各种面版中,跟据大小自动调节 刚做好一个SWING的日历控件,与大家分享一下。以后还会增强日历功能。JDK1.4以上版本,都可用我已经将代码公布到了chinaitlab上了.代码在http://bbs.chinaitlab.com/frame.php?frameon=yes&referer=http%3A//bbs.chinaitlab.com/thread-282485-1-1.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道怎么发效果图,大家就自己运行下看吧.有什么好的见意,可以给我留言.当前是做的一个WINDOWS样式,最标准日历而做的控件没有其它功能在上面以后有空可能在上面加上其它附加功能.如记事,支持选择不同着色标注你要的特定日期,等等 看过了,不错,有个小问题帮你改掉了应该是 months[i] 不是months private void setNorthPanel() { JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); comboBoxMonth = new JComboBox(); for (int i = 0; i < months.length; i++) { comboBoxMonth.addItem(months[i]); } comboBoxMonth.setSelectedIndex(-1); panel.add(comboBoxMonth); RolloverSpinnerListModel numberModel = new RolloverSpinnerListModel( 1980, 1980, 2099, 1); spinnerYear = new JSpinner(numberModel); JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor( spinnerYear, "####"); spinnerYear.setEditor(numberEditor); panel.add(spinnerYear); this.add(panel, BorderLayout.NORTH); } 呵呵...谢谢...应该是 months[i] 本地代码同你改的一样,开始也已经测试是对的...可能粘贴代码的时候出了问题.谢谢指出..我这就去修改下 刚刚从新试了下.还是有问题.注意了下原因months[i] 在chinaitlab里面[i]是特转义字符.它认为是斜体把后面的一个)改变了 发现JDK中的WINDOW窗体处理比较特别,原有的代码日历面版直接放在WINDOW上,会出现TABLE的高度分配不正确,现修改了一下其中的TABLE类代码如下class JTable2 extends JTable { /** * */ private static final long serialVersionUID = 2092799354481792367L; public JTable2() { this.getTableHeader().setReorderingAllowed(false); this.getTableHeader().setResizingAllowed(false); this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.setCellSelectionEnabled(true); this.setGridColor(Color.white); } public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { if (this.getValueAt(rowIndex, columnIndex) == null) { return; } if (rowIndex == 0) { return; } super.changeSelection(rowIndex, columnIndex, toggle, extend); } public void repaint(int x, int y, int width, int height) { super.repaint(x, y, width, height); if (height > 0) { makeTableRowHeight(); } } protected void validateTree() { super.validateTree(); makeTableRowHeight(); } private void makeTableRowHeight() { int rowHeight = (int) ((this.getHeight() / 7) * 0.6); if (rowHeight > 0) { this.setRowHeight(0, rowHeight); } rowHeight = (int) ((this.getHeight() - rowHeight) / 6); if (rowHeight > 0) { for (int i = 1; i < 8; i++) { this.setRowHeight(i, rowHeight); } } }} java.lang.NullPointerException 一个关于工厂的问题 swing中的JTabbedPane标签 请问jawin 调用问题 java一道面试问题,在线等 急 webwork可以直接得到一个对象吗 xml解析除问题啦!! 关于IBM Websphere Studio Application Developer 5.0 如何将内部的eclipse更新成2.1版本 JAVA 找学习伙伴 我才学到oop呢 请问现在企业一般性用什么java编译器???? 这个JOptionPane怎么不用实例化就可以使用他的构造方法? 求教
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
comboBoxMonth = new JComboBox();
for (int i = 0; i < months.length; i++) {
comboBoxMonth.addItem(months[i]);
}
comboBoxMonth.setSelectedIndex(-1);
panel.add(comboBoxMonth);
RolloverSpinnerListModel numberModel = new RolloverSpinnerListModel(
1980, 1980, 2099, 1);
spinnerYear = new JSpinner(numberModel);
JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(
spinnerYear, "####");
spinnerYear.setEditor(numberEditor);
panel.add(spinnerYear); this.add(panel, BorderLayout.NORTH);
}
months[i]
在chinaitlab里面[i]是特转义字符.它认为是斜体把后面的一个)改变了
class JTable2 extends JTable { /**
*
*/
private static final long serialVersionUID = 2092799354481792367L; public JTable2() {
this.getTableHeader().setReorderingAllowed(false);
this.getTableHeader().setResizingAllowed(false);
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.setCellSelectionEnabled(true);
this.setGridColor(Color.white);
} public void changeSelection(int rowIndex, int columnIndex, boolean toggle,
boolean extend) {
if (this.getValueAt(rowIndex, columnIndex) == null) {
return;
} if (rowIndex == 0) {
return;
} super.changeSelection(rowIndex, columnIndex, toggle, extend);
} public void repaint(int x, int y, int width, int height) {
super.repaint(x, y, width, height); if (height > 0) {
makeTableRowHeight();
}
} protected void validateTree() {
super.validateTree(); makeTableRowHeight();
} private void makeTableRowHeight() {
int rowHeight = (int) ((this.getHeight() / 7) * 0.6); if (rowHeight > 0) {
this.setRowHeight(0, rowHeight);
} rowHeight = (int) ((this.getHeight() - rowHeight) / 6); if (rowHeight > 0) {
for (int i = 1; i < 8; i++) {
this.setRowHeight(i, rowHeight);
}
}
}}