Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计 » Swing  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
话题被移动
该话题已被移动 - floater , 2004-10-18 11:14
如果您尚不清楚该话题被移动的原因,请参考论坛规则以及本版公告或者联系本版版主。
作者 Re:如何用JTable设置表头多行 [Re:kylin]
kylin





发贴: 61
积分: 0
于 2004-10-26 14:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好像是那么一回事,不过还不能满足我的需要,我在研究研究,如果有了新得会贴出来共享一下,呵呵


作者 Re:如何用JTable设置表头多行 [Re:kylin]
hujianso





发贴: 17
积分: 0
于 2004-10-28 11:08 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
to: kavinwang
你实在太强了!好佩服你啊!你给的那两段代码实在是"厉害",你都是怎么想到的啊,太强了!太强了!太强了!!



作者 Re:如何用JTable设置表头多行 [Re:kylin]
kavinwang

现实版流氓兔

版主


发贴: 529
积分: 38
于 2004-10-28 14:34 user profilesend a private message to usersend email to kavinwangsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
谢谢夸奖!
kylin:你的那个东西有搞定吗?



作者 Re:如何用JTable设置表头多行 [Re:kylin]
kylin





发贴: 61
积分: 0
于 2004-10-29 10:28 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
hujianso说得对,kavinwang的确是太强了,帮了我很大的忙,我都不知道该怎样感激他,如果有机会来南京,我可要好好请他一顿了,呵呵。

现在好像不需要搞那么复杂的表了,只需要表头可以对应多列的,不需要单元格可以对应多行的要求了,不过单元格之间要做处理,我不知道按tab健在表格健移动这个事件在哪里添加的,



作者 Re:如何用JTable设置表头多行 [Re:kylin]
javatool



发贴: 0
积分: 0
于 2004-11-02 10:30 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
可以联系MSN: javatoolsoft@hotmail.com


作者 Re:如何用JTable设置表头多行 [Re:kylin]
xiaoxiaoxia





发贴: 1
积分: 0
于 2004-12-15 09:20 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
看到这里有位高人,我很开心。我有一个棘手的问题请教一下:
我想使用JTable 实现这样一个功能,选中同行或者同列的几个单元格,可以把它们合并成一个单元格,图示如下:
-----------|-----------|----------|
-----------|-----------|----------|

变为
-----------|----------------------|
-----------|----------------------|

也就是说我想随意合并表格的单元格

能给我个解决思路嘛,谢谢! |



作者 Re:如何用JTable设置表头多行 [Re:kylin]
xcontinue





发贴: 6
积分: 0
于 2004-12-22 11:13 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
kylin大师,现在万分紧急,想讨教你的多行表头是怎么实现的?我也要做这样的效果,请帮忙,万分感谢!


作者 Re:如何用JTable设置表头多行 [Re:kylin]
kylin





发贴: 61
积分: 0
于 2004-12-22 11:40 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你先等等,我先整理一下,马上传上来


作者 Re:如何用JTable设置表头多行 [Re:kylin]
kylin





发贴: 61
积分: 0
于 2004-12-22 13:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
xcontinue:你看看t.java或TaxBudget.java的实现,你可以先运行看看效果,不过我可以先贴上t.java的运行的效果图



作者 Re:如何用JTable设置表头多行 [Re:kylin]
kylin





发贴: 61
积分: 0
于 2004-12-22 14:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
刚才发的怎么没把代码放上去

test.rar (16.62k)



作者 Re:如何用JTable设置表头多行 [Re:kylin]
xcontinue





发贴: 6
积分: 0
于 2004-12-25 19:06 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请问斑竹:如何给jtable 的cell着不同的颜色?


作者 Re:如何用JTable设置表头多行 [Re:kylin]
xcontinue





发贴: 6
积分: 0
于 2004-12-25 19:08 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请问:kylin怎么给jtable的cell着不同的颜色?jtable好像不能实现这个功能耶
万分着急!



作者 Re:如何用JTable设置表头多行 [Re:kylin]
xcontinue





