Example usage for javax.swing JSplitPane HORIZONTAL_SPLIT

List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT

Introduction

In this page you can find the example usage for javax.swing JSplitPane HORIZONTAL_SPLIT.

Prototype

int HORIZONTAL_SPLIT

To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.

Click Source Link

Document

Horizontal split indicates the Components are split along the x axis.

Usage

From source file:BasicDnD.java

public BasicDnD() {
    super(new BorderLayout());
    JPanel leftPanel = createVerticalBoxPanel();
    JPanel rightPanel = createVerticalBoxPanel();

    // Create a table model.
    DefaultTableModel tm = new DefaultTableModel();
    tm.addColumn("Column 0");
    tm.addColumn("Column 1");
    tm.addColumn("Column 2");
    tm.addColumn("Column 3");
    tm.addRow(new String[] { "Table 00", "Table 01", "Table 02", "Table 03" });
    tm.addRow(new String[] { "Table 10", "Table 11", "Table 12", "Table 13" });
    tm.addRow(new String[] { "Table 20", "Table 21", "Table 22", "Table 23" });
    tm.addRow(new String[] { "Table 30", "Table 31", "Table 32", "Table 33" });

    // LEFT COLUMN
    // Use the table model to create a table.
    table = new JTable(tm);
    leftPanel.add(createPanelForComponent(table, "JTable"));

    // Create a color chooser.
    colorChooser = new JColorChooser();
    leftPanel.add(createPanelForComponent(colorChooser, "JColorChooser"));

    // RIGHT COLUMN
    // Create a textfield.
    textField = new JTextField(30);
    textField.setText("Favorite foods:\nPizza, Moussaka, Pot roast");
    rightPanel.add(createPanelForComponent(textField, "JTextField"));

    // Create a scrolled text area.
    textArea = new JTextArea(5, 30);
    textArea.setText("Favorite shows:\nBuffy, Alias, Angel");
    JScrollPane scrollPane = new JScrollPane(textArea);
    rightPanel.add(createPanelForComponent(scrollPane, "JTextArea"));

    // Create a list model and a list.
    DefaultListModel listModel = new DefaultListModel();
    listModel.addElement("Martha Washington");
    listModel.addElement("Abigail Adams");
    listModel.addElement("Martha Randolph");
    listModel.addElement("Dolley Madison");
    listModel.addElement("Elizabeth Monroe");
    listModel.addElement("Louisa Adams");
    listModel.addElement("Emily Donelson");
    list = new JList(listModel);
    list.setVisibleRowCount(-1);//from w  ww  . java 2 s  .c o m
    list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    list.setTransferHandler(new TransferHandler() {

        public boolean canImport(TransferHandler.TransferSupport info) {
            // we only import Strings
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                return false;
            }

            JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
            if (dl.getIndex() == -1) {
                return false;
            }
            return true;
        }

        public boolean importData(TransferHandler.TransferSupport info) {
            if (!info.isDrop()) {
                return false;
            }

            // Check for String flavor
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                displayDropLocation("List doesn't accept a drop of this type.");
                return false;
            }

            JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
            DefaultListModel listModel = (DefaultListModel) list.getModel();
            int index = dl.getIndex();
            boolean insert = dl.isInsert();
            // Get the current string under the drop.
            String value = (String) listModel.getElementAt(index);

            // Get the string that is being dropped.
            Transferable t = info.getTransferable();
            String data;
            try {
                data = (String) t.getTransferData(DataFlavor.stringFlavor);
            } catch (Exception e) {
                return false;
            }

            // Display a dialog with the drop information.
            String dropValue = "\"" + data + "\" dropped ";
            if (dl.isInsert()) {
                if (dl.getIndex() == 0) {
                    displayDropLocation(dropValue + "at beginning of list");
                } else if (dl.getIndex() >= list.getModel().getSize()) {
                    displayDropLocation(dropValue + "at end of list");
                } else {
                    String value1 = (String) list.getModel().getElementAt(dl.getIndex() - 1);
                    String value2 = (String) list.getModel().getElementAt(dl.getIndex());
                    displayDropLocation(dropValue + "between \"" + value1 + "\" and \"" + value2 + "\"");
                }
            } else {
                displayDropLocation(dropValue + "on top of " + "\"" + value + "\"");
            }

            /**
             * This is commented out for the basicdemo.html tutorial page. * If you
             * add this code snippet back and delete the * "return false;" line, the
             * list will accept drops * of type string. // Perform the actual
             * import. if (insert) { listModel.add(index, data); } else {
             * listModel.set(index, data); } return true;
             */
            return false;
        }

        public int getSourceActions(JComponent c) {
            return COPY;
        }

        protected Transferable createTransferable(JComponent c) {
            JList list = (JList) c;
            Object[] values = list.getSelectedValues();

            StringBuffer buff = new StringBuffer();

            for (int i = 0; i < values.length; i++) {
                Object val = values[i];
                buff.append(val == null ? "" : val.toString());
                if (i != values.length - 1) {
                    buff.append("\n");
                }
            }
            return new StringSelection(buff.toString());
        }
    });
    list.setDropMode(DropMode.ON_OR_INSERT);

    JScrollPane listView = new JScrollPane(list);
    listView.setPreferredSize(new Dimension(300, 100));
    rightPanel.add(createPanelForComponent(listView, "JList"));

    // Create a tree.
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Mia Familia");
    DefaultMutableTreeNode sharon = new DefaultMutableTreeNode("Sharon");
    rootNode.add(sharon);
    DefaultMutableTreeNode maya = new DefaultMutableTreeNode("Maya");
    sharon.add(maya);
    DefaultMutableTreeNode anya = new DefaultMutableTreeNode("Anya");
    sharon.add(anya);
    sharon.add(new DefaultMutableTreeNode("Bongo"));
    maya.add(new DefaultMutableTreeNode("Muffin"));
    anya.add(new DefaultMutableTreeNode("Winky"));
    DefaultTreeModel model = new DefaultTreeModel(rootNode);
    tree = new JTree(model);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setPreferredSize(new Dimension(300, 100));
    rightPanel.add(createPanelForComponent(treeView, "JTree"));

    // Create the toggle button.
    toggleDnD = new JCheckBox("Turn on Drag and Drop");
    toggleDnD.setActionCommand("toggleDnD");
    toggleDnD.addActionListener(this);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
    splitPane.setOneTouchExpandable(true);

    add(splitPane, BorderLayout.CENTER);
    add(toggleDnD, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
}

