Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating an Outlook style user interface in Java?
    text
    copied!<p>I'm looking to create an Outlook style UI in a Java desktop app, with a list of contexts or nodes in a lefthand pane, and the selected context in a pane on the right. How do I go about this? </p> <p>I'm looking for a bit more detail than 'use a JFrame'. A tutorial or walk through would be good, or some skeleton code, or a framework/library that provides this kind of thing out of the box. </p> <p>Thanks.</p> <p><strong>Edit</strong></p> <p>My (edited) code so far:</p> <p><strong>UIPanel</strong></p> <pre><code>public class UIPanel extends javax.swing.JPanel { private final JSplitPane splitPane; public UIPanel() { super(new BorderLayout()); initComponents(); JPanel contextPnl = new ContextPanel(); JPanel treePnl = new NodePanel(contextPnl); this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(treePnl), new JScrollPane(contextPnl)); add(splitPane, BorderLayout.CENTER); //not sure I need these? splitPane.setVisible(true); treePnl.setVisible(true); contextPnl.setVisible(true); } </code></pre> <p><strong>NodePanel</strong></p> <pre><code>public class NodePanel extends javax.swing.JPanel { JPanel _contextPanel; public NodePanel(JPanel contextPanel) { initComponents(); _contextPanel = contextPanel; initialise(); } private void initialise(){ nodeTree.addTreeSelectionListener(getTreeListener()); } private TreeSelectionListener getTreeListener(){ return new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodeTree.getLastSelectedPathComponent(); // if nothing is selected if (node == null) return; // get selected node Object nodeInfo = node.getUserObject(); CardLayout layout = (CardLayout) _contextPanel.getLayout(); //layout.show(_contextPanel, "test"); //show context for selected node } }; } </code></pre> <p><strong>ContextPanel</strong></p> <pre><code>public class ContextPanel extends javax.swing.JPanel { JPanel _cards; final static String CONTEXT1 = "Context 1"; final static String CONTEXT2 = "Context 2"; JPanel _context1; JPanel _context2; public ContextPanel() { initComponents(); intialiseContexts(); } public void updateContext(String contextName){ //TODO } private void intialiseContexts(){ _context1 = new NodeContext(); _context2 = new NodeContext(); _cards = new JPanel(new CardLayout()); _cards.add(_context1, CONTEXT1); _cards.add(_context2, CONTEXT2); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload