List of usage examples for org.jdom2.contrib.output JTreeOutputter JTreeOutputter
public JTreeOutputter(boolean toBeCompatible)
From source file:JTreeOutputterDemo.java
License:Open Source License
public JTreeOutputterDemo() { frame = new JFrame(" JDOM Viewer 1.0"); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); openFile = new JMenuItem("Open XML File"); openFile.addActionListener(this); openURL = new JMenuItem("Open URL Stream"); openURL.addActionListener(this); openSQL = new JMenuItem("Query Database"); openSQL.addActionListener(this); exitMenu = new JMenuItem("Exit"); exitMenu.addActionListener(this); menu.add(openFile);/*from w ww. j a va 2 s . c o m*/ menu.add(openURL); menu.add(new JSeparator()); menu.add(openSQL); menu.add(new JSeparator()); menu.add(exitMenu); menuBar.add(menu); frame.setJMenuBar(menuBar); openButton = new JButton("Open"); openButton.addActionListener(this); reloadButton = new JButton("Reload"); reloadButton.addActionListener(this); exitButton = new JButton("Exit"); exitButton.addActionListener(this); aboutButton = new JButton("About"); aboutButton.addActionListener(this); JPanel buttonPanel = new JPanel(); buttonPanel.add(openButton); buttonPanel.add(reloadButton); buttonPanel.add(exitButton); buttonPanel.add(aboutButton); root = new DefaultMutableTreeNode("JDOM"); outputter = new JTreeOutputter(true); tree = new JTree(root); saxBuilder = new SAXBuilder(); scrollPane = new JScrollPane(); scrollPane.getViewport().add(tree); frame.setSize(400, 400); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add("Center", scrollPane); frame.getContentPane().add("South", buttonPanel); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { System.exit(0); } }); frame.setVisible(true); }