From source file:org.eobjects.datacleaner.widgets.result.ValueDistributionResultSwingRendererGroupDelegate.java

public JSplitPane renderGroupResult(final ValueCountingAnalyzerResult result) {
    final Integer distinctCount = result.getDistinctCount();
    final Integer unexpectedValueCount = result.getUnexpectedValueCount();
    final int totalCount = result.getTotalCount();

    _valueCounts = result.getReducedValueFrequencies(_preferredSlices);
    for (ValueFrequency valueCount : _valueCounts) {
        setDataSetValue(valueCount.getName(), valueCount.getCount());
    }//from   www.ja  v a  2  s .co m

    logger.info("Rendering with {} slices", getDataSetItemCount());
    drillToOverview(result);

    // chart for display of the dataset
    String title = "Value distribution of " + _groupOrColumnName;
    final JFreeChart chart = ChartFactory.createBarChart(title, "Value", "Count", _dataset,
            PlotOrientation.HORIZONTAL, true, true, false);

    List<Title> titles = new ArrayList<Title>();
    titles.add(new ShortTextTitle("Total count: " + totalCount));
    if (distinctCount != null) {
        titles.add(new ShortTextTitle("Distinct count: " + distinctCount));
    }
    if (unexpectedValueCount != null) {
        titles.add(new ShortTextTitle("Unexpected value count: " + unexpectedValueCount));
    }
    chart.setSubtitles(titles);

    ChartUtils.applyStyles(chart);

    // code-block for tweaking style and coloring of chart
    {
        final CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.getDomainAxis().setVisible(false);

        int colorIndex = 0;
        for (int i = 0; i < getDataSetItemCount(); i++) {
            final String key = getDataSetKey(i);
            final Color color;
            final String upperCaseKey = key.toUpperCase();
            if (_valueColorMap.containsKey(upperCaseKey)) {
                color = _valueColorMap.get(upperCaseKey);
            } else {
                if (i == getDataSetItemCount() - 1) {
                    // the last color should not be the same as the first
                    if (colorIndex == 0) {
                        colorIndex++;
                    }
                }

                Color colorCandidate = SLICE_COLORS[colorIndex];
                int darkAmount = i / SLICE_COLORS.length;
                for (int j = 0; j < darkAmount; j++) {
                    colorCandidate = WidgetUtils.slightlyDarker(colorCandidate);
                }
                color = colorCandidate;

                colorIndex++;
                if (colorIndex >= SLICE_COLORS.length) {
                    colorIndex = 0;
                }
            }

            plot.getRenderer().setSeriesPaint(i, color);
        }
    }

    final ChartPanel chartPanel = new ChartPanel(chart);

    // chartPanel.addChartMouseListener(new ChartMouseListener() {
    //
    // @Override
    // public void chartMouseMoved(ChartMouseEvent event) {
    // ChartEntity entity = event.getEntity();
    // if (entity instanceof PieSectionEntity) {
    // PieSectionEntity pieSectionEntity = (PieSectionEntity) entity;
    // String sectionKey = (String) pieSectionEntity.getSectionKey();
    // if (_groups.containsKey(sectionKey)) {
    // chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    // } else {
    // chartPanel.setCursor(Cursor.getDefaultCursor());
    // }
    // } else {
    // chartPanel.setCursor(Cursor.getDefaultCursor());
    // }
    // }
    //
    // @Override
    // public void chartMouseClicked(ChartMouseEvent event) {
    // ChartEntity entity = event.getEntity();
    // if (entity instanceof PieSectionEntity) {
    // PieSectionEntity pieSectionEntity = (PieSectionEntity) entity;
    // String sectionKey = (String) pieSectionEntity.getSectionKey();
    // if (_groups.containsKey(sectionKey)) {
    // drillToGroup(result, sectionKey, true);
    // }
    // }
    // }
    // });

    final DCPanel leftPanel = new DCPanel();
    leftPanel.setLayout(new VerticalLayout());
    leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel, true, 4));

    _backButton.setMargin(new Insets(0, 0, 0, 0));
    _backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            drillToOverview(result);
        }
    });

    final DCPanel rightPanel = new DCPanel();
    rightPanel.setLayout(new BorderLayout());
    rightPanel.add(_backButton, BorderLayout.NORTH);
    rightPanel.add(_table.toPanel(), BorderLayout.CENTER);

    final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.setOpaque(false);
    split.add(leftPanel);
    split.add(rightPanel);
    split.setDividerLocation(550);

    return split;
}