发贴: 6
积分: 0
于 2004-12-25 19:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
像这样一幅图如何用jtable实现?表头多行我已实现,但其中有些格子的右边框为红色或者加粗,如何实现呢?万分紧急!



作者 Re:如何用JTable设置表头多行 [Re:kylin]
xcontinue





发贴: 6
积分: 0
于 2004-12-26 17:11 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我搞了如图所示的页面,为什么用了边框以后cell和header对不齐呢?(不用边框的时候我像kavinwang指教的那样改了是可以对得齐的)



作者 Re:如何用JTable设置表头多行 [Re:kylin]
xcontinue





发贴: 6
积分: 0
于 2004-12-28 10:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
怎么没人说话阿?救命啊


作者 Re:如何用JTable设置表头多行 [Re:kylin]
kavinwang

现实版流氓兔

版主


发贴: 529
积分: 38
于 2004-12-28 11:16 user profilesend a private message to usersend email to kavinwangsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我当时是进行硬性的改动,如果你提供边框的话,可能需要再做些改动,如果看到我之前提供的改动的代码,进行后续的改动应该不困难,你可自己试着进行改动!


作者 Re:如何用JTable设置表头多行 [Re:kylin]
ccvcd





发贴: 1
积分: 0
于 2005-01-12 17:39 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
to:xcontinue
能把你的实现源码发给我一份吗,我现在正需要这个呢,谢谢了。
我的邮箱:ccvcd@sohu.com



作者 Re:如何用JTable设置表头多行 [Re:kylin]
javatool



发贴: 0
积分: 0
于 2005-01-31 13:50 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
可以试试JavaCellReport http://www.javatoolsoft.com


作者 借宝地提问tame.exmple.AnimatedIconHeaderExample [Re:kylin]
windcao





发贴: 6
积分: 0
于 2005-02-24 15:23 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
to:kavinwang 佩服佩服佩服佩服佩服佩服佩服佩服佩服佩服佩服佩服
我在调tame的第一个例子AnimatedIconHeaderExample似乎里面并没有用到
tame 的东西。这里面的table getHeaderRenderer() 取出的header是空的。是不是由于jdk升级引起的还没有调查不知道你是否关注过这个例子。共同探讨一下



作者 欢迎大家参与tame的重新整理工作,积极讨论 [Re:kylin]
windcao





发贴: 6
积分: 0
于 2005-02-24 15:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://www.cjsdn.net/post/view?bid=46&id=135778&sty=1#135778


作者 Re:如何用JTable设置表头多行 [Re:kylin]
ShiZhen





发贴: 2
积分: 0
于 2005-02-28 19:34 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
斑竹及各位大虾,在下有理了。
看了这里的文章觉得非常好,尤其是关于表头的设定,收益匪浅。
我现在做JTable的东东,遇到了一个问题哪位能给指点一下?
先谢谢了。
我的table中有一列只能录入数字,当焦点离开该列的某个Cell是我先判断录入的值是不是数字,若不是程序打出错误框,关闭错误框后我想让焦点回到刚才编辑过的Cell,现在我不知道该如何能让焦点回到table中某个指定的Cell。请帮帮忙!



作者 Re:如何用JTable设置表头多行 [Re:kylin]
kavinwang

现实版流氓兔

版主


发贴: 529
积分: 38
于 2005-03-01 08:44 user profilesend a private message to usersend email to kavinwangsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
取出刚才输入的cell的位置,再调用相应的方法进行设置


作者 Re:如何用JTable设置表头多行 [Re:kylin]
杰克逊





发贴: 4
积分: 0
于 2005-03-02 11:46 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
以身相许吧,呵呵……
有row的randerer自然也有column的randerer,以前每一行的行头有一个rowNo道理是一样的



Just Do It !!!
作者 Re:如何用JTable设置表头多行 [Re:kylin]
zhansy





发贴: 9
积分: 0
于 2005-03-18 22:40 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我发现个问题,好像你们写的程序在jdk1。5里面运行时,表头只能显示最下面的一列,这个是什么原因呢???


作者 Re:如何用JTable设置表头多行 [Re:kylin]
seeler





