Search in sources :

Example 31 with JSplitPane

use of javax.swing.JSplitPane in project JMRI by JMRI.

the class ThreePaneTLRWindow method configureFrame.

protected void configureFrame() {
    // TODO figure out what WI is used here
    rightTopWI = new jmri.util.swing.sdi.JmriJFrameInterface();
    //rightTop.setBorder(BorderFactory.createLineBorder(Color.black));
    top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
    right.setLayout(new FlowLayout());
    left.setLayout(new FlowLayout());
    leftRightSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
    leftRightSplitPane.setOneTouchExpandable(true);
    // emphasize right part
    leftRightSplitPane.setResizeWeight(0.0);
    upDownSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, leftRightSplitPane);
    upDownSplitPane.setOneTouchExpandable(true);
    // emphasize top part
    upDownSplitPane.setResizeWeight(1.0);
    add(upDownSplitPane, BorderLayout.CENTER);
}
Also used : FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout) JSplitPane(javax.swing.JSplitPane)

Example 32 with JSplitPane

use of javax.swing.JSplitPane in project JMRI by JMRI.

the class MdiMainFrame method configureFrame.

protected void configureFrame(String treeFile) {
    desktop = new JDesktopPane();
    desktop.setBorder(BorderFactory.createLineBorder(Color.black));
    leftRightSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, makeLeftTree(treeFile), desktop);
    leftRightSplitPane.setOneTouchExpandable(true);
    // emphasize right part
    leftRightSplitPane.setResizeWeight(0.0);
    add(leftRightSplitPane, BorderLayout.CENTER);
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JSplitPane(javax.swing.JSplitPane)

Example 33 with JSplitPane

use of javax.swing.JSplitPane in project JMRI by JMRI.

the class TieToolFrame method initComponents.

@Override
public void initComponents() throws Exception {
    // set the frame's initial state
    setTitle(rb.getString("WindowTitle"));
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    ProducerTablePane producerPane = new ProducerTablePane();
    producerPane.initComponents();
    Border producerBorder = BorderFactory.createEtchedBorder();
    Border producerTitled = BorderFactory.createTitledBorder(producerBorder, "Producers");
    producerPane.setBorder(producerTitled);
    ConsumerTablePane consumerPane = new ConsumerTablePane();
    consumerPane.initComponents();
    Border consumerBorder = BorderFactory.createEtchedBorder();
    Border consumerTitled = BorderFactory.createTitledBorder(consumerBorder, "Consumers");
    consumerPane.setBorder(consumerTitled);
    TieTablePane tiePane = new TieTablePane();
    tiePane.initComponents();
    Border tieBorder = BorderFactory.createEtchedBorder();
    Border tieTitled = BorderFactory.createTitledBorder(tieBorder, "Events");
    tiePane.setBorder(tieTitled);
    JSplitPane upperSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, producerPane, consumerPane);
    JSplitPane wholeSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperSplit, tiePane);
    JPanel p1 = new JPanel();
    p1.add(wholeSplit);
    contentPane.add(p1);
    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(new JButton("Add"));
    p2.add(new JButton("Update"));
    p2.add(new JButton("Delete"));
    contentPane.add(p2);
    // initialize menu bar
    JMenuBar menuBar = new JMenuBar();
    // set up File menu
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    // fileMenu.add(...);
    setJMenuBar(menuBar);
    addHelpMenu("package.jmri.jmrix.openlcb.swing.tie.TieToolFrame", true);
    // pack for display
    pack();
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JSplitPane(javax.swing.JSplitPane) Border(javax.swing.border.Border) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 34 with JSplitPane

use of javax.swing.JSplitPane in project JMRI by JMRI.

the class ListedTableFrame method initComponents.

