Example usage for javax.swing JScrollPane setVerticalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setVerticalScrollBarPolicy

Introduction

In this page you can find the example usage for javax.swing JScrollPane setVerticalScrollBarPolicy.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane vertical scrollbar policy")
public void setVerticalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the vertical scrollbar appears in the scrollpane.

Usage

From source file:org.zaproxy.zap.extension.httppanel.view.syntaxhighlight.HttpPanelSyntaxHighlightTextView.java

private void init() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    httpPanelTextArea = createHttpPanelTextArea();
    httpPanelTextArea.setEditable(false);
    httpPanelTextArea.setComponentPopupMenu(new CustomPopupMenu());

    JScrollPane scrollPane = new RTextScrollPane(httpPanelTextArea, false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    mainPanel.add(scrollPane, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.extension.httppanelviews.syntaxhighlight.HttpPanelSyntaxHighlightTextView.java

private void init() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    httpPanelTextArea = createHttpPanelTextArea();
    httpPanelTextArea.setEditable(false);
    httpPanelTextArea.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override//from  ww  w.  jav a2s . c o  m
        public void mouseReleased(java.awt.event.MouseEvent e) {
            // right mouse button action
            if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || e.isPopupTrigger()) {
                if (!httpPanelTextArea.isFocusOwner()) {
                    httpPanelTextArea.requestFocusInWindow();
                }

                View.getSingleton().getPopupMenu().show(httpPanelTextArea, e.getX(), e.getY());
            }
        }
    });

    JScrollPane scrollPane = new RTextScrollPane(httpPanelTextArea, false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    mainPanel.add(scrollPane, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.extension.tlsdebug.TlsDebugPanel.java

@SuppressWarnings("deprecation")
private void initialize() {

    this.setIcon(TLSDEBUG_ICON);
    this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,
            // TODO Remove warn suppression and use View.getMenuShortcutKeyStroke with
            // newer ZAP (or use getMenuShortcutKeyMaskEx() with Java 10+)
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.ALT_DOWN_MASK, false));
    this.setLayout(new BorderLayout());

    JPanel panelContent = new JPanel(new GridBagLayout());
    this.add(panelContent, BorderLayout.NORTH);

    panelContent.setBackground(Color.white);
    panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    panelContent.add(new JLabel(Constant.messages.getString("tlsdebug.label.url")),
            LayoutHelper.getGBC(0, 0, 1, 0.0D, new Insets(5, 5, 5, 5)));

    JPanel urlSelectPanel = new JPanel(new GridBagLayout());
    JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
    selectButton.setIcon(/*from ww w .ja v a2s  .  c  om*/
            DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe
    // icon
    selectButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame());
            SiteNode node = null;
            try {
                node = Model.getSingleton().getSession().getSiteTree()
                        .findNode(new URI(getUrlField().getText(), false));
            } catch (Exception e2) {
                // Ignore
            }
            node = nsd.showDialog(node);
            if (node != null && node.getHistoryReference() != null) {
                try {
                    getUrlField().setText(node.getHistoryReference().getURI().toString());
                } catch (Exception e1) {
                    // Ignore
                }
            }
        }
    });

    urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D));
    urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D));
    panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 0, 3, 0.25D));

    panelContent.add(this.getCheckButton(), LayoutHelper.getGBC(0, 1, 1, 0.0D));

    JPanel outputPanel = new JPanel(new BorderLayout());
    outputPanel.add(new JLabel(Constant.messages.getString("tlsdebug.label.console")), BorderLayout.NORTH);
    JScrollPane jScrollPane = new JScrollPane();
    jScrollPane.add(getOutputArea(), LayoutHelper.getGBC(0, 0, 4, 1.D, 1.0D)); // Padding
    // at
    // bottom
    jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11));
    jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.setViewportView(getOutputArea());
    outputPanel.add(jScrollPane, BorderLayout.CENTER);

    this.add(outputPanel, BorderLayout.CENTER);
}

From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java

