Example usage for javax.swing JTabbedPane SCROLL_TAB_LAYOUT

List of usage examples for javax.swing JTabbedPane SCROLL_TAB_LAYOUT

Introduction

In this page you can find the example usage for javax.swing JTabbedPane SCROLL_TAB_LAYOUT.

Prototype

int SCROLL_TAB_LAYOUT

To view the source code for javax.swing JTabbedPane SCROLL_TAB_LAYOUT.

Click Source Link

Document

Tab layout policy for providing a subset of available tabs when all the tabs will not fit within a single run.

Usage

From source file:org.gcaldaemon.gui.ConfigEditor.java

private ConfigEditor(MainConfig config, ProgressMonitor monitor) throws Exception {
    this.config = config;
    try {/*from w w  w  .  j  a va2s .  c  om*/

        // Init swing
        System.setProperty("sun.awt.noerasebackground", "false"); //$NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("swing.aatext", "true"); //$NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("swing.boldMetal", "false"); //$NON-NLS-1$ //$NON-NLS-2$
        Locale locale = Locale.getDefault();
        String code = null;
        try {
            code = config.getConfigProperty(Configurator.EDITOR_LANGUAGE, null);
            if (code != null) {
                locale = new Locale(code);
            }
        } catch (Exception invalidLocale) {
            log.warn(invalidLocale);
        }
        if (!Messages.setUserLocale(locale)) {
            locale = Locale.ENGLISH;
            Messages.setUserLocale(locale);
            code = null;
        }
        if (code == null) {
            config.setConfigProperty(Configurator.EDITOR_LANGUAGE, locale.getLanguage().toLowerCase());
        }
        try {
            boolean lookAndFeelChanged = false;
            String oldLaf = UIManager.getLookAndFeel().getClass().getName();
            String newLaf = config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL,
                    UIManager.getCrossPlatformLookAndFeelClassName());
            lookAndFeelChanged = !oldLaf.equals(newLaf);
            if (lookAndFeelChanged) {
                UIManager.setLookAndFeel(newLaf);
            }
            if (config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, null) == null) {
                config.setConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, newLaf);
            }
            if (lookAndFeelChanged) {
                new ConfigEditor(config, monitor);
                dispose();
                return;
            }
        } catch (Exception invalidLaf) {
            log.warn(invalidLaf);
        }

        // Window settings
        setTitle(Messages.getString("config.editor") + " - " + config.getConfigPath()); //$NON-NLS-1$ //$NON-NLS-2$
        setIconImage(TOOLKIT.getImage(ConfigEditor.class.getResource("/org/gcaldaemon/gui/icons/icon.gif"))); //$NON-NLS-1$
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        Container root = getContentPane();
        root.setLayout(new BorderLayout());
        root.add(folder, BorderLayout.CENTER);
        folder.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        folder.setTabPlacement(JTabbedPane.LEFT);
        folder.addChangeListener(this);
        status.setBorder(new BevelBorder(BevelBorder.LOWERED));
        root.add(status, BorderLayout.SOUTH);

        // Create menu items
        fileMenu = new JMenu(Messages.getString("file")); //$NON-NLS-1$
        saveMenu = new JMenuItem(Messages.getString("save"), getIcon("save")); //$NON-NLS-1$ //$NON-NLS-2$
        exitMenu = new JMenuItem(Messages.getString("exit"), getIcon("exit")); //$NON-NLS-1$ //$NON-NLS-2$
        viewMenu = new JMenu(Messages.getString("view")); //$NON-NLS-1$
        langMenu = new JMenu(Messages.getString("language")); //$NON-NLS-1$
        lafMenu = new JMenu(Messages.getString("look.and.feel")); //$NON-NLS-1$
        transMenu = new JMenuItem(Messages.getString("translate")); //$NON-NLS-1$
        logMenu = new JMenuItem(Messages.getString("log.viewer")); //$NON-NLS-1$
        helpMenu = new JMenu(Messages.getString("help")); //$NON-NLS-1$
        aboutMenu = new JMenuItem(Messages.getString("about")); //$NON-NLS-1$

        // Build menu
        setJMenuBar(menuBar);
        menuBar.add(fileMenu);
        fileMenu.add(saveMenu);
        fileMenu.addSeparator();
        fileMenu.add(exitMenu);
        menuBar.add(viewMenu);
        viewMenu.add(logMenu);
        viewMenu.addSeparator();
        viewMenu.add(langMenu);
        viewMenu.add(lafMenu);
        langMenu.add(transMenu);
        menuBar.add(helpMenu);
        helpMenu.add(aboutMenu);

        // Build language menu
        Locale[] locales = Messages.getAvailableLocales();
        String[] names = new String[locales.length];
        String temp;
        int i;
        for (i = 0; i < locales.length; i++) {
            names[i] = locales[i].getDisplayLanguage(Locale.ENGLISH);
            if (names[i] == null || names[i].length() == 0) {
                names[i] = locales[i].getLanguage().toLowerCase();
            }
            temp = locales[i].getDisplayLanguage(locale);
            if (temp != null && temp.length() > 0 && !temp.equals(names[i])) {
                names[i] = names[i] + " [" + temp + ']';
            }
        }
        Arrays.sort(names, String.CASE_INSENSITIVE_ORDER);
        if (locales.length != 0) {
            langMenu.addSeparator();
        }
        for (i = 0; i < locales.length; i++) {
            JMenuItem item = new JMenuItem(names[i]);
            item.setName('!' + names[i]);
            langMenu.add(item);
            item.addActionListener(this);
        }

        // Build look and feel menu
        LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
        LookAndFeelInfo info;
        for (i = 0; i < infos.length; i++) {
            info = infos[i];
            JMenuItem item = new JMenuItem(info.getName());
            item.addActionListener(this);
            item.setName('#' + info.getClassName());
            lafMenu.add(item);
        }

        // Action listeners
        addWindowListener(this);
        folder.addChangeListener(this);
        exitMenu.addActionListener(this);
        saveMenu.addActionListener(this);
        transMenu.addActionListener(this);
        logMenu.addActionListener(this);
        aboutMenu.addActionListener(this);

        // Add pages
        addPage("common.settings", new CommonPage(config, this)); //$NON-NLS-1$
        addPage("http.settings", new HttpPage(config, this)); //$NON-NLS-1$
        addPage("file.settings", new FilePage(config, this)); //$NON-NLS-1$
        addPage("feed.settings", new FeedPage(config, this)); //$NON-NLS-1$
        addPage("ldap.settings", new LdapPage(config, this)); //$NON-NLS-1$
        addPage("notifier.settings", new NotifierPage(config, this)); //$NON-NLS-1$
        addPage("sendmail.settings", new SendmailPage(config, this)); //$NON-NLS-1$
        addPage("mailterm.settings", new MailtermPage(config, this)); //$NON-NLS-1$

        // Set tab colors
        Iterator editors = disabledServices.iterator();
        while (editors.hasNext()) {
            setServiceEnabled((BooleanEditor) editors.next(), false);
        }
        disabledServices = null;

        // Show GUI
        setResizable(true);
        Dimension size = TOOLKIT.getScreenSize();
        int w = size.width - 50;
        int h = size.height - 70;
        w = Math.min(w, 1000);
        h = Math.min(h, 700);
        setSize(w, h);
        setLocation((size.width - w) / 2, (size.height - h) / 2);
        validate();
        if (monitor != null) {
            monitor.dispose();
        }
        setVisible(true);
        toFront();
    } catch (Exception error) {
        if (monitor != null) {
            monitor.dispose();
        }
        error(Messages.getString("error"), "Unable to start configurator: " + error, error);
    }
}