From source file:misc.TextBatchPrintingDemo.java

/**
 * Create and display the main application frame.
 *///w w  w.  j ava2s  .  c o  m
void createAndShowGUI() {
    messageArea = new JLabel(defaultMessage);

    selectedPages = new JList(new DefaultListModel());
    selectedPages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectedPages.addListSelectionListener(this);

    setPage(homePage);

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(pageItem),
            new JScrollPane(selectedPages));

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    /** Menu item and keyboard shortcuts for the "add page" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Add Page") {
        public void actionPerformed(ActionEvent e) {
            DefaultListModel pages = (DefaultListModel) selectedPages.getModel();
            pages.addElement(pageItem);
            selectedPages.setSelectedIndex(pages.getSize() - 1);
        }
    }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "print selected" command.*/
    fileMenu.add(createMenuItem(new AbstractAction("Print Selected") {
        public void actionPerformed(ActionEvent e) {
            printSelectedPages();
        }
    }, KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "clear selected" command.*/
    fileMenu.add(createMenuItem(new AbstractAction("Clear Selected") {
        public void actionPerformed(ActionEvent e) {
            DefaultListModel pages = (DefaultListModel) selectedPages.getModel();
            pages.removeAllElements();
        }
    }, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK)));

    fileMenu.addSeparator();

    /** Menu item and keyboard shortcuts for the "home page" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Home Page") {
        public void actionPerformed(ActionEvent e) {
            setPage(homePage);
        }
    }, KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "quit" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Quit") {
        public void actionPerformed(ActionEvent e) {
            for (Window w : Window.getWindows()) {
                w.dispose();
            }
        }
    }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK)));

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);

    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(pane);
    contentPane.add(messageArea);

    JFrame frame = new JFrame("Text Batch Printing Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menuBar);
    frame.setContentPane(contentPane);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    if (printService == null) {
        // Actual printing is not possible, issue a warning message.
        JOptionPane.showMessageDialog(frame, "No default print service", "Print Service Alert",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:com.emental.mindraider.ui.outline.OutlineJPanel.java

/**
 * Creates notebook outline./*from  w ww  .  j av a 2s  . c o  m*/
 */
private OutlineJPanel() {
    setDoubleBuffered(true);
    setLayout(new BorderLayout());

    /*
     * toolbar
     */

    JToolBar toolbar = createToolbar();

    /*
     * tree
     */

    // tree table itself
    outlineTableTree = OutlineTreeInstance.getInstance();
    outlineTableTreeModel = new NotebookOutlineModel(outlineTableTree.getOutlineRoot());
    treeTable = new JTreeTable(outlineTableTreeModel);
    treeTable.tree.addTreeSelectionListener(new TreeSelectionListenerImplementation());
    // add key listener
    treeTable.addKeyListener(new KeyListenerImplementation());

    // label column
    TableColumn tableColumn = treeTable
            .getColumn(NotebookOutlineModel.columnNames[NotebookOutlineModel.COLUMN_LABEL]);
    tableColumn.setMaxWidth(LABEL_COLUMN_MAX_WIDTH);
    tableColumn.setMinWidth(0);
    tableColumn.setPreferredWidth(LABEL_COLUMN_PREFERRED_WIDTH);
    // date column
    tableColumn = treeTable.getColumn(NotebookOutlineModel.columnNames[NotebookOutlineModel.COLUMN_CREATED]);
    tableColumn.setMaxWidth(DATE_COLUMN_MAX_WIDTH);
    tableColumn.setMinWidth(0);
    tableColumn.setPreferredWidth(DATE_COLUMN_PREFERRED_WIDTH);
    // and the rest will be annotation
    JScrollPane treeTableScrollPane = new JScrollPane(treeTable);

    // outline treetabble + toolbar panel
    JPanel treeAndToolbarPanel = new JPanel(new BorderLayout());
    treeAndToolbarPanel.add(toolbar, BorderLayout.NORTH);
    treeAndToolbarPanel.add(treeTableScrollPane, BorderLayout.CENTER);

    /*
     * outline / list tabbed pane
     */

    outlineAndTreeTabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    outlineAndTreeTabbedPane.add(treeAndToolbarPanel, "Outline");
    outlineSorterJPanel = new OutlineSorterJPanel();
    outlineAndTreeTabbedPane.add(outlineSorterJPanel, "Sorter");
    outlineArchiveJPanel = new OutlineArchiveJPanel();
    outlineAndTreeTabbedPane.add(outlineArchiveJPanel, "Archive");

    /*
     * concept sidebar
     */

    conceptJPanel = (ConceptJPanel) MindRaiderSpringContext.getCtx().getBean("conceptPanel");

    /*
     * vertical split of notebook outline and RDF graph
     */

    treeAndSpidersSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    treeAndSpidersSplit.setContinuousLayout(true);
    treeAndSpidersSplit.setOneTouchExpandable(true);
    treeAndSpidersSplit.setDividerLocation(200);
    treeAndSpidersSplit.setLastDividerLocation(150);
    treeAndSpidersSplit.setDividerSize(6);
    treeAndSpidersSplit.add(outlineAndTreeTabbedPane);

    // spiders & tags visual navigation
    spidersAndTagsTabs = new JTabbedPane(JTabbedPane.BOTTOM);
    if (MindRaider.profile.isEnableSpiders()) {
        // notebook mind map
        spidersAndTagsTabs.addTab("Mind Map", MindRaider.spidersGraph.getPanel()); // TODO bundle
    }
    // global tags
    spidersAndTagsTabs.addTab("Tag Cloud", MindRaider.tagCustodian.getPanel()); // TODO bundle
    // global mind map
    //spidersAndTagsTabs.addTab("Global Mind Map",new JPanel()); // TODO bundle

    // lazy spiders rendering
    spidersAndTagsTabs.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
            if (sourceTabbedPane.getSelectedIndex() == 0) {
                MindRaider.spidersGraph.renderModel();
            }
        }
    });

    if (!new ConfigurationBean().isDefaultTabMindMap()) {
        spidersAndTagsTabs.setSelectedIndex(1);
    }

    MindRaider.tagCustodian.redraw();

    // add spiders panel
    treeAndSpidersSplit.add(spidersAndTagsTabs);

    /*
     * horizontal split of outline/graph slit and concept sidebar
     */

    rightSiderbarSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeAndSpidersSplit, conceptJPanel);
    rightSiderbarSplitPane.setOneTouchExpandable(true);
    rightSiderbarSplitPane.setContinuousLayout(true);
    rightSiderbarSplitPane.setDividerLocation(500);
    rightSiderbarSplitPane.setLastDividerLocation(500);
    rightSiderbarSplitPane.setDividerSize(6);

    add(rightSiderbarSplitPane);
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