private void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    addButton.setText("Add Next Chronicle");
    addButton.setActionCommand(ADD_COMMAND);
    allButton.setText("All");
    allButton.setActionCommand(ALL_COMMAND);
    noneButton.setText("None");
    noneButton.setActionCommand(NONE_COMMAND);

    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(new JLabel("Check an item to include on your Character Sheet"));
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(allButton);/*from w w w  . j  a  v  a  2  s  .co m*/
    hbox.add(Box.createRigidArea(new Dimension(3, 0)));
    hbox.add(noneButton);
    hbox.add(Box.createHorizontalGlue());

    add(Box.createVerticalStrut(5));
    add(hbox);
    add(Box.createVerticalStrut(10));
    JScrollPane pane = new JScrollPane(chroniclesPane) {

        @Override
        public Dimension getMaximumSize() {
            Dimension size = getPreferredSize();
            size.width = Integer.MAX_VALUE;
            return size;
        }

        @Override
        public boolean isValidateRoot() {
            return false;
        }

    };
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    add(pane);
    add(Box.createVerticalStrut(10));
    addButton.setAlignmentX(0.5f);
    add(addButton);
    add(Box.createVerticalStrut(5));
    add(Box.createVerticalGlue());
}

From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java

/**
 * create a new instance of XslTree The nodes will be automaticaly
 * duplicated if the schema specify that more than one element of this type
 * are mandatory//from w w w .j  a v  a 2 s .  c  o m
 */
public XsdTreePanelImpl(XsdTreeStructImpl xsdTree, JTextPane messagePane) {
    super(xsdTree);

    messagePane.setEditable(false);

    JScrollPane scrollpane = new JScrollPane(messagePane);
    scrollpane.setMaximumSize(new Dimension(Short.MAX_VALUE, 150));
    scrollpane.setMinimumSize(new Dimension(200, 150));
    scrollpane.setPreferredSize(new Dimension(200, 150));
    scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.setBorder(new TitledBorder("Messages"));

    add(scrollpane, BorderLayout.SOUTH);
    add(getButtonPanel(), BorderLayout.EAST);
    MouseListener mouseListener = new TreeMouseAdapter();
    xsdTree.tree.addMouseListener(mouseListener);
}

From source file:qic.launcher.Main.java

private void startGUI(TakeDown installer) {
    TextAreaWithBackground textArea = new TextAreaWithBackground();

    JButton launchButton = new JButton("  Launch  ");
    launchButton.setEnabled(false);/*from  w w  w  .  j a v  a  2  s  . co  m*/
    JProgressBar progressBar = new JProgressBar();

    launchButton.addActionListener(e -> {
        runAIC();
        System.exit(0);
    });

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));
    southPanel.add(progressBar);
    southPanel.add(launchButton);
    JFrame frame = new JFrame("QIC Search Updater");
    frame.setIconImage(new ImageIcon(getClass().getResource("/q.png")).getImage());
    frame.setLayout(new BorderLayout(5, 5));
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.getContentPane().add(southPanel, BorderLayout.SOUTH);
    frame.setSize(495, 445);
    frame.setLocationRelativeTo(null);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

    textArea.setText("Loading path notes...");

    String imgUrl = "http://poeqic.github.io/launcher/images/background.png";
    try {
        Image image = ImageIO.read(new URL(imgUrl));
        if (image != null)
            textArea.setBackgroundImage(image);
    } catch (IOException ex) {
        logger.error("Error while loading background image from: " + imgUrl, ex);
    }

    Worker<String> pathNotesWorker = new Worker<String>(() -> URLConnectionReader.getText(CHANGELOG_URL),
            s -> textArea.setText(s), e -> showErrorAndQuit(e));
    pathNotesWorker.execute();

    Worker<Boolean> updaterWorker = new Worker<Boolean>(() -> {
        progressBar.setIndeterminate(true);
        return installer.installOrUpdate();
    }, b -> {
        progressBar.setIndeterminate(false);
        launchButton.setEnabled(true);
    }, e -> showErrorAndQuit(e));
    updaterWorker.execute();

}

From source file:tk.tomby.tedit.core.Buffer.java

/**
 * Creates a new Buffer object.//from   w w  w. java  2s .  c o m
 */