From source file:org.intermine.modelviewer.swing.ModelViewer.java

/**
 * Lays out the components within this panel and wires up the relevant
 * event listeners./*ww  w  .  ja v  a 2 s.  c  o  m*/
 */
private void init() {

    FileFilter xmlFilter = new XmlFileFilter();
    projectFileChooser = new JFileChooser();
    projectFileChooser.addChoosableFileFilter(xmlFilter);
    projectFileChooser.setAcceptAllFileFilterUsed(false);
    projectFileChooser.setFileFilter(xmlFilter);

    File lastProjectFile = MineManagerBackingStore.getInstance().getLastProjectFile();
    if (lastProjectFile != null) {
        projectFileChooser.setSelectedFile(lastProjectFile);
    }

    initButtonPanel();

    classTreeModel = new ClassTreeModel();
    classTree = new JTree(classTreeModel);
    classTree.setCellRenderer(new ClassTreeCellRenderer());
    classTree.setRootVisible(false);
    classTree.setShowsRootHandles(true);

    Box vbox = Box.createVerticalBox();
    vbox.add(new JScrollPane(classTree));
    vbox.add(buttonPanel);

    DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    classTree.setSelectionModel(selectionModel);

    classTree.addTreeSelectionListener(new ClassTreeSelectionListener());

    attributeTableModel = new AttributeTableModel();
    attributeTable = new AttributeTable(attributeTableModel);

    referenceTableModel = new ReferenceTableModel();
    referenceTable = new ReferenceTable(referenceTableModel);

    graphModel = new mxGraphModel();
    graph = new CustomisedMxGraph(graphModel);

    graphComponent = new mxGraphComponent(graph);
    graphComponent.setEscapeEnabled(true);

    JTabbedPane tableTab = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    tableTab.add(Messages.getMessage("tab.attributes"), new JScrollPane(attributeTable));
    tableTab.add(Messages.getMessage("tab.references"), new JScrollPane(referenceTable));

    JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableTab, graphComponent);

    JSplitPane mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, vbox, rightSplit);

    setOpaque(true);
    setLayout(new BorderLayout());
    add(mainSplit, BorderLayout.CENTER);

    rightSplit.setDividerLocation(150);
    mainSplit.setDividerLocation(200);

}