public void init() {

    //   dataPoints = new LinkedList();
    t1_x = t2_x = 0;/*  w  w  w  . j  av  a2 s.com*/
    t1_y = t2_y = 0.001;
    simulatedPoints = setupUniformSimulate(numStocks, numSimulate);
    tabbedPanelContainer = new JTabbedPane();
    show_tangent = true;

    //   addGraph(chartPanel);
    //   addToolbar(sliderPanel);
    initGraphPanel();
    initMixPanel();
    initInputPanel();
    emptyTool();
    emptyTool2();
    leftControl = new JPanel();
    leftControl.setLayout(new BoxLayout(leftControl, BoxLayout.PAGE_AXIS));
    addRadioButton2Left("Number of Stocks:", "", numStocksArray, numStocks - 2, this);
    addRadioButton2Left("Show Tangent Line :", "", on_off, 0, this);

    JScrollPane mixPanelContainer = new JScrollPane(mixPanel);
    mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100));

    addTabbedPane(GRAPH, graphPanel);

    addTabbedPane(INPUT, inputPanel);

    addTabbedPane(ALL, mixPanelContainer);

    setChart();

    tabbedPanelContainer.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) {
                mixPanel.removeAll();
                setMixPanel();
                mixPanel.validate();
            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) {
                graphPanel.removeAll();
                setChart();

            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == INPUT) {
                //
                setInputPanel();
            }
        }
    });

    statusTextArea = new JTextPane(); //right side lower
    statusTextArea.setEditable(false);
    JScrollPane statusContainer = new JScrollPane(statusTextArea);
    statusContainer.setPreferredSize(new Dimension(600, 140));

    JSplitPane upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftControl),
            new JScrollPane(tabbedPanelContainer));

    this.getMainPanel().removeAll();
    if (SHOW_STATUS_TEXTAREA) {
        JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(upContainer),
                statusContainer);
        container.setContinuousLayout(true);
        container.setDividerLocation(0.6);
        this.getMainPanel().add(container, BorderLayout.CENTER);
    } else {

        this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER);
    }
    this.getMainPanel().validate();

}

From source file:org.eobjects.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java

