本文整理汇总了Java中javax.swing.JTree.addTreeExpansionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.addTreeExpansionListener方法的具体用法?Java JTree.addTreeExpansionListener怎么用?Java JTree.addTreeExpansionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.addTreeExpansionListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeActual
import javax.swing.JTree; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super TreeExpansionEvent> observer) {
JTree w = widget;
TreeExpansionEventConsumer aec = new TreeExpansionEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addTreeExpansionListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}
示例2: PackageBrowser
import javax.swing.JTree; //导入方法依赖的package包/类
public PackageBrowser(JFrame frame, String title, boolean modal) {
super(MainFrame.mainFrame,title, modal);
addWindowListener(WindowDisposer.getDisposer());
addKeyListener(WindowDisposer.getDisposer());
ActionEventHandler actionEventH = new ActionEventHandler();
LibComboActionEvnetHandler libComboHandler = new LibComboActionEvnetHandler();
PackageListSelectionEventHandler packageListSelectionEventH = new PackageListSelectionEventHandler();
ClassListSelectionEventHandler classListSelectionEventH = new ClassListSelectionEventHandler();
TreeExpansionEventHandler treeExpansionEventH = new TreeExpansionEventHandler();
tabbedPane = new JTabbedPane();
//List view tab
libListRenderer = new LibComboCellRenderer();
packageListRenderer = new PackageListCellRenderer();
classListRenderer = new ClassListCellRenderer();
libraryCombo = new JComboBox();
libraryCombo.setRenderer(libListRenderer);
libraryCombo.addActionListener(libComboHandler);
packageList = new JList();
packageList.setCellRenderer(packageListRenderer);
packageList.addListSelectionListener(packageListSelectionEventH);
classList = new JList();
classList.setCellRenderer(classListRenderer);
classList.addListSelectionListener(classListSelectionEventH);
listViewTab = new ListViewPanel(libraryCombo, packageList, classList);
tabbedPane.addTab("ListView", listViewTab);
tabbedPane.setTabPlacement(SwingConstants.TOP);
tabbedPane.setSelectedIndex(0);
tree = new JTree();
tree.putClientProperty("JTree.lineStyle", "Angled");
tree.addTreeExpansionListener(treeExpansionEventH);
treeRenderer = new PackageBrowserTreeCellRenderer();
tree.setCellRenderer(treeRenderer);
//Tree view tab
treeViewTab = new TreeViewPanel(tree);
treeViewTab.setPackageBrowser(this);
tabbedPane.addTab("TreeView", treeViewTab);
//buttons panel
selectBtn = new JButton("Select");
selectBtn.setActionCommand("Select");
selectBtn.addActionListener(actionEventH);
selectBtn.setEnabled(true);
cancelBtn = new JButton("Close");
cancelBtn.setActionCommand("Close");
cancelBtn.addActionListener(actionEventH);
btnP = new JPanel();
FlowLayout btnL = new FlowLayout();
btnP.setLayout(btnL);
btnP.add(selectBtn);
btnP.add(cancelBtn);
setFirstData();
getContentPane().add(tabbedPane, BorderLayout.CENTER);
getContentPane().add(btnP, BorderLayout.SOUTH);
getContentPane().add(new JPanel(),BorderLayout.WEST);
getContentPane().add(new JPanel(),BorderLayout.EAST);
setSize(250,480);
setLocation(150, 150);
this.setResizable(false);
}