@Override
public void initComponents() {
    actionList = new ActionJList(this);
    detailpanel = new JPanel();
    detailpanel.setLayout(new CardLayout());
    tabbedTableArray = new ArrayList<TabbedTableItem>(TabbedTableItemListArrayArray.size());
    ArrayList<TabbedTableItemListArray> removeItem = new ArrayList<TabbedTableItemListArray>(5);
    for (int x = 0; x < TabbedTableItemListArrayArray.size(); x++) {
        /* Here we add all the tables into the panel*/
        TabbedTableItemListArray item = TabbedTableItemListArrayArray.get(x);
        try {
            TabbedTableItem itemModel = new TabbedTableItem(item.getClassAsString(), item.getItemString(), item.getStandardTableModel());
            itemBeingAdded = itemModel;
            detailpanel.add(itemModel.getPanel(), itemModel.getClassAsString());
            tabbedTableArray.add(itemModel);
            itemBeingAdded.getAAClass().addToFrame(this);
        } catch (Exception ex) {
            detailpanel.add(errorPanel(item.getItemString()), item.getClassAsString());
            log.error("Error when adding " + item.getClassAsString() + " to display\n" + ex);
            ex.printStackTrace();
            removeItem.add(item);
        }
    }
    for (TabbedTableItemListArray dead : removeItem) {
        TabbedTableItemListArrayArray.remove(dead);
    }
    list = new JList<String>(new Vector<String>(getChoices()));
    listScroller = new JScrollPane(list);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list.setLayoutOrientation(JList.VERTICAL);
    list.addMouseListener(actionList);
    buttonpanel = new JPanel();
    buttonpanel.setLayout(new BorderLayout(5, 0));
    buttonpanel.setLayout(new BoxLayout(buttonpanel, BoxLayout.Y_AXIS));
    buttonpanel.add(listScroller);
    buildMenus(tabbedTableArray.get(0));
    setTitle(tabbedTableArray.get(0).getItemString());
    cardHolder = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buttonpanel, detailpanel);
    cardHolder.setDividerSize(8);
    if (lastdivider != 0) {
        cardHolder.setDividerLocation(lastdivider);
    } else {
        // if no specific size has been given we set it to the lists preferred width
        cardHolder.setDividerLocation(listScroller.getPreferredSize().width);
    }
    cardHolder.addPropertyChangeListener(new PropertyChangeListener() {

        @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "We only intend to use/save the last position of the Split frame")
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals("dividerLocation")) {
                lastdivider = (Integer) e.getNewValue();
            }
        }
    });
    cardHolder.setOneTouchExpandable(true);
    getContentPane().add(cardHolder);
    pack();
    actionList.selectListItem(0);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) ArrayList(java.util.ArrayList) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) BorderLayout(java.awt.BorderLayout) JSplitPane(javax.swing.JSplitPane) Vector(java.util.Vector)

Example 35 with JSplitPane

use of javax.swing.JSplitPane in project JMRI by JMRI.

the class RosterFrame method createTop.