From source file:org.jcurl.demo.tactics.JCurlShotPlanner.java

@Override
protected void startup() {
    // set the window icon:
    {/*  w  w  w  . j  a v  a  2s  .com*/
        final Image img;
        if (true)
            img = getContext().getResourceMap().getImageIcon("Application.icon").getImage();
        else {
            final ResourceMap r = getContext().getResourceMap();
            if (true)
                try {
                    img = ImageIO.read(this.getClass()
                            .getResource("/" + r.getResourcesDir() + "/" + r.getString("Application.icon")));
                } catch (final IOException e) {
                    throw new RuntimeException("Unhandled", e);
                }
            else
                img = Toolkit.getDefaultToolkit().createImage(this.getClass()
                        .getResource("/" + r.getResourcesDir() + "/" + r.getString("Application.icon")));
        }
        getMainFrame().setIconImage(img);
        // SystemTray tray = SystemTray.getSystemTray();
    }

    // File Filter
    jcxzPat = gui.createFileFilter("fileFilterJcxz", "jcz", "jcx");
    pngPat = gui.createFileFilter("fileFilterPng", "png");
    svgPat = gui.createFileFilter("fileFilterSvg", "svgz", "svg");

    getMainFrame().setJMenuBar(createMenuBar());

    final JComponent c = new JPanel();
    c.setLayout(new BorderLayout());
    tactics.setPreferredSize(new Dimension(400, 600));
    c.add(tactics, BorderLayout.CENTER);
    c.add(url, BorderLayout.NORTH);
    {
        final JPanel b = new JPanel();
        b.setLayout(new BorderLayout());
        final JTabbedPane t = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
        t.add("Rock", broomSwing);
        t.setMnemonicAt(0, 'R');
        t.add("Ice", curlerSwing);
        t.setMnemonicAt(1, 'I');
        t.add("Collission", new JLabel("TODO: Collission settings"));
        t.setMnemonicAt(2, 'C');
        b.add(t, BorderLayout.NORTH);
        if (false)
            b.add(new JLabel("TODO: Bird's eye view"), BorderLayout.CENTER);
        else
            b.add(birdPiccolo, BorderLayout.CENTER);
        c.add(b, BorderLayout.EAST);
    }

    show(c);
    view12Foot();
}

From source file:org.kuali.test.ui.components.panels.WebTestPanel.java

@Override
protected void initComponents() {
    super.initComponents();
    tabbedPane = new JTabbedPane();
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    add(tabbedPane, BorderLayout.CENTER);
}

From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java

/**
 * the gui representation of the framework
 *///from   ww w. j  a va  2  s .co  m
