Search in sources :

Example 1 with JAutoScrollBarPane

use of org.freeplane.core.ui.components.JAutoScrollBarPane in project freeplane by freeplane.

the class CollectionBoxController method createMoveButton.

private JButton createMoveButton(final String elementName) {
    JButton btnMove = TranslatedElementFactory.createButtonWithIcon(elementName + ".move.icon", "collection.move");
    btnMove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Vector<String> items = new Vector<>(collection.getSize());
            for (int i = 1; i <= collection.getSize(); i++) {
                items.addElement(i + ": " + collection.getElement(i - 1).getName());
            }
            final ComboBoxModel<String> elements = new DefaultComboBoxModel<>(items);
            JList<String> targets = new JList<>(elements);
            targets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            final String title = TextUtils.getText("collection.moveTo");
            if (JOptionPane.showConfirmDialog(collectionComponent, new JAutoScrollBarPane(targets), title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION)
                UndoableNamedElementCollection.of(collection).moveCurrentElementTo(targets.getSelectedIndex());
        }
    });
    return btnMove;
}
Also used : JAutoScrollBarPane(org.freeplane.core.ui.components.JAutoScrollBarPane) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Vector(java.util.Vector) ComboBoxModel(javax.swing.ComboBoxModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JList(javax.swing.JList)

Example 2 with JAutoScrollBarPane

use of org.freeplane.core.ui.components.JAutoScrollBarPane in project freeplane by freeplane.

the class PresentationController method createPanel.

private Component createPanel() {
    final Component presentationEditor = presentationEditorController.createPanel(modeController);
    presentationEditor.addHierarchyListener(new HierarchyListener() {

        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if (0 != (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED))
                presentationState.setHighlightsNodes(e.getComponent().isShowing());
        }
    });
    return new JAutoScrollBarPane(presentationEditor);
}
Also used : JAutoScrollBarPane(org.freeplane.core.ui.components.JAutoScrollBarPane) HierarchyEvent(java.awt.event.HierarchyEvent) Component(java.awt.Component) HierarchyListener(java.awt.event.HierarchyListener)

Aggregations

JAutoScrollBarPane (org.freeplane.core.ui.components.JAutoScrollBarPane)2 Component (java.awt.Component)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 HierarchyEvent (java.awt.event.HierarchyEvent)1 HierarchyListener (java.awt.event.HierarchyListener)1 Vector (java.util.Vector)1 ComboBoxModel (javax.swing.ComboBoxModel)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JButton (javax.swing.JButton)1 JList (javax.swing.JList)1