- JScrollPane added

- expand tree 

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@221 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-11-29 11:44:49 +00:00
parent af40b52734
commit 4a284332a6

View File

@@ -7,6 +7,7 @@
package ch.ntb.usb.usbView; package ch.ntb.usb.usbView;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@@ -16,6 +17,7 @@ import javax.swing.JMenu;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane; import javax.swing.JSplitPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JTree; import javax.swing.JTree;
@@ -35,7 +37,7 @@ public class UsbView extends JFrame {
private JMenu commandsMenu = null; private JMenu commandsMenu = null;
private JMenuItem exitMenuItem = null; private JMenuItem exitMenuItem = null;
private JMenuItem updateMenuItem = null; private JMenuItem updateMenuItem = null;
private JTree usbTree = null; JTree usbTree = null;
private JSplitPane jSplitPane = null; private JSplitPane jSplitPane = null;
private JTextArea jPropertiesArea = null; private JTextArea jPropertiesArea = null;
@@ -151,6 +153,7 @@ public class UsbView extends JFrame {
Usb_Bus bus = LibusbJava.usb_get_busses(); Usb_Bus bus = LibusbJava.usb_get_busses();
if (bus != null) { if (bus != null) {
treeModel.fireTreeStructureChanged(bus); treeModel.fireTreeStructureChanged(bus);
expandAll(usbTree);
} }
} }
}); });
@@ -174,6 +177,7 @@ public class UsbView extends JFrame {
treeModel = new UsbTreeModel(bus, jPropertiesArea); treeModel = new UsbTreeModel(bus, jPropertiesArea);
usbTree = new JTree(treeModel); usbTree = new JTree(treeModel);
expandAll(usbTree);
usbTree.addTreeSelectionListener(treeModel); usbTree.addTreeSelectionListener(treeModel);
} }
return usbTree; return usbTree;
@@ -190,8 +194,9 @@ public class UsbView extends JFrame {
jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane.setContinuousLayout(true); jSplitPane.setContinuousLayout(true);
jSplitPane.setDividerLocation(APP_HIGHT / 2); jSplitPane.setDividerLocation(APP_HIGHT / 2);
jSplitPane.setBottomComponent(getJPropertiesArea()); jSplitPane
jSplitPane.setTopComponent(getUsbTree()); .setBottomComponent(createScrollPane(getJPropertiesArea()));
jSplitPane.setTopComponent(createScrollPane(getUsbTree()));
} }
return jSplitPane; return jSplitPane;
} }
@@ -208,6 +213,11 @@ public class UsbView extends JFrame {
return jPropertiesArea; return jPropertiesArea;
} }
private JScrollPane createScrollPane(Component view) {
JScrollPane scrollPane = new JScrollPane(view);
return scrollPane;
}
/** /**
* Launches this application * Launches this application
*/ */
@@ -216,4 +226,11 @@ public class UsbView extends JFrame {
application.setVisible(true); application.setVisible(true);
} }
void expandAll(JTree tree) {
int row = 0;
while (row < tree.getRowCount()) {
tree.expandRow(row);
row++;
}
}
} }