public SPFMainFrame() {

    /*
     * handled by worker thread.
     */
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.setTitle("Sensor Platform Framework");

    this.menu = new JMenuBar();

    try {
        File f = new File("img/icon.png");
        InputStream in;
        if (!f.exists()) {
            in = ImageMapMarker.class.getResourceAsStream("/img/icon.png");
        } else {
            in = new FileInputStream(f);
        }

        this.setIconImage(ImageIO.read(in));
    } catch (IOException e) {
        this.log.warn(e.getMessage(), e);
    }

    /*
     * simple menu bar
     */
    JMenu file = new JMenu("File");
    JMenuItem exit = new JMenuItem("Exit");

    /*
     * shutdown the engine if closed
     */
    exit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            shutdownFrame();
        }
    });

    this.pnp = new JCheckBoxMenuItem("Plug'n'Play mode");
    this.pnp.setSelected(false);

    /*
     * switch the pnp mode
     */
    this.pnp.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean flag = SPFMainFrame.this.pnp.isSelected();

            if (flag && !SPFMainFrame.this.dontShow) {
                JCheckBox checkbox = new JCheckBox("Do not show this message again.");
                String message = "During Plug'n'Play mode the output generation is blocked.";
                Object[] params = { message, checkbox };
                JOptionPane.showMessageDialog(SPFMainFrame.this, params);
                SPFMainFrame.this.dontShow = checkbox.isSelected();
            }

            /*
             * check if we need to restart the output plugins
             */
            if (!flag && SPFMainFrame.this.inputChanged) {
                SPFRegistry.getInstance().restartOutputPlugins();
            }

            SPFRegistry.getInstance().setPNPMode(flag);
        }
    });

    JMenuItem restart = new JMenuItem("Restart");
    restart.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            shutdownFrame(RESTART_CODE);
        }
    });

    JMenuItem managePlugins = new JMenuItem("Manage available Plugins");
    managePlugins.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PluginRegistrationDialog prd = new PluginRegistrationDialog(SPFMainFrame.this);

            if (prd.isCanceled())
                return;

            updateConfigurationFile(prd.getSelectedNewPlugins(), prd.getSelectedOldPlugins());

            int ret = JOptionPane.showConfirmDialog(SPFMainFrame.this,
                    "<html><body><div>" + "Changes will have effect after restart of the application. "
                            + "</div><div>A restart is highly recommended due to memory usage."
                            + "</div><div><br />Restart now?</div></body></html>",
                    "Restart application", JOptionPane.YES_NO_OPTION);

            if (ret == 0) {
                shutdownFrame(RESTART_CODE);
            }
        }
    });
    file.add(managePlugins);

    file.add(this.pnp);
    file.add(new FixedSeparator());
    file.add(restart);
    file.add(new FixedSeparator());
    file.add(exit);
    this.menu.add(file);
    this.inputPluginMenu = new JMenu("InputPlugins");
    this.outputPluginMenu = new JMenu("OutputPlugins");
    this.menu.add(this.inputPluginMenu);
    this.menu.add(this.outputPluginMenu);

    /*
     * help
     */
    this.aboutDialog = new AboutDialog(SPFMainFrame.this);
    JMenu help = new JMenu("Help");
    JMenuItem about = new JMenuItem("About");
    about.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SPFMainFrame.this.aboutDialog.showSelf(SPFMainFrame.this);
        }
    });

    help.add(about);
    this.menu.add(help);
    this.setJMenuBar(this.menu);

    /*
     * the tabbed pane. every tab represents a input plugin
     */
    this.pane = new JTabbedPane();
    this.pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    /*
     * shutdown the engine if closed
     */
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            SPFMainFrame.this.shutdownFrame();
        }

    });

    /*
     * the framework core tab
     */
    this.corePanel = new FrameworkCorePanel();
    this.addTab(this.corePanel, "Framework Core", BLUE_IMAGE);

    /*
     * the map panel
     */
    if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.OVERVIEW_MAP_ENABLED))) {
        this.mapPanel = new MapPanel();
        this.addTab(this.mapPanel, "Overview Map", BLUE_IMAGE);
    }

    /*
     * other stuff
     */
    this.getContentPane().add(this.pane);

    JPanel statusBar = new JPanel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setPreferredSize(new Dimension(200, 25));
    JPanel statusBarWrapper = new JPanel(new BorderLayout());
    statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.WEST);
    statusBarWrapper.add(statusBar);
    statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.EAST);

    this.statusLabel = new JLabel("SPFramework startup finished.");
    statusBar.add(this.statusLabel, BorderLayout.EAST);

    this.outputLabel = new JLabel("(no output yet)");
    statusBar.add(this.outputLabel, BorderLayout.WEST);

    this.getContentPane().add(statusBarWrapper, BorderLayout.SOUTH);

    this.getContentPane().setBackground(this.pane.getBackground());

    this.setPreferredSize(new Dimension(1280, 720));
    this.pack();

    /*
     * full screen?
     */
    if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.MAXIMIZED))) {
        this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    }

    this.setLocationRelativeTo(null);
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