public Buffer() {
    super();

    setLayout(new BorderLayout());

    JPanel internalPanel = new JPanel();
    internalPanel.setLayout(new BorderLayout());

    editor = new ColourTextArea();

    int red = PreferenceManager.getInt("general.editor.background.red", 0);
    int green = PreferenceManager.getInt("general.editor.background.green", 0);
    int blue = PreferenceManager.getInt("general.editor.background.blue", 0);
    editor.setBackground(new Color(red, green, blue));

    red = PreferenceManager.getInt("general.editor.foreground.red", 0);
    green = PreferenceManager.getInt("general.editor.foreground.green", 0);
    blue = PreferenceManager.getInt("general.editor.foreground.blue", 0);
    editor.setForeground(new Color(red, green, blue));

    red = PreferenceManager.getInt("general.editor.selection.red", 0);
    green = PreferenceManager.getInt("general.editor.selection.green", 0);
    blue = PreferenceManager.getInt("general.editor.selection.blue", 0);
    editor.setSelectionColor(new Color(red, green, blue));

    String font = PreferenceManager.getString("general.editor.font", "Monospaced");
    int size = PreferenceManager.getInt("general.editor.fontSize", 12);
    editor.setFont(new Font(font, Font.PLAIN, size));

    editor.setEditable(true);
    editor.setDragEnabled(true);
    editor.setEditorKit(EditorKitManager.createEditorKit(getExtension(DEFAULT_FILE_NAME)));

    InputMap map = editor.getInputMap(JComponent.WHEN_FOCUSED);

    for (InputMap imap = map; imap != null; imap = imap.getParent()) {
        imap.remove(KeyStroke.getKeyStroke('V', InputEvent.CTRL_MASK, false));
        imap.remove(KeyStroke.getKeyStroke('C', InputEvent.CTRL_MASK, false));
        imap.remove(KeyStroke.getKeyStroke('X', InputEvent.CTRL_MASK, false));
        imap.remove(KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK, false));
    }

    editor.setInputMap(JComponent.WHEN_FOCUSED, map);

    editor.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent evt) {
            MessageManager.sendMessage(new BufferMessage(evt.getSource(), BufferMessage.CARET_EVENT));
        }
    });

    internalPanel.add(BorderLayout.CENTER, editor);

    if (PreferenceManager.getBoolean("general.editor.lineNumbers", false)) {
        lines = new LineNumbering();
        lines.setPreferredSize(new Dimension(50, 0));
        lines.setFont(new Font(font, Font.PLAIN, size));
        lines.setFocusable(false);
        lines.setDocument(editor.getDocument());

        internalPanel.add(BorderLayout.WEST, lines);
    }

    JScrollPane scroll = new JScrollPane(internalPanel);
    scroll.getVerticalScrollBar().setUnitIncrement(10);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE);

    add(BorderLayout.CENTER, scroll);

    editor.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                WorkspaceManager.getPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }

        public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                WorkspaceManager.getPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });

    undo = new UndoManager();

    undoableListener = new UndoableEditListener() {
        public void undoableEditHappened(UndoableEditEvent evt) {
            undo.addEdit(evt.getEdit());

            MessageManager.sendMessage(new BufferMessage(evt.getSource(), BufferMessage.UNDOABLE_EDIT_EVENT));

            if (!modifiedState) {
                setModifiedState(true);
            }
        }
    };

    editor.getDocument().addUndoableEditListener(undoableListener);

    MessageManager.addMessageListener(MessageManager.PREFERENCE_GROUP_NAME, this);

    fileName = DEFAULT_FILE_NAME;
}

From source file:tk.tomby.tedit.plugins.explorer.Explorer.java

/**
 * Creates a new Explorer object./*ww  w. j  av a 2 s  .  co m*/
 */