发贴: 10
积分: 0
于 2005-03-30 08:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
厉害,学到东西了


作者 Re:如何用JTable设置表头多行 [Re:xcontinue]
billyzorro





发贴: 2
积分: 0
于 2005-03-30 09:17 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
代码下载是损坏的,能重发吗? test.rar


作者 Re:如何用JTable设置表头多行 [Re:kylin]
ljy789654





发贴: 2
积分: 0
于 2005-05-10 15:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我对JAVA的认识不过有一定了解。
想请你帮忙做个小游戏。怎么样?



作者 Re:如何用JTable设置表头多行 [Re:kylin]
mylzw





发贴: 1
积分: 0
于 2005-05-14 19:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我也发现JDK1.5只显示一行表头,不知道是什么原因啊。
望高手赐教!



作者 Re:如何用JTable设置表头多行 [Re:kylin]
leigh





发贴: 2
积分: 0
于 2005-06-08 15:33 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
问题应该是出在 AttributiveCellTableModel 的 setDataVector() 方法中调用了 setColumnIdentifiers(), 而 1.5 的 setColumnIdentifiers() 方法中又调用了 setDataVector(),导致堆栈溢出了。


作者 Re:如何用JTable设置表头多行 [Re:kylin]
hyhoo7





发贴: 3
积分: 0
于 2005-06-16 09:43 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在jdk15中运行需要修改代码,修改如下:

/* (swing1.1beta3) */
package tame.examples;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.*;

import javax.swing.*;
import javax.swing.table.*;

import tame.table.ColumnGroup;
import tame.table.GroupableTableHeader;
import tame.table.GroupableTableHeaderUI;

/**
<pre>
* |-----------------------------------------------------|
* | | Name | Language |
* | |-----------------|--------------------------|
* | SNo. | | | | Others |
* | | 1 | 2 | Native |-----------------|
* | | | | | 2 | 3 |
* |-----------------------------------------------------|
* | | | | | | |
</pre>
@author Nobuo Tamemasa
@version 1.0 11/09/98
*/
public class GroupableHeaderExample extends JFrame {

GroupableHeaderExample() {
super( "Groupable Header Example" );

DefaultTableModel dm = new DefaultTableModel();
dm.setDataVector(new Object[][]{
{"119","foo","bar","ja","ko","zh"},
{"911","bar","foo","en","fr","pt"}},
new Object[]{"SNo.","1","2","Native","2","3"});

JTable table = new JTable( dm ) {
protected JTableHeader createDefaultTableHeader() {
return new GroupableTableHeader(columnModel);
}
};
TableColumnModel cm = table.getColumnModel(); //得到列模型,可以取出表头
ColumnGroup g_name = new ColumnGroup("Name");
g_name.add(cm.getColumn(1));
g_name.add(cm.getColumn(2));
ColumnGroup g_lang = new ColumnGroup("Language");
g_lang.add(cm.getColumn(3));
ColumnGroup g_other = new ColumnGroup("Others");
g_other.add(cm.getColumn(4));
g_other.add(cm.getColumn(5));
g_lang.add(g_other);
GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
header.addColumnGroup(g_name);
header.addColumnGroup(g_lang);

TableCellRenderer renderer = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
JTableHeader header = table.getTableHeader();
if (header != null) {
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
}
setHorizontalAlignment(JLabel.CENTER);
setText((value == null) ? "" : value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return this;
}
};

TableColumnModel model = table.getColumnModel();
for (int i=0;i<model.getColumnCount();i++) {
model.getColumn(i).setHeaderRenderer(renderer);
}
table.getTableHeader().setUI(new GroupableTableHeaderUI());
JScrollPane scroll = new JScrollPane( table );
getContentPane().add( scroll );
setSize( 400, 120 );
}

public static void main(String[] args) {
GroupableHeaderExample frame = new GroupableHeaderExample();
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
}
});
frame.setVisible(true);
}

}


kavinwang edited on 2005-06-16 11:30

go to first page go to previous page  1   2   3  go to next page go to last page

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923