public ReportDesignerFrame() throws XulException {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    final ImageIcon icon = IconLoader.getInstance().getProductIcon();
    if (icon != null) {
        setIconImage(icon.getImage());/*  ww  w  .jav a 2s.  c  om*/
    }

    setTitle(Messages.getString("ReportDesignerFrame.Title"));
    addWindowListener(new WindowCloseHandler());

    viewController = new FrameViewController(this);
    context = new DefaultReportDesignerContext(viewController);
    viewController.initializeXulDesignerFrame(context);

    welcomePane = new WelcomePane(ReportDesignerFrame.this, getContext());
    fieldSelectorPaletteDialog = new FieldSelectorPaletteDialog(ReportDesignerFrame.this, getContext());

    statusBar = new StatusBar(context);

    reportEditorPane = new FancyTabbedPane();
    reportEditorPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    reportEditorPane.getModel().addChangeListener(new ReportTabActivationHandler());
    reportEditorPane.addMouseListener(new ReportTabPanePopupHandler());

    dockingPane = new GlobalPane(false);
    dockingPane.setMainComponent(reportEditorPane);

    attributeEditorPanel = new ElementPropertiesPanel();
    attributeEditorPanel.setAllowAttributeCard(true);
    attributeEditorPanel.setReportDesignerContext(context);

    treePanel = new TreeSidePanel(context, attributeEditorPanel);

    initializeToolWindows();

    paletteToolBar = createPaletteToolBar();

    final JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(context.getToolBar("main-toolbar"), BorderLayout.NORTH); // NON-NLS
    contentPane.add(dockingPane, BorderLayout.CENTER);
    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(paletteToolBar, BorderLayout.WEST);
    setContentPane(contentPane);

    setJMenuBar(createMenuBar());
    setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new DefaultDropTargetListener()));

    context.addPropertyChangeListener(ReportDesignerContext.ACTIVE_CONTEXT_PROPERTY,
            new ReportTabActivationHandler());
    context.addPropertyChangeListener(ReportDesignerContext.STATUS_TEXT_PROPERTY, new StatusTextHandler());
    context.addPropertyChangeListener(ReportDesignerContext.PAGE_PROPERTY, new PageTextHandler());
    context.addPropertyChangeListener(ReportDesignerContext.REPORT_RENDER_CONTEXT_PROPERTY,
            new ReportEditorContextHandler());

    Toolkit.getDefaultToolkit().addAWTEventListener(new DragSelectionToggleHandler(), AWTEvent.KEY_EVENT_MASK);

    if (MacOSXIntegration.MAC_OS_X) {
        try {
            final AboutAction aboutAction = new AboutAction();
            aboutAction.setReportDesignerContext(context);

            final SettingsAction settingsAction = new SettingsAction();
            settingsAction.setReportDesignerContext(context);

            final QuitAction quitAction = new QuitAction();
            quitAction.setReportDesignerContext(context);

            final OpenReportAction openReportAction = new OpenReportAction();
            openReportAction.setReportDesignerContext(context);

            MacOSXIntegration.setOpenFileAction(openReportAction);
            MacOSXIntegration.setAboutAction(aboutAction);
            MacOSXIntegration.setPreferencesAction(settingsAction);
            MacOSXIntegration.setQuitAction(quitAction);
        } catch (Throwable e) {
            DebugLog.log("Failed to activate MacOS-X integration", e); // NON-NLS
        }
    }

    visibleElementsUpdateHandler = new VisibleElementsUpdateHandler();
    WorkspaceSettings.getInstance().addSettingsListener(visibleElementsUpdateHandler);
}

From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java

/**
 * Initialize all the GUI.//from w  w w  .j  a v a2s. c om
 */