public Explorer() {
    super("Explorer");

    File rootDir = new File(PreferenceManager.getString("explorer.directory", System.getProperty("user.home")));

    JPanel internalPanel = new JPanel();
    internalPanel.setLayout(new BorderLayout());

    topPanel = new TopPanel(rootDir.getAbsolutePath());
    topPanel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            JComboBox combo = (JComboBox) evt.getSource();
            TaskManager.execute(new ReadDirectoryWorker(combo));
        }
    });

    internalPanel.add(BorderLayout.NORTH, topPanel);

    DefaultMutableTreeNode directoryRoot = new DefaultMutableTreeNode(rootDir);

    directoryTreeModel = new ShortedTreeModel(directoryRoot, new ToStringComparator());
    directoryTree = new JTree(directoryTreeModel);
    directoryTree.setCellRenderer(new DirectoryCellRenderer());
    directoryTree.setRootVisible(true);
    directoryTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    directoryTree.setEnabled(true);
    directoryTree.setEditable(false);
    directoryTree.setShowsRootHandles(true);
    directoryTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getPath();
            TreePath leadPath = evt.getNewLeadSelectionPath();

            if ((path != null) && (leadPath != null)) {
                TaskManager.execute(new RefreshWorker(leadPath, false));
            }
        }
    });
    directoryTree.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) directoryTree
                        .getLastSelectedPathComponent();

                if (!node.isRoot()) {
                    File dir = (File) node.getUserObject();

                    topPanel.setDirectory(dir.getAbsolutePath());
                }
            }
        }
    });

    JScrollPane directoryScroll = new JScrollPane(directoryTree);
    directoryScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    directoryScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    directoryScroll.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE);

    fileListModel = new ShortedListModel(new ToStringComparator());
    fileList = new JList(fileListModel);
    fileList.setDragEnabled(true);
    fileList.setCellRenderer(new FileCellRenderer());
    fileList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                final int index = fileList.locationToIndex(evt.getPoint());

                TaskManager.execute(new Runnable() {
                    public void run() {
                        File file = (File) fileListModel.getElementAt(index);

                        if (log.isDebugEnabled()) {
                            log.debug(file);
                        }

                        IBuffer buffer = new BufferFactory().createBuffer();
                        buffer.open(file);

                        WorkspaceManager.addBuffer(buffer);
                    }
                });
            }
        }
    });

    JScrollPane filesScroll = new JScrollPane(fileList);
    filesScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    filesScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    filesScroll.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE);

    splitPane = new StrippedSplitPane(JSplitPane.VERTICAL_SPLIT, directoryScroll, filesScroll);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOneTouchExpandable(false);
    splitPane.setDividerSize(5);
    splitPane.setDividerLocation(PreferenceManager.getInt("explorer.divider", 0));

    List<MutableTreeNode> dirs = openDirectory(rootDir);
    directoryTreeModel.insertAllInto(dirs, directoryRoot);

    List<File> files = getFiles(rootDir);
    fileListModel.addAll(files);

    directoryTree.expandRow(0);

    internalPanel.add(splitPane, BorderLayout.CENTER);

    setContent(internalPanel);
}

From source file:utybo.branchingstorytree.swing.editor.StoryNodesEditor.java

public StoryNodesEditor() {
    setLayout(new MigLayout("", "[:33%:300px][grow 150]", "[grow][]"));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    add(scrollPane, "cell 0 0,grow");

    jlist = new JList<>();
    jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jlist.setCellRenderer(new SubstanceDefaultListCellRenderer() {

        @Override/*from   w  ww  . j  av  a 2 s  .  c o m*/
        public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object o,
                int index, boolean isSelected, boolean cellHasFocus) {
            JLabel label = (JLabel) super.getListCellRendererComponent(list, o, index, isSelected,
                    cellHasFocus);

            if (o instanceof StorySingleNodeEditor) {
                if (((StorySingleNodeEditor) o).getStatus() == Status.ERROR)
                    label.setForeground(Color.RED.darker());
                if (o instanceof StoryLogicalNodeEditor)
                    label.setIcon(new ImageIcon(Icons.getImage("LogicalNode", 16)));
                else if (o instanceof StoryTextNodeEditor)
                    label.setIcon(new ImageIcon(Icons.getImage("TextNode", 16)));
                else if (o instanceof StoryVirtualNodeEditor)
                    label.setIcon(new ImageIcon(Icons.getImage("VirtualNode", 16)));
            }

            return label;
        }

    });
    jlist.addListSelectionListener(e -> {
        if (jlist.getSelectedValue() instanceof JComponent) {
            container.removeAll();
            container.add(jlist.getSelectedValue());
            container.revalidate();
            container.repaint();
        }
    });

    JScrollablePanel pan = new JScrollablePanel(new BorderLayout(0, 0));
    jlist.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            scrollPane.revalidate();
            pan.revalidate();
            jlist.revalidate();

            revalidate();
            repaint();
        }

    });
    pan.setScrollableWidth(ScrollableSizeHint.FIT);
    pan.setScrollableHeight(ScrollableSizeHint.STRETCH);
    pan.add(jlist, BorderLayout.CENTER);
    scrollPane.setViewportView(pan);

    container = new JPanel();
    add(container, "cell 1 0,grow");
    container.setLayout(new BorderLayout(0, 0));

    container.add(new JPanel(), BorderLayout.CENTER); // TODO

    JPanel panel = new JPanel();
    add(panel, "cell 0 1 2 1,alignx leading,growy");

    JButton btnAddNode = new JButton(Lang.get("editor.panel.add"),
            new ImageIcon(Icons.getImage("Add Subnode", 16)));
    btnAddNode.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            createMenu().show(btnAddNode, e.getX(), e.getY());
        }
    });
    panel.add(btnAddNode);

    JButton btnRemoveNode = new JButton(Lang.get("editor.panel.remove"),
            new ImageIcon(Icons.getImage("Delete Subnode", 16)));
    btnRemoveNode.addActionListener(e -> removeNode());
    panel.add(btnRemoveNode);

}