@Override
public JComponent render(DateGapAnalyzerResult result) {

    final TaskSeriesCollection dataset = new TaskSeriesCollection();
    final Set<String> groupNames = result.getGroupNames();
    final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION);
    final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS);
    final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS);
    for (final String groupName : groupNames) {
        final String groupDisplayName;

        if (groupName == null) {
            if (groupNames.size() == 1) {
                groupDisplayName = "All";
            } else {
                groupDisplayName = LabelUtils.NULL_LABEL;
            }/*from   www .ja v a  2  s. com*/
        } else {
            groupDisplayName = groupName;
        }

        final TimeInterval completeDuration = result.getCompleteDuration(groupName);
        final Task completeDurationTask = new Task(groupDisplayName,
                createTimePeriod(completeDuration.getFrom(), completeDuration.getTo()));
        completeDurationTaskSeries.add(completeDurationTask);

        // plot gaps
        {
            final SortedSet<TimeInterval> gaps = result.getGaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : gaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    gapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " gap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }

        // plot overlaps
        {
            final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : overlaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    overlapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " overlap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }
    }
    dataset.add(overlapsTaskSeries);
    dataset.add(gapsTaskSeries);
    dataset.add(completeDurationTaskSeries);

    final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0,
            GROUPS_VISIBLE);

    final JFreeChart chart = ChartFactory.createGanttChart(
            "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(),
            result.getGroupColumnName(), "Time", slidingDataset, true, true, false);
    ChartUtils.applyStyles(chart);

    // make sure the 3 timeline types have correct coloring
    {
        final CategoryPlot plot = (CategoryPlot) chart.getPlot();

        plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT,
                WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT));
    }

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            ChartEntity entity = event.getEntity();
            if (entity instanceof PlotEntity) {
                cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
            }
            chartPanel.setCursor(cursor);
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // do nothing
        }
    });

    final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size());

    chartPanel.setPreferredSize(new Dimension(0, visibleLines * 50 + 200));

    final JComponent decoratedChartPanel;

    StringBuilder chartDescription = new StringBuilder();
    chartDescription
            .append("<html><p>The chart displays the recorded timeline based on FROM and TO dates.<br/><br/>");
    chartDescription.append(
            "The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.<br/><br/>");
    chartDescription.append(
            "You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail.");

    if (groupNames.size() > GROUPS_VISIBLE) {
        final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL);
        scroll.setMinimum(0);
        scroll.setMaximum(groupNames.size());
        scroll.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                int value = e.getAdjustable().getValue();
                slidingDataset.setFirstCategoryIndex(value);
            }
        });

        chartPanel.addMouseWheelListener(new MouseWheelListener() {

            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                int scrollType = e.getScrollType();
                if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                    int wheelRotation = e.getWheelRotation();
                    scroll.setValue(scroll.getValue() + wheelRotation);
                }
            }
        });

        final DCPanel outerPanel = new DCPanel();
        outerPanel.setLayout(new BorderLayout());
        outerPanel.add(chartPanel, BorderLayout.CENTER);
        outerPanel.add(scroll, BorderLayout.EAST);
        chartDescription.append("<br/><br/>Use the right <b>scrollbar</b> to scroll up and down on the chart.");
        decoratedChartPanel = outerPanel;

    } else {
        decoratedChartPanel = chartPanel;
    }

    chartDescription.append("</p></html>");

    final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString());

    chartDescriptionLabel.setBorder(new EmptyBorder(4, 10, 4, 10));

    final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(decoratedChartPanel);
    split.add(chartDescriptionLabel);
    split.setDividerLocation(550);

    return split;
}

From source file:net.sf.jhylafax.addressbook.AddressBook.java

private void initializeContent() {
    horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    horizontalSplitPane.setBorder(GUIHelper.createEmptyBorder(5));

    rootNode = new DefaultMutableTreeNode();
    addressBookTreeModel = new DefaultTreeModel(rootNode);
    addressBookTree = new JTree(addressBookTreeModel);
    addressBookTree.setRootVisible(false);
    addressBookTree.setCellRenderer(new ContactCollectionCellRenderer());
    horizontalSplitPane.add(new JScrollPane(addressBookTree));

    JPanel contactPanel = new JPanel();
    contactPanel.setLayout(new BorderLayout(0, 10));
    horizontalSplitPane.add(contactPanel);

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("min, 3dlu, min, 3dlu, pref:grow, 3dlu, min", ""));
    contactPanel.add(builder.getPanel(), BorderLayout.NORTH);

    searchTextField = new JTextField(10);
    EraseTextFieldAction eraseAction = new EraseTextFieldAction(searchTextField) {
        public void actionPerformed(ActionEvent event) {
            super.actionPerformed(event);
            filterAction.actionPerformed(event);
        };//  w w  w .  ja  va2s . c om
    };
    builder.append(new TabTitleButton(eraseAction));
    filterLabel = new JLabel();
    builder.append(filterLabel);
    builder.append(searchTextField);
    GUIHelper.bindEnterKey(searchTextField, filterAction);

    builder.append(Builder.createButton(filterAction));

    JPopupMenu tablePopupMenu = new JPopupMenu();
    tablePopupMenu.add(Builder.createMenuItem(newAction));
    tablePopupMenu.addSeparator();
    tablePopupMenu.add(Builder.createMenuItem(editAction));
    tablePopupMenu.addSeparator();
    tablePopupMenu.add(Builder.createMenuItem(deleteAction));

    contactTableModel = new AddressTableModel();
    TableSorter sorter = new TableSorter(contactTableModel);
    contactTable = new ColoredTable(sorter);
    contactTableLayoutManager = new TableLayoutManager(contactTable);
    contactTableLayoutManager.addColumnProperties("displayName", "", 180, true);
    contactTableLayoutManager.addColumnProperties("company", "", 80, true);
    contactTableLayoutManager.addColumnProperties("faxNumber", "", 60, true);
    contactTableLayoutManager.initializeTableLayout();
    contactPanel.add(new JScrollPane(contactTable), BorderLayout.CENTER);

    contactTable.setShowVerticalLines(true);
    contactTable.setShowHorizontalLines(false);
    contactTable.setAutoCreateColumnsFromModel(true);
    contactTable.setIntercellSpacing(new java.awt.Dimension(2, 1));
    contactTable.setBounds(0, 0, 50, 50);
    contactTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    contactTable.getSelectionModel().addListSelectionListener(this);
    contactTable.addMouseListener(new PopupListener(tablePopupMenu));
    contactTable.addMouseListener(new DoubleClickListener(new TableDoubleClickAction()));
    contactTable.setTransferHandler(new ContactTransferHandler());
    contactTable.setDragEnabled(true);

    contactTable.setDefaultRenderer(String.class, new StringCellRenderer());

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(horizontalSplitPane, BorderLayout.CENTER);
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java