@Override
public void initializeGUI() {
    ThreadUtil.invokeNow(new Runnable() {

        @Override
        public void run() {
            _camera_label = mCore.getCameraDevice();
            if (_camera_label.length() > 0) {
                if (_combo_binning.getItemCount() > 0) {
                    _combo_binning.removeAllItems();
                }
                StrVector binSizes;
                try {
                    binSizes = mCore.getAllowedPropertyValues(_camera_label, MMCoreJ.getG_Keyword_Binning());
                } catch (Exception e1) {
                    binSizes = new StrVector();
                }
                ActionListener[] listeners = _combo_binning.getActionListeners();
                for (int i = 0; i < listeners.length; i++) {
                    _combo_binning.removeActionListener(listeners[i]);
                }
                for (int i = 0; i < binSizes.size(); i++) {
                    _combo_binning.addItem(binSizes.get(i));
                }
                _combo_binning.setMaximumRowCount((int) binSizes.size());
                if (binSizes.size() == 0L)
                    _combo_binning.setEditable(true);
                else {
                    _combo_binning.setEditable(false);
                }

                for (int i = 0; i < listeners.length; i++) {
                    _combo_binning.addActionListener(listeners[i]);
                }
                _combo_binning.setSelectedIndex(0);
            }
            try {
                _shutters = mCore.getLoadedDevicesOfType(DeviceType.ShutterDevice);
            } catch (Exception e) {
                e.printStackTrace();
            }

            if (_shutters != null) {
                String[] items = new String[(int) _shutters.size()];
                for (int i = 0; i < _shutters.size(); i++) {
                    items[i] = _shutters.get(i);
                }

                ActionListener[] listeners = _combo_shutters.getActionListeners();
                for (int i = 0; i < listeners.length; i++) {
                    _combo_shutters.removeActionListener(listeners[i]);
                }
                if (_combo_shutters.getItemCount() > 0) {
                    _combo_shutters.removeAllItems();
                }

                for (int i = 0; i < items.length; i++) {
                    _combo_shutters.addItem(items[i]);
                }

                for (int i = 0; i < listeners.length; i++)
                    _combo_shutters.addActionListener(listeners[i]);

                String activeShutter = mCore.getShutterDevice();
                if (activeShutter != null)
                    _combo_shutters.setSelectedItem(activeShutter);
                else {
                    _combo_shutters.setSelectedItem("");
                }
            }

            // ------------
            // GUI DRAW
            // -----------
            _mainPanel.removeAll();
            _panelConfig = new JPanel();
            _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS));
            _panelConfig.add(_groupPad, BorderLayout.CENTER);
            _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH);
            _panelConfig.setPreferredSize(new Dimension(300, 300));

            _panelCameraSettingsContainer = new JPanel();
            _panelCameraSettingsContainer
                    .setLayout(new BoxLayout(_panelCameraSettingsContainer, BoxLayout.Y_AXIS));
            _panelCameraSettingsContainer.add(_panel_cameraSettings);
            _panelCameraSettingsContainer.add(Box.createVerticalGlue());

            _panelAcquisitions = new JPanel();
            _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS));
            _panelAcquisitions.add(new JLabel("No acquisition running."));

            JPanel panelPainterSettingsContainer = new JPanel();
            panelPainterSettingsContainer.setLayout(new GridLayout());
            panelPainterSettingsContainer.add(_panelColorChooser);

            _tabbedPanel = new JTabbedPane();
            _tabbedPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
            _tabbedPanel.add("Configuration", _panelConfig);
            _tabbedPanel.add("Camera Settings", _panelCameraSettingsContainer);
            _tabbedPanel.add("Running Acquisitions", _panelAcquisitions);
            _tabbedPanel.add("Painter Settings", panelPainterSettingsContainer);

            final IcyLogo logo_title = new IcyLogo("Micro-Manager for Icy");
            logo_title.setPreferredSize(new Dimension(200, 80));
            _mainPanel.add(_tabbedPanel, BorderLayout.CENTER);
            _mainPanel.add(logo_title, BorderLayout.NORTH);
            _mainPanel.validate();
        }
    });
}

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

/**
 * Creates a new WorkSpace object./*  www  .j  a  v a 2 s.  c o m*/
 */
public Workspace() {
    super();

    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    MessageManager.addMessageListener(MessageManager.BUFFER_GROUP_NAME, new IMessageListener<BufferMessage>() {
        public void receiveMessage(BufferMessage message) {
            Workspace.this.receiveMessage(message);
        }
    });

    MessageManager.addMessageListener(MessageManager.PREFERENCE_GROUP_NAME,
            new IMessageListener<PreferenceMessage>() {
                public void receiveMessage(PreferenceMessage message) {
                    Workspace.this.receiveMessage(message);
                }
            });

    bufferPane = new JTabbedPane();
    bufferPane.setMinimumSize(new Dimension(600, 400));
    bufferPane.setPreferredSize(new Dimension(800, 600));
    bufferPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    bottomPort = createDockingPort(0, 80);
    rightPort = createDockingPort(80, 0);
    leftPort = createDockingPort(80, 0);

    splitPaneRight = createSplitPane(JSplitPane.HORIZONTAL_SPLIT, bufferPane, rightPort);
    splitPaneLeft = createSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPort, splitPaneRight);
    splitPaneBottom = createSplitPane(JSplitPane.VERTICAL_SPLIT, splitPaneLeft, bottomPort);

    bufferPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            MessageManager
                    .sendMessage(new WorkspaceMessage(evt.getSource(), bufferPane.getSelectedComponent()));
        }
    });

    bufferPane.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                splitPaneLeft.setDividerLocation(0.0d);
                splitPaneBottom.setDividerLocation(1.0d);
                splitPaneRight.setDividerLocation(1.0d);
            }
        }
    });

    DropTarget dropTarget = new DropTarget(bufferPane, new DropTargetAdapter() {
        public void drop(DropTargetDropEvent dtde) {
            if (log.isDebugEnabled()) {
                log.debug("drop start");
            }

            try {
                if (log.isDebugEnabled()) {
                    log.debug(dtde.getSource());
                }

                Transferable tr = dtde.getTransferable();
                DataFlavor[] flavors = tr.getTransferDataFlavors();

                for (int i = 0; i < flavors.length; i++) {
                    DataFlavor flavor = flavors[i];

                    if (log.isDebugEnabled()) {
                        log.debug("mime-type:" + flavor.getMimeType());
                    }

                    if (flavor.isMimeTypeEqual("text/plain")) {
                        final Object obj = tr.getTransferData(flavor);

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

                        if (obj instanceof String) {
                            TaskManager.execute(new Runnable() {
                                public void run() {
                                    BufferFactory factory = new BufferFactory();
                                    IBuffer buffer = factory.createBuffer();
                                    buffer.open((String) obj);

                                    addBuffer(buffer);
                                }
                            });
                        }

                        dtde.dropComplete(true);

                        return;
                    }
                }
            } catch (UnsupportedFlavorException e) {
                log.warn(e.getMessage(), e);
            } catch (IOException e) {
                log.warn(e.getMessage(), e);
            }

            dtde.rejectDrop();

            if (log.isDebugEnabled()) {
                log.debug("drop end");
            }
        }
    });

    bufferPane.setDropTarget(dropTarget);

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

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