From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java

private JMenu createShortMenu() {
    JMenu shortMenu = new JMenu();
    addDarkModeCallback(b -> {//from  ww  w .  j a v a 2  s  .  c om
        shortMenu.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE.brighter());
        shortMenu.setForeground(b ? Color.WHITE : OPENBST_BLUE);
    });
    shortMenu.setBackground(OPENBST_BLUE.brighter());
    shortMenu.setForeground(OPENBST_BLUE);
    shortMenu.setText(Lang.get("banner.title"));
    shortMenu.setIcon(new ImageIcon(Icons.getImage("Logo", 16)));
    JMenuItem label = new JMenuItem(Lang.get("menu.title"));
    label.setEnabled(false);
    shortMenu.add(label);
    shortMenu.addSeparator();
    shortMenu.add(
            new JMenuItem(new AbstractAction(Lang.get("menu.open"), new ImageIcon(Icons.getImage("Open", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    openStory(VisualsUtils.askForFile(OpenBSTGUI.this, Lang.get("file.title")));
                }
            }));

    shortMenu.addSeparator();

    shortMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.create"), new ImageIcon(Icons.getImage("Add Property", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    doNewEditor();
                }
            }));

    JMenu additionalMenu = new JMenu(Lang.get("menu.advanced"));
    shortMenu.add(additionalMenu);

    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.package"), new ImageIcon(Icons.getImage("Open Archive", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    new PackageDialog(instance).setVisible(true);
                }
            }));
    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("langcheck"), new ImageIcon(Icons.getImage("LangCheck", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    final Map<String, String> languages = new Gson()
                            .fromJson(new InputStreamReader(
                                    OpenBST.class.getResourceAsStream(
                                            "/utybo/branchingstorytree/swing/lang/langs.json"),
                                    StandardCharsets.UTF_8), new TypeToken<Map<String, String>>() {
                                    }.getType());
                    languages.remove("en");
                    languages.remove("default");
                    JComboBox<String> jcb = new JComboBox<>(new Vector<>(languages.keySet()));
                    JPanel panel = new JPanel();
                    panel.add(new JLabel(Lang.get("langcheck.choose")));
                    panel.add(jcb);
                    int result = JOptionPane.showOptionDialog(OpenBSTGUI.this, panel, Lang.get("langcheck"),
                            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
                    if (result == JOptionPane.OK_OPTION) {
                        Locale selected = new Locale((String) jcb.getSelectedItem());
                        if (!Lang.getMap().keySet().contains(selected)) {
                            try {
                                Lang.loadTranslationsFromFile(selected,
                                        OpenBST.class
                                                .getResourceAsStream("/utybo/branchingstorytree/swing/lang/"
                                                        + languages.get(jcb.getSelectedItem().toString())));
                            } catch (UnrespectedModelException | IOException e1) {
                                LOG.warn("Failed to load translation file", e1);
                            }
                        }
                        ArrayList<String> list = new ArrayList<>();
                        Lang.getLocaleMap(Locale.ENGLISH).forEach((k, v) -> {
                            if (!Lang.getLocaleMap(selected).containsKey(k)) {
                                list.add(k + "\n");
                            }
                        });
                        StringBuilder sb = new StringBuilder();
                        Collections.sort(list);
                        list.forEach(s -> sb.append(s));
                        JDialog dialog = new JDialog(OpenBSTGUI.this, Lang.get("langcheck"));
                        dialog.getContentPane().setLayout(new MigLayout());
                        dialog.getContentPane().add(new JLabel(Lang.get("langcheck.result")),
                                "pushx, growx, wrap");
                        JTextArea area = new JTextArea();
                        area.setLineWrap(true);
                        area.setWrapStyleWord(true);
                        area.setText(sb.toString());
                        area.setEditable(false);
                        area.setBorder(BorderFactory.createLoweredBevelBorder());
                        JScrollPane jsp = new JScrollPane(area);
                        jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                        dialog.getContentPane().add(jsp, "pushx, pushy, growx, growy");
                        dialog.setSize((int) (Icons.getScale() * 300), (int) (Icons.getScale() * 300));
                        dialog.setLocationRelativeTo(OpenBSTGUI.this);
                        dialog.setModalityType(ModalityType.APPLICATION_MODAL);
                        dialog.setVisible(true);
                    }
                }
            }));

    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.debug"), new ImageIcon(Icons.getImage("Code", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    DebugInfo.launch(OpenBSTGUI.this);
                }
            }));

    JMenu includedFiles = new JMenu("Included BST files");

    for (Entry<String, String> entry : OpenBST.getInternalFiles().entrySet()) {
        JMenuItem jmi = new JMenuItem(entry.getKey());
        jmi.addActionListener(ev -> {
            String path = "/bst/" + entry.getValue();
            InputStream is = OpenBSTGUI.class.getResourceAsStream(path);
            ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(OpenBSTGUI.this, "Extracting...",
                    is);
            new Thread(() -> {
                try {
                    File f = File.createTempFile("openbstinternal", ".bsp");
                    FileOutputStream fos = new FileOutputStream(f);
                    IOUtils.copy(pmis, fos);
                    openStory(f);
                } catch (final IOException e) {
                    LOG.error("IOException caught", e);
                    showException(Lang.get("file.error").replace("$e", e.getClass().getSimpleName())
                            .replace("$m", e.getMessage()), e);
                }

            }).start();

        });
        includedFiles.add(jmi);
    }
    additionalMenu.add(includedFiles);

    shortMenu.addSeparator();

    JMenu themesMenu = new JMenu(Lang.get("menu.themes"));
    shortMenu.add(themesMenu);
    themesMenu.setIcon(new ImageIcon(Icons.getImage("Color Wheel", 16)));
    ButtonGroup themesGroup = new ButtonGroup();
    JRadioButtonMenuItem jrbmi;

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.dark"));
    if (0 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(0, DARK_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.light"));
    if (1 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(1, LIGHT_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.debug"));
    if (2 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(2, DEBUG_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    JMenu additionalLightThemesMenu = new JMenu(Lang.get("menu.themes.morelight"));
    int j = 3;
    for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_LIGHT_THEMES.entrySet()) {
        int jf = j;
        jrbmi = new JRadioButtonMenuItem(entry.getKey());
        if (j == selectedTheme)
            jrbmi.setSelected(true);
        jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue()));
        additionalLightThemesMenu.add(jrbmi);
        themesGroup.add(jrbmi);
        j++;
    }
    themesMenu.add(additionalLightThemesMenu);

    JMenu additionalDarkThemesMenu = new JMenu(Lang.get("menu.themes.moredark"));
    for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_DARK_THEMES.entrySet()) {
        int jf = j;
        jrbmi = new JRadioButtonMenuItem(entry.getKey());
        if (j == selectedTheme)
            jrbmi.setSelected(true);
        jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue()));
        additionalDarkThemesMenu.add(jrbmi);
        themesGroup.add(jrbmi);
        j++;
    }
    themesMenu.add(additionalDarkThemesMenu);

    shortMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.about"), new ImageIcon(Icons.getImage("About", 16))) {
                /**
                 *
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    new AboutDialog(instance).setVisible(true);
                }
            }));

    return shortMenu;
}