/**
 * Sets the chat session to associate to this chat panel.
 * @param chatSession the chat session to associate to this chat panel
 *//*  w w  w . j  ava  2  s  . com*/
public void setChatSession(ChatSession chatSession) {
    if (this.chatSession != null) {
        // remove old listener
        this.chatSession.removeChatTransportChangeListener(this);
    }

    this.chatSession = chatSession;
    this.chatSession.addChatTransportChangeListener(this);

    if ((this.chatSession != null) && this.chatSession.isContactListSupported()) {
        topPanel.remove(conversationPanelContainer);

        TransparentPanel rightPanel = new TransparentPanel(new BorderLayout());
        Dimension chatConferencesListsPanelSize = new Dimension(150, 25);
        Dimension chatContactsListsPanelSize = new Dimension(150, 175);
        Dimension rightPanelSize = new Dimension(150, 200);
        rightPanel.setMinimumSize(rightPanelSize);
        rightPanel.setPreferredSize(rightPanelSize);

        TransparentPanel contactsPanel = new TransparentPanel(new BorderLayout());
        contactsPanel.setMinimumSize(chatContactsListsPanelSize);
        contactsPanel.setPreferredSize(chatContactsListsPanelSize);

        conferencePanel.setMinimumSize(chatConferencesListsPanelSize);
        conferencePanel.setPreferredSize(chatConferencesListsPanelSize);

        this.chatContactListPanel = new ChatRoomMemberListPanel(this);
        this.chatContactListPanel.setOpaque(false);

        topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        topSplitPane.setBorder(null); // remove default borders
        topSplitPane.setOneTouchExpandable(true);
        topSplitPane.setOpaque(false);
        topSplitPane.setResizeWeight(1.0D);

        Color msgNameBackground = Color.decode(ChatHtmlUtils.MSG_NAME_BACKGROUND);

        // add border to the divider
        if (topSplitPane.getUI() instanceof BasicSplitPaneUI) {
            ((BasicSplitPaneUI) topSplitPane.getUI()).getDivider()
                    .setBorder(BorderFactory.createLineBorder(msgNameBackground));
        }

        ChatTransport chatTransport = chatSession.getCurrentChatTransport();

        JPanel localUserLabelPanel = new JPanel(new BorderLayout());
        JLabel localUserLabel = new JLabel(chatTransport.getProtocolProvider().getAccountID().getDisplayName());

        localUserLabel.setFont(localUserLabel.getFont().deriveFont(Font.BOLD));
        localUserLabel.setHorizontalAlignment(SwingConstants.CENTER);
        localUserLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 3, 0));
        localUserLabel.setForeground(Color.decode(ChatHtmlUtils.MSG_IN_NAME_FOREGROUND));

        localUserLabelPanel.add(localUserLabel, BorderLayout.CENTER);
        localUserLabelPanel.setBackground(msgNameBackground);

        JButton joinConference = new JButton(
                GuiActivator.getResources().getI18NString("service.gui.JOIN_VIDEO"));

        joinConference.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                showChatConferenceDialog();
            }
        });
        contactsPanel.add(localUserLabelPanel, BorderLayout.NORTH);
        contactsPanel.add(chatContactListPanel, BorderLayout.CENTER);

        conferencePanel.add(joinConference, BorderLayout.CENTER);

        rightPanel.add(conferencePanel, BorderLayout.NORTH);
        rightPanel.add(contactsPanel, BorderLayout.CENTER);

        topSplitPane.setLeftComponent(conversationPanelContainer);
        topSplitPane.setRightComponent(rightPanel);

        topPanel.add(topSplitPane);

    } else {
        if (topSplitPane != null) {
            if (chatContactListPanel != null) {
                topSplitPane.remove(chatContactListPanel);
                chatContactListPanel = null;
            }

            this.messagePane.remove(topSplitPane);
            topSplitPane = null;
        }

        topPanel.add(conversationPanelContainer);
    }

    if (chatSession instanceof MetaContactChatSession) {
        // The subject panel is added here, because it's specific for the
        // multi user chat and is not contained in the single chat chat panel.
        if (subjectPanel != null) {
            this.remove(subjectPanel);
            subjectPanel = null;

            this.revalidate();
            this.repaint();
        }

        writeMessagePanel.initPluginComponents();
        writeMessagePanel.setTransportSelectorBoxVisible(true);

        //Enables to change the protocol provider by simply pressing the
        // CTRL-P key combination
        ActionMap amap = this.getActionMap();

        amap.put("ChangeProtocol", new ChangeTransportAction());

        InputMap imap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK), "ChangeProtocol");
    } else if (chatSession instanceof ConferenceChatSession) {
        ConferenceChatSession confSession = (ConferenceChatSession) chatSession;

        writeMessagePanel.setTransportSelectorBoxVisible(false);

        confSession.addLocalUserRoleListener(this);
        confSession.addMemberRoleListener(this);

        ChatRoom room = ((ChatRoomWrapper) chatSession.getDescriptor()).getChatRoom();
        room.addMemberPropertyChangeListener(this);

        setConferencesPanelVisible(room.getCachedConferenceDescriptionSize() > 0);
        subjectPanel = new ChatRoomSubjectPanel((ConferenceChatSession) chatSession);

        // The subject panel is added here, because it's specific for the
        // multi user chat and is not contained in the single chat chat panel.
        this.add(subjectPanel, BorderLayout.NORTH);

        this.revalidate();
        this.repaint();
    }

    if (chatContactListPanel != null) {
        // Initialize chat participants' panel.
        Iterator<ChatContact<?>> chatParticipants = chatSession.getParticipants();

        while (chatParticipants.hasNext())
            chatContactListPanel.addContact(chatParticipants.next());
    }
}