public OpenBSTGUI() {
    instance = this;
    UIManager.put("OptionPane.errorIcon", new ImageIcon(Icons.getImage("Cancel", 48)));
    UIManager.put("OptionPane.informationIcon", new ImageIcon(Icons.getImage("About", 48)));
    UIManager.put("OptionPane.questionIcon", new ImageIcon(Icons.getImage("Rename", 48)));
    UIManager.put("OptionPane.warningIcon", new ImageIcon(Icons.getImage("Error", 48)));

    BorderLayout borderLayout = new BorderLayout();
    borderLayout.setVgap(4);// ww  w .j  a  v  a 2 s. c o m
    getContentPane().setLayout(borderLayout);
    setIconImage(Icons.getImage("Logo", 48));
    setTitle("OpenBST " + OpenBST.VERSION);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            boolean cancelled = false;
            int i = 0;
            for (Component c : container.getComponents()) {
                if (c instanceof StoryPanel) {
                    i++;
                } else if (c instanceof StoryEditor) {
                    container.setSelectedComponent(c);
                    if (((StoryEditor) c).askClose()) {
                        continue;
                    } else {
                        cancelled = true;
                        break;
                    }
                }
            }
            if (!cancelled) {
                if (i > 0) {
                    int j = Messagers.showConfirm(OpenBSTGUI.this,
                            "You are about to close " + i + " file(s). Are you sure you wish to exit OpenBST?",
                            Messagers.OPTIONS_YES_NO, Messagers.TYPE_WARNING, "Closing OpenBST");
                    if (j != Messagers.OPTION_YES)
                        cancelled = true;
                }
                if (!cancelled)
                    System.exit(0);
            }
        }

    });

    JMenuBar jmb = new JMenuBar();
    jmb.setBackground(OPENBST_BLUE);
    jmb.add(Box.createHorizontalGlue());
    jmb.add(createShortMenu());
    jmb.add(Box.createHorizontalGlue());
    this.setJMenuBar(jmb);

    addDarkModeCallback(b -> {
        jmb.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE);
    });

    container = new JTabbedPane();
    container.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    container.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e)) {
                final int i = container.indexAtLocation(e.getX(), e.getY());
                System.out.println(i);
                if (i > -1) {
                    Component c = container.getComponentAt(i);
                    if (c instanceof StoryPanel) {
                        container.setSelectedComponent(c);
                        ((StoryPanel) c).askClose();
                    } else if (c instanceof StoryEditor) {
                        container.setSelectedComponent(c);
                        ((StoryEditor) c).askClose();
                    }
                }
            }
        }
    });
    getContentPane().add(container, BorderLayout.CENTER);

    final JBackgroundPanel welcomeContentPanel = new JBackgroundPanel(Icons.getRandomBackground(),
            Image.SCALE_FAST);
    background = welcomeContentPanel;

    welcomeContentPanel.setLayout(new MigLayout("hidemode 2", "[grow,center]", "[][grow][]"));
    container.add(welcomeContentPanel);
    container.setTitleAt(0, Lang.get("welcome"));

    bannersPanel = new JPanel(new MigLayout("hidemode 2, gap 0px, fill, wrap 1, ins 0"));
    bannersPanel.setBackground(new Color(0, 0, 0, 0));
    welcomeContentPanel.add(bannersPanel, "cell 0 0,grow");

    if (OpenBST.VERSION.endsWith("u")) {
        JButton btnReportBugs = new JButton(Lang.get("welcome.reportbugs"));
        btnReportBugs.addActionListener(e -> {
            VisualsUtils.browse("https://github.com/utybo/BST/issues");
        });
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.YELLOW,
                Lang.get("welcome.ontheedge"), btnReportBugs, false), "grow");
    } else if (OpenBST.VERSION.contains("SNAPSHOT")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.ORANGE,
                Lang.get("welcome.snapshot"), null, false), "grow");
    }

    if (System.getProperty("java.specification.version").equals("9")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)),
                new Color(255, 50, 50), Lang.get("welcome.java9warning"), null, false), "grow");
    }
    if (System.getProperty("java.specification.version").equals("10")) {
        bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)),
                new Color(255, 50, 50), Lang.get("welcome.java10warning"), null, false), "grow");
    }

    JButton btnJoinDiscord = new JButton(Lang.get("openbst.discordjoin"));
    btnJoinDiscord.addActionListener(e -> {
        VisualsUtils.browse("https://discord.gg/6SVDCMM");
    });
    bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Discord", 48)), DISCORD_COLOR,
            Lang.get("openbst.discord"), btnJoinDiscord, true), "grow");

    JPanel panel = new JPanel();
    panel.setBackground(new Color(0, 0, 0, 0));
    welcomeContentPanel.add(panel, "flowx,cell 0 1,growx,aligny center");
    panel.setLayout(new MigLayout("", "[40%][][][][60%,growprio 50]", "[][grow]"));

    final JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogo", 48)));
    addDarkModeCallback(b -> lblOpenbst
            .setIcon(new ImageIcon(b ? Icons.getImage("FullLogoWhite", 48) : Icons.getImage("FullLogo", 48))));
    panel.add(lblOpenbst, "flowx,cell 0 0 1 2,alignx trailing,aligny center");

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    panel.add(separator, "cell 2 0 1 2,growy");

    final JLabel lblWelcomeToOpenbst = new JLabel("<html>" + Lang.get("welcome.intro"));
    lblWelcomeToOpenbst.setMaximumSize(new Dimension(350, 999999));
    panel.add(lblWelcomeToOpenbst, "cell 4 0");

    Component horizontalStrut = Box.createHorizontalStrut(10);
    panel.add(horizontalStrut, "cell 1 1");

    Component horizontalStrut_1 = Box.createHorizontalStrut(10);
    panel.add(horizontalStrut_1, "cell 3 1");

    final JButton btnOpenAFile = new JButton(Lang.get("welcome.open"));
    panel.add(btnOpenAFile, "flowx,cell 4 1");
    btnOpenAFile.setIcon(new ImageIcon(Icons.getImage("Open", 40)));
    btnOpenAFile.addActionListener(e -> {
        openStory(VisualsUtils.askForFile(this, Lang.get("file.title")));
    });

    final JButton btnOpenEditor = new JButton(Lang.get("welcome.openeditor"));
    panel.add(btnOpenEditor, "cell 4 1");
    btnOpenEditor.setIcon(new ImageIcon(Icons.getImage("Edit Property", 40)));
    btnOpenEditor.addActionListener(e -> {
        openEditor(VisualsUtils.askForFile(this, Lang.get("file.title")));
    });

    JButton btnChangeBackground = new JButton(Lang.get("welcome.changebackground"),
            new ImageIcon(Icons.getImage("Change Theme", 16)));
    btnChangeBackground.addActionListener(e -> {
        BufferedImage prev = background.getImage();
        BufferedImage next;
        do {
            next = Icons.getRandomBackground();
        } while (prev == next);
        background.setImage(next);
    });
    welcomeContentPanel.add(btnChangeBackground, "flowx,cell 0 2,alignx left");

    JButton btnWelcomepixabay = new JButton(Lang.get("welcome.pixabay"),
            new ImageIcon(Icons.getImage("External Link", 16)));
    btnWelcomepixabay.addActionListener(e -> {
        VisualsUtils.browse("https://pixabay.com");

    });
    welcomeContentPanel.add(btnWelcomepixabay, "cell 0 2");

    JLabel creds = new JLabel(Lang.get("welcome.credits"));
    creds.setEnabled(false);
    welcomeContentPanel.add(creds, "cell 0 2, gapbefore 10px");

    setSize((int) (830 * Icons.getScale()), (int) (480 * Icons.getScale()));
    setLocationRelativeTo(null);
}