JComponent createTop() {
    Object selectedRosterGroup = prefsMgr.getProperty(getWindowFrameRef(), SELECTED_ROSTER_GROUP);
    groups = new RosterGroupsPanel((selectedRosterGroup != null) ? selectedRosterGroup.toString() : null);
    groups.setNewWindowMenuAction(this.getNewWindowAction());
    setTitle(groups.getSelectedRosterGroup());
    final JPanel rosters = new JPanel();
    rosters.setLayout(new BorderLayout());
    // set up roster table
    rtable = new RosterTable(true, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    rtable.setRosterGroup(this.getSelectedRosterGroup());
    rtable.setRosterGroupSource(groups);
    rosters.add(rtable, BorderLayout.CENTER);
    // add selection listener
    rtable.getTable().getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
        JTable table = rtable.getTable();
        if (!e.getValueIsAdjusting()) {
            if (rtable.getSelectedRosterEntries().length == 1 && table.getSelectedRow() >= 0) {
                log.debug("Selected row ", table.getSelectedRow());
                locoSelected(rtable.getModel().getValueAt(table.getRowSorter().convertRowIndexToModel(table.getSelectedRow()), RosterTableModel.IDCOL).toString());
            } else if (rtable.getSelectedRosterEntries().length > 1 || table.getSelectedRow() < 0) {
                locoSelected(null);
            }
        // leave last selected item visible if no selection
        }
    });
    //Set all the sort and width details of the table first.
    String rostertableref = getWindowFrameRef() + ":roster";
    rtable.getTable().setName(rostertableref);
    // Allow only one column to be sorted at a time - 
    // Java allows multiple column sorting, but to effectly persist that, we
    // need to be intelligent about which columns can be meaningfully sorted
    // with other columns; this bypasses the problem by only allowing the
    // last column sorted to affect sorting
    RowSorterUtil.addSingleSortableColumnListener(rtable.getTable().getRowSorter());
    // Reset and then persist the table's ui state
    JTablePersistenceManager tpm = InstanceManager.getNullableDefault(JTablePersistenceManager.class);
    if (tpm != null) {
        tpm.resetState(rtable.getTable());
        tpm.persist(rtable.getTable());
    }
    rtable.getTable().setDragEnabled(true);
    rtable.getTable().setTransferHandler(new TransferHandler() {

        @Override
        public int getSourceActions(JComponent c) {
            return TransferHandler.COPY;
        }

        @Override
        public Transferable createTransferable(JComponent c) {
            JTable table = rtable.getTable();
            ArrayList<String> Ids = new ArrayList<>(table.getSelectedRowCount());
            for (int i = 0; i < table.getSelectedRowCount(); i++) {
                Ids.add(rtable.getModel().getValueAt(table.getRowSorter().convertRowIndexToModel(table.getSelectedRows()[i]), RosterTableModel.IDCOL).toString());
            }
            return new RosterEntrySelection(Ids);
        }

        @Override
        public void exportDone(JComponent c, Transferable t, int action) {
        // nothing to do
        }
    });
    MouseListener rosterMouseListener = new rosterPopupListener();
    rtable.getTable().addMouseListener(rosterMouseListener);
    try {
        clickDelay = ((Integer) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"));
    } catch (RuntimeException e) {
        clickDelay = 500;
        log.debug("Unable to get the double click speed, Using JMRI default of half a second" + e.toString());
    }
    // assemble roster/groups splitpane
    rosterGroupSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, groups, rosters);
    rosterGroupSplitPane.setOneTouchExpandable(true);
    // emphasis rosters
    rosterGroupSplitPane.setResizeWeight(0);
    Object w = prefsMgr.getProperty(getWindowFrameRef(), "rosterGroupPaneDividerLocation");
    if (w != null) {
        groupSplitPaneLocation = (Integer) w;
        rosterGroupSplitPane.setDividerLocation(groupSplitPaneLocation);
    }
    if (!Roster.getDefault().getRosterGroupList().isEmpty()) {
        if (prefsMgr.getSimplePreferenceState(this.getClass().getName() + ".hideGroups")) {
            hideGroupsPane(true);
        }
    } else {
        enableRosterGroupMenuItems(false);
    }
    PropertyChangeListener propertyChangeListener = (PropertyChangeEvent changeEvent) -> {
        JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
        String propertyName = changeEvent.getPropertyName();
        if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
            int current = sourceSplitPane.getDividerLocation();
            hideGroups = current <= 1;
            Integer last = (Integer) changeEvent.getNewValue();
            if (current >= 2) {
                groupSplitPaneLocation = current;
            } else if (last >= 2) {
                groupSplitPaneLocation = last;
            }
        }
    };
    groups.addPropertyChangeListener(SELECTED_ROSTER_GROUP, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            prefsMgr.setProperty(this.getClass().getName(), SELECTED_ROSTER_GROUP, pce.getNewValue());
            setTitle((String) pce.getNewValue());
        }
    });
    rosterGroupSplitPane.addPropertyChangeListener(propertyChangeListener);
    Roster.getDefault().addPropertyChangeListener((PropertyChangeEvent e) -> {
        if (e.getPropertyName().equals("RosterGroupAdded") && Roster.getDefault().getRosterGroupList().size() == 1) {
            // if the pane is hidden, show it when 1st group is created
            hideGroupsPane(false);
            enableRosterGroupMenuItems(true);
        } else if (!rtable.isVisible() && (e.getPropertyName().equals("saved"))) {
            if (firstHelpLabel != null) {
                firstHelpLabel.setVisible(false);
            }
            rtable.setVisible(true);
            rtable.resetColumnWidths();
        }
    });
    if (Roster.getDefault().numEntries() == 0) {
        try {
            BufferedImage myPicture = ImageIO.read(FileUtil.findURL(("resources/" + Bundle.getMessage("ThrottleFirstUseImage")), FileUtil.Location.INSTALLED));
            //rosters.add(new JLabel(new ImageIcon( myPicture )), BorderLayout.CENTER);
            firstHelpLabel = new JLabel(new ImageIcon(myPicture));
            rtable.setVisible(false);
            rosters.add(firstHelpLabel, BorderLayout.NORTH);
            //tableArea.add(firstHelpLabel);
            rtable.setVisible(false);
        } catch (IOException ex) {
        // handle exception...
        }
    }
    return rosterGroupSplitPane;
}
Also used : RosterEntrySelection(jmri.util.datatransfer.RosterEntrySelection) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) PropertyChangeListener(java.beans.PropertyChangeListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) BufferedImage(java.awt.image.BufferedImage) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) PropertyChangeEvent(java.beans.PropertyChangeEvent) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JLabel(javax.swing.JLabel) IOException(java.io.IOException) JTablePersistenceManager(jmri.swing.JTablePersistenceManager) JTable(javax.swing.JTable) TransferHandler(javax.swing.TransferHandler) JSplitPane(javax.swing.JSplitPane)

Aggregations

JSplitPane (javax.swing.JSplitPane)109 BorderLayout (java.awt.BorderLayout)69 JPanel (javax.swing.JPanel)64 JScrollPane (javax.swing.JScrollPane)54 Dimension (java.awt.Dimension)40 JLabel (javax.swing.JLabel)31 JButton (javax.swing.JButton)17 JTextArea (javax.swing.JTextArea)16 FlowLayout (java.awt.FlowLayout)15 Insets (java.awt.Insets)15 GridBagLayout (java.awt.GridBagLayout)14 GridBagConstraints (java.awt.GridBagConstraints)13 JTable (javax.swing.JTable)13 Container (java.awt.Container)10 GridLayout (java.awt.GridLayout)10 ArrayList (java.util.ArrayList)10 BoxLayout (javax.swing.BoxLayout)10 JComponent (javax.swing.JComponent)10 JTabbedPane (javax.swing.JTabbedPane)10 EmptyBorder (javax.swing.border.EmptyBorder)10