From source file:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java

public MIResultPanel(IgbService service, String summary, List<MIResult> results, String label, MIQuery query) {
    setLayout(new BorderLayout());

    this.label = label;

    igbLogger = IGBLogger.getInstance(label);

    colorer = TaxonColorer.getColorer(query.getTaxid());

    Box menuBox = new Box(BoxLayout.X_AXIS);

    Box buttonBox = new Box(BoxLayout.Y_AXIS);
    Box buttonBox1 = new Box(BoxLayout.X_AXIS);

    Box buttonBox3 = new Box(BoxLayout.X_AXIS);
    buttonBox.add(buttonBox1);/*from w  ww  . java  2 s.  c om*/

    buttonBox.add(buttonBox3);

    JTextPane querySummary = new JTextPane();
    querySummary.setContentType("text/html");
    querySummary.setEditable(false);
    querySummary.setText(summary);

    menuBox.add(querySummary);

    menuBox.add(buttonBox);

    final JFrame logFrame = new JFrame("MI Bundle Log");
    logFrame.setVisible(false);
    Dimension preferredSize = new Dimension(800, 500);

    logFrame.setPreferredSize(preferredSize);
    logFrame.setMinimumSize(preferredSize);

    logFrame.add(new LogPanel(igbLogger));

    JButton log = new JButton();

    if (igbLogger.hasError()) {
        log.setBackground(Color.red);
    }

    log.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/console.png"));

    log.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            logFrame.setVisible(true);
        }

    });

    buttonBox1.add(log);

    JButton networkButton = new JButton("");
    networkButton.setIcon(new ImageIcon(getClass().getResource("/network.jpg")));
    networkButton.addActionListener(new DisplayNetworkActionListener());

    buttonBox1.add(networkButton);

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));

    buttonBox1.add(new JLabel("Save: "));
    JButton exportButton = new JButton("text");
    exportButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png"));
    exportButton.addActionListener(new ExportActionListener());

    if (false == MICommons.testVersion) {
        buttonBox1.add(exportButton);
    }

    JButton exportXgmmlButton = new JButton("xgmml");
    exportXgmmlButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png"));
    exportXgmmlButton.addActionListener(new ExportXgmmlActionListener());
    if (false == MICommons.testVersion) {
        buttonBox1.add(exportXgmmlButton);
    }

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));

    buttonBox1.add(new JLabel("View structure: "));

    structures = new StructuresPanel(service, label);

    buttonBox1.add(structures.getJmolButton());
    buttonBox1.add(structures.getLinkButton());

    // Filters
    ButtonGroup scoreGroup = new ButtonGroup();
    JRadioButton scoreButton0 = new JRadioButton("<html>" + HTML_SCORE_0 + "</html>");
    JRadioButton scoreButton1 = new JRadioButton("<html>" + HTML_SCORE_1 + "</html>");
    JRadioButton scoreButton2 = new JRadioButton("<html>" + HTML_SCORE_2 + "</html>");
    JRadioButton scoreButton3 = new JRadioButton("<html>" + HTML_SCORE_3 + "</html>");
    scoreButton0.setSelected(true);

    ScoreListener scoreListener = new ScoreListener();
    scoreButton0.addActionListener(scoreListener);
    scoreButton1.addActionListener(scoreListener);
    scoreButton2.addActionListener(scoreListener);
    scoreButton3.addActionListener(scoreListener);

    scoreGroup.add(scoreButton0);
    scoreGroup.add(scoreButton1);
    scoreGroup.add(scoreButton2);
    scoreGroup.add(scoreButton3);

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));
    buttonBox1.add(new JLabel("Score: "));
    buttonBox1.add(scoreButton0);
    buttonBox1.add(scoreButton1);
    buttonBox1.add(scoreButton2);
    buttonBox1.add(scoreButton3);

    buttonBox3.add(new JLabel("Interaction type: "));

    JCheckBox EvidencePhysicalButton = new JCheckBox(HTML_CHECKBOX_PHYSICAL);
    JCheckBox EvidenceAssociationButton = new JCheckBox(HTML_CHECKBOX_ASSOCIATION);
    JCheckBox EvidenceEnzymaticButton = new JCheckBox(HTML_CHECKBOX_ENZYMATIC);
    JCheckBox EvidenceOtherButton = new JCheckBox(HTML_CHECKBOX_OTHER);
    JCheckBox EvidenceUnspecifiedButton = new JCheckBox(HTML_CHECKBOX_UNSPECIFIED);
    JCheckBox EvidenceStructureButton = new JCheckBox(HTML_CHECKBOX_STRUCTURE);

    EvidencePhysicalButton.setSelected(true);
    EvidenceAssociationButton.setSelected(true);
    EvidenceEnzymaticButton.setSelected(true);
    EvidenceOtherButton.setSelected(true);
    EvidenceUnspecifiedButton.setSelected(true);
    EvidenceStructureButton.setSelected(true);

    buttonBox3.add(EvidencePhysicalButton);
    buttonBox3.add(EvidenceAssociationButton);
    buttonBox3.add(EvidenceEnzymaticButton);
    buttonBox3.add(EvidenceOtherButton);
    buttonBox3.add(EvidenceUnspecifiedButton);
    buttonBox3.add(EvidenceStructureButton);

    EvidenceTypeListener evidenceListener = new EvidenceTypeListener();
    EvidencePhysicalButton.addActionListener(evidenceListener);
    EvidenceAssociationButton.addActionListener(evidenceListener);
    EvidenceEnzymaticButton.addActionListener(evidenceListener);
    EvidenceOtherButton.addActionListener(evidenceListener);
    EvidenceUnspecifiedButton.addActionListener(evidenceListener);
    EvidenceStructureButton.addActionListener(evidenceListener);

    Box tableBox = new Box(BoxLayout.Y_AXIS);

    MITableModel model = new MITableModel(results);

    miTable = new MITable(model, service, query);

    miTable.setFillsViewportHeight(true);

    miTable.setStructuresPanel(structures);

    tableBox.add(miTable.getTableHeader());
    tableBox.add(miTable);

    JScrollPane tableScroll = new JScrollPane(tableBox);

    tableScroll.setMinimumSize(new Dimension(800, 50));
    tableScroll.setPreferredSize(new Dimension(800, 50));
    tableScroll.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));

    structures.setMinimumSize(new Dimension(200, 500));
    structures.setPreferredSize(new Dimension(200, 500));
    structures.setMaximumSize(new Dimension(200, Short.MAX_VALUE));

    resultBox = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScroll, structures);
    resultBox.setOneTouchExpandable(true);

    add(menuBox, BorderLayout.NORTH);
    add(resultBox, BorderLayout.CENTER);

}

