I created a frame which have panel,splitpane and scrollpane. The splitpane have one scrollpane and panel. I have jtree structure of xml and i added it to the scrollpane of splitpane. The scrollbar is not visible, not able to see the nodes beyond the visibility os the scrollpane
Here is my code
Main app = new Main();
JFrame.setDefaultLookAndFeelDecorated(true);
app.f = new JFrame("NCX Generator");
app.pane1=new JPanel();
app.pane2=new JSplitPane();
app.right=new JPanel();
app.left=new JPanel();
app.Scrpane=new JScrollPane();
app.pane2.setRightComponent(app.right);
app.pane2.setLeftComponent(app.Scrpane);
app.pane3=new JScrollPane();
app.browse = new JButton("BROWSE");
app.save = new JButton("SAVE");
app.search = new JButton("SEARCH");
app.field = new JTextField("Enter Text ");
//app.pane2.setOneTouchExpandable(true);
app.pane2.setDividerLocation(700);
app.Scrpane.setLayout(null);
app.Scrpane.setBounds(10, 30, 700, 700);
app.Scrpane.setBackground(Color.white);
app.right.setLayout(null);
app.right.setBounds(700, 30, 700, 700);
app.right.setBackground(Color.white);
app.f.setLayout(new BorderLayout(100,100));
app.f.setBounds(0, 0, 1300, 720);
app.pane1.setLayout(new FlowLayout());
app.pane1.add(app.browse);
app.pane1.add(app.save);
app.pane1.add(app.search);
app.pane1.add(app.field);
app.f.add(app.pane1,BorderLayout.NORTH);
app.f.add(app.pane2,BorderLayout.CENTER);
app.f.add(app.pane3,BorderLayout.SOUTH);
app.browse.addActionListener(app);
app.save.addActionListener(app);
app.search.addActionListener(app);
app.f.setVisible(true);
}
private TreeSelectionListener createSelectionListener() {
return new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
String temp;
TreePath path = e.getPath();
int pathCount = path.getPathCount();
for (int i = 0; i < pathCount; i++) {
System.out.print(path.getPathComponent(i).toString());
if (i + 1 != pathCount) {
System.out.print("|");
}
if (i + 1 == pathCount) {
temp = path.getPathComponent(i).toString();
System.out.println("/n");
System.out.println(temp);
}
}
System.out.println("");
}
};
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == browse) {
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
filename = file.getPath();
System.out.println("You have selected: " + filename);
if (filename != "") {
InputStream in;
try {
in = new FileInputStream(new File(filename));
new XmlTree(filename, in);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
WindowUtilities.setNativeLookAndFeel();
JTree tree = new JTree();
tree=new XmlTree(filename);
tree.setEditable(true);
Scrpane.add(tree);
tree.addTreeSelectionListener(createSelectionListener());
tree.setBounds(10, 30, 700, 700);
//Scrpane.setPreferredSize(tree.getPreferredSize());
Scrpane.setVisible(true);
} catch (IOException ioe) {
System.out.println("Error creating tree: " + ioe);
}
}
}