JBuilder2006下如何实现自动添加jtable的各行各列的表格和jtree的各个节点呀。我用JBuilder2006在UI界面上放了一个JTREE,想请教一下各位高手如何才能不输入代码而直接靠修改jtree的某个属性或拖拽或右键添加其节点及相关事件(如弹出右键菜单或双击鼠标显示对话框的事件)呀?jtable也是类似的问题。哪位高人能帮我解决一下呀?谢谢了!
解决方案 »
- 哪位好心人士帮我看看啊,做不出来,要吐血了!!
- 请大家帮帮忙,看看这个程序的允许结果为什么是这个?想了好久都不清楚
- 请教一个问题!请高手相助!!
- 怎样在.setText()或println()中输出回车呀?哪位大哥讲一下
- 求助?如何在父窗体中显示子窗体??
- 在Linux Vi编辑器能不能引用AWT包,做一个图形界面,我试了很久好像不可以.请大家帮帮忙.
- 请问两个个简单问题!希望这里德高望重的大虾帮个忙!
- 软件工程师和程序员是一会事吗?
- 关于io的小问题,请指点
- 有没有方法在 非solaris 的 unix下,比如说 sco unix 下面,使用 j2se 的方法!
- 数据库查询问题
- 如何解决数据表中一对多的父子关系??
...
table.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
if (e.isMetaDown())
{
Point p = e.getPoint();
getContextMenu().show(table, p.x, p.y);
}
}
}); public JPopupMenu getContextMenu()
{
JPopupMenu pop = new JPopupMenu();
Action add = new TbAction("增加");
Action del = new TbAction("删除");
if (add != null)
{
pop.add(add);
}
if (del != null)
{
pop.add(del);
}
return pop.getComponentCount() > 0 ? pop : null;
} public class TbAction extends AbstractAction
{
JTable table;
public TbAction(String name,JTable table)
{
super(name);
this.table = table;
} public void actionPerformed(java.awt.event.ActionEvent e)
{
if (getValue(Action.NAME).equals("增加"))
{
( (DefaultTableModel) table.getModel()).insertRow(table.getSelectedRow(), new Vector());
}
else if (getValue(Action.NAME).equals("删除")&&table.getSelectedRow()!=-1)
{
( (DefaultTableModel) table.getModel()).removeRow(table.getSelectedRow());
}
}
}
是不能利用JBUILDER2006添加树节点的