From source file:com.opendoorlogistics.studio.AppFrame.java

public AppFrame() {

    // create frame with desktop pane
    Container con = getContentPane();
    con.setLayout(new BorderLayout());

    SwingWorker<BufferedImage, BufferedImage> createBackground = new SwingWorker<BufferedImage, BufferedImage>() {

        @Override/*from  www .  j a v a2 s . c  om*/
        protected BufferedImage doInBackground() throws Exception {
            // background = new AppBackground().create();
            AppBackground ab = new AppBackground();

            ab.start();
            long lastTime = System.currentTimeMillis();
            int lastRendered = 0;
            while (ab.getNbConsecutiveFails() < 100) {
                ab.doStep();
                long current = System.currentTimeMillis();
                if (current - lastTime > 100 && lastRendered != ab.getNbRendered()) {
                    background = ImageUtils.deepCopy(ab.getImage());
                    publish(background);
                    lastTime = current;
                    lastRendered = ab.getNbRendered();
                }
            }

            ab.finish();

            background = ab.getImage();
            return background;
        }

        @Override
        protected void process(List<BufferedImage> chunks) {
            repaint();
        }

        @Override
        public void done() {
            AppFrame.this.repaint();
        }
    };
    createBackground.execute();

    initWindowPosition();

    registerAppFrameDependentComponents();

    // then create other objects which might use the components
    tables = new DatastoreTablesPanel(this);

    // create scripts panel after registering components
    scriptManager = new ScriptUIManagerImpl(this);
    scriptsPanel = new ScriptsPanel(getApi(), PreferencesManager.getSingleton().getScriptsDirectory(),
            scriptManager);

    // set my icon
    setIconImage(Icons.loadFromStandardPath("App logo.png").getImage());

    // create actions
    fileActions = initFileActions();
    editActions = initEditActions();

    // create left-hand panel with scripts and tables
    splitterTablesScripts = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tables, scriptsPanel);
    splitterTablesScripts.setPreferredSize(new Dimension(200, splitterTablesScripts.getPreferredSize().height));
    splitterTablesScripts.setResizeWeight(0.5);

    // split center part into tables/scripts browser on the left and desktop
    // pane on the right
    desktopScrollPane = new DesktopScrollPane(desktopPane);
    splitterLeftPanelMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitterTablesScripts,
            desktopScrollPane);
    con.add(splitterLeftPanelMain, BorderLayout.CENTER);

    // add toolbar
    initToolbar(con);

    initMenus();

    // control close operation to stop changed being lost
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            if (canCloseDatastore()) {
                dispose();
                System.exit(0);
            }
        }
    });

    setVisible(true);
    updateAppearance();

}