M
Mirela
Hi!!
I have a problem concerning the display of the Horizontal ScrollBar on
a Jtable. It may seem silly, but there is no way I can get it visible
and active.
So, I have a frame, that contains a tree on the left and a table on
the right. The constructor of my class is posted at the end of the
message.
What exactly is it that I do wrong???? The scollbar is "visible", but
inactive. And the columns of the table can not be scrolled.
The thing is the Vertical scroll bar has always been displayed without
doing anythig. Just using the default constructor ( JScollPane
(myJTable) ); But never the Horizontal one..
WHY!!!
Here is the code where the table is defined, as well as its scollpane,
the frame, the tree, etc ..
Thanks for ANY ides on the subject!!
Mirela
.... imports ...
public class emjrcf extends JFrame implements dm.include.Rcf,
dm.include.ii, TableModelListener {
private static JTree tree;
private DefaultTreeModel treeModel;
private String lineStyle = "Angled";
private static JSplitPane splitPane = null;
private static JTable myJTable;
private static JScrollPane myTableJScrollPane = null;
private JScrollPane myTreeScrollPane = null;
private PopupMenu myPopupMenu = null;
private Ma ma = null;
private Tsl tsl = null;
private static DefaultMutableTreeNode top = null;
private DefaultMutableTreeNode selectedNode = new
DefaultMutableTreeNode ();
.. other declarations ...
public emjrcf(String title, String server ) {
super("emjrcf " + title);
// create an arg to set the name of the root node through an ArgInfo
object
DriArg topArg = new DriArg();
try {
topArg.set(rcfResNameId, rcfResNameType, server);
} catch (iiException e) {
System.out.println("Exception is : " + e.getMessage());
}
/* for the construction of the tree */
Ptable formatTable = getTreeFormat();
ArgInfo ai = new ArgInfo(topArg) ;
ai.paramTable = formatTable ;
top = new DefaultMutableTreeNode(ai);
top.setUserObject(ai);
createNodes(top, formatTable);
//Create a tree that allows one selection at a time.
treeModel = new DefaultTreeModel(top);
tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// Listen for the right click to show popup
myPopupMenu = new PopupMenu(this);
myPopupMenu.createPopupMenuRoot();
MouseListener popupListener = myPopupMenu.popupListener;
//Listen for when the selection changes.
tree.addTreeSelectionListener(new Tsl(tree, this));
tree.addMouseListener(new Ma(tree, this));
tree.addMouseListener(popupListener);
//Create the scroll pane and add the tree to it.
myTreeScrollPane = new JScrollPane(tree);
tableModel = new TableModel("Root View ");
tableModel.addTableModelListener(this);
tableModel.hookTree = this;
/* _____________________________________
here is the creation of the table
___________________________________*/
myJTable = new JTable(tableModel);
myJTable.setPreferredScrollableViewportSize( new Dimension(100,
50));
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
myTableJScrollPane = new JScrollPane(myJTable, v, h);
//Add the scroll panes to a split pane.
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(myTreeScrollPane);
splitPane.setRightComponent(myTableJScrollPane);
Dimension minimumSize = new Dimension(100, 50);
myTableJScrollPane.setMinimumSize(minimumSize);
myTreeScrollPane.setMinimumSize(minimumSize);
splitPane.setDividerLocation(200);
splitPane.setPreferredSize(new Dimension(500, 300));
createMenu();
//Add the split pane to this frame.
getContentPane().add(splitPane, BorderLayout.CENTER);
setRootView();
}
I have a problem concerning the display of the Horizontal ScrollBar on
a Jtable. It may seem silly, but there is no way I can get it visible
and active.
So, I have a frame, that contains a tree on the left and a table on
the right. The constructor of my class is posted at the end of the
message.
What exactly is it that I do wrong???? The scollbar is "visible", but
inactive. And the columns of the table can not be scrolled.
The thing is the Vertical scroll bar has always been displayed without
doing anythig. Just using the default constructor ( JScollPane
(myJTable) ); But never the Horizontal one..
WHY!!!
Here is the code where the table is defined, as well as its scollpane,
the frame, the tree, etc ..
Thanks for ANY ides on the subject!!
Mirela
.... imports ...
public class emjrcf extends JFrame implements dm.include.Rcf,
dm.include.ii, TableModelListener {
private static JTree tree;
private DefaultTreeModel treeModel;
private String lineStyle = "Angled";
private static JSplitPane splitPane = null;
private static JTable myJTable;
private static JScrollPane myTableJScrollPane = null;
private JScrollPane myTreeScrollPane = null;
private PopupMenu myPopupMenu = null;
private Ma ma = null;
private Tsl tsl = null;
private static DefaultMutableTreeNode top = null;
private DefaultMutableTreeNode selectedNode = new
DefaultMutableTreeNode ();
.. other declarations ...
public emjrcf(String title, String server ) {
super("emjrcf " + title);
// create an arg to set the name of the root node through an ArgInfo
object
DriArg topArg = new DriArg();
try {
topArg.set(rcfResNameId, rcfResNameType, server);
} catch (iiException e) {
System.out.println("Exception is : " + e.getMessage());
}
/* for the construction of the tree */
Ptable formatTable = getTreeFormat();
ArgInfo ai = new ArgInfo(topArg) ;
ai.paramTable = formatTable ;
top = new DefaultMutableTreeNode(ai);
top.setUserObject(ai);
createNodes(top, formatTable);
//Create a tree that allows one selection at a time.
treeModel = new DefaultTreeModel(top);
tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// Listen for the right click to show popup
myPopupMenu = new PopupMenu(this);
myPopupMenu.createPopupMenuRoot();
MouseListener popupListener = myPopupMenu.popupListener;
//Listen for when the selection changes.
tree.addTreeSelectionListener(new Tsl(tree, this));
tree.addMouseListener(new Ma(tree, this));
tree.addMouseListener(popupListener);
//Create the scroll pane and add the tree to it.
myTreeScrollPane = new JScrollPane(tree);
tableModel = new TableModel("Root View ");
tableModel.addTableModelListener(this);
tableModel.hookTree = this;
/* _____________________________________
here is the creation of the table
___________________________________*/
myJTable = new JTable(tableModel);
myJTable.setPreferredScrollableViewportSize( new Dimension(100,
50));
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
myTableJScrollPane = new JScrollPane(myJTable, v, h);
//Add the scroll panes to a split pane.
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(myTreeScrollPane);
splitPane.setRightComponent(myTableJScrollPane);
Dimension minimumSize = new Dimension(100, 50);
myTableJScrollPane.setMinimumSize(minimumSize);
myTreeScrollPane.setMinimumSize(minimumSize);
splitPane.setDividerLocation(200);
splitPane.setPreferredSize(new Dimension(500, 300));
createMenu();
//Add the split pane to this frame.
getContentPane().add(splitPane, BorderLayout.CENTER);
setRootView();
}