Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

In this page you can find the example usage for javax.swing JLabel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.java

private JPanel createServerStatus() {
    JPanel serverStatusPanel = new JPanel(new GridBagLayout());

    JLabel serverStatusLabel = new JLabel("Local update: ");
    updateServerButton = new JButton();
    serverStatus = new JLabel();

    final HyperlinkLabel link = new HyperlinkLabel("");
    link.setIcon(AllIcons.General.Help_small);
    link.setUseIconAsLink(true);/*from   ww  w.  j  a  va 2 s.  c  o m*/
    link.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final JLabel label = new JLabel(
                    "<html>Click to fetch data from the selected SonarQube server, such as the list of projects,<br>"
                            + " rules, quality profiles, etc. This needs to be done before being able to select a project.");
            label.setBorder(HintUtil.createHintBorder());
            label.setBackground(HintUtil.INFORMATION_COLOR);
            label.setOpaque(true);
            HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link),
                    HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
        }
    });

    JPanel flow1 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    flow1.add(serverStatusLabel);
    flow1.add(serverStatus);

    JPanel flow2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    flow2.add(updateServerButton);
    flow2.add(link);

    serverStatusPanel.add(flow1, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0,
            new Insets(0, 0, 0, 0), 0, 0));
    serverStatusPanel.add(flow2, new GridBagConstraints(1, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0,
            new Insets(0, 0, 0, 0), 0, 0));

    updateServerButton.setAction(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            actionUpdateServerTask(false);
        }
    });
    updateServerButton.setText("Update binding");
    updateServerButton.setToolTipText("Update local data: quality profile, settings, ...");

    JPanel alignedPanel = new JPanel(new BorderLayout());
    alignedPanel.add(serverStatusPanel, BorderLayout.NORTH);
    return alignedPanel;
}

From source file:org.springframework.richclient.application.statusbar.support.DefaultStatusBar.java

/**
 * Create the <code>JLabel</code> used to render the messages.
 * <p>/*from  w  w  w . j a va 2 s .  com*/
 * Can safely be overridden to customize the label
 *
 * @return the <code>JLabel</code>
 */
protected JLabel createMessageLabel() {
    JLabel messageLabel = new JLabel(" ");
    messageLabel.setName("message");
    Border bevelBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED,
            UIManager.getColor("controlHighlight"), UIManager.getColor("controlShadow"));
    Border emptyBorder = BorderFactory.createEmptyBorder(1, 3, 1, 3);
    messageLabel.setBorder(BorderFactory.createCompoundBorder(bevelBorder, emptyBorder));

    return messageLabel;
}

From source file:org.stanwood.swing.AboutDialog.java

private JComponent createAuthorsTab() {
    JScrollPane scroll = new JScrollPane();
    scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    Box box = Box.createVerticalBox();
    box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    for (Author author : authors) {
        box.add(new JLabel(author.getName()));
        JXHyperlink link = new JXHyperlink(
                new LinkAction(this, author.getEmail(), "mailto:" + author.getEmail()));
        box.add(link);/*  w w  w  . ja  va 2 s .  c om*/
        link.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
        JLabel lblDescription = new JLabel(author.getDescription());
        lblDescription.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
        box.add(lblDescription);
    }

    scroll.getViewport().add(box);
    return scroll;
}

From source file:org.ut.biolab.medsavant.client.project.ProjectSummaryPage.java

@Override
public JPanel getView() {
    JPanel view = new JPanel();

    ViewUtil.applyVerticalBoxLayout(view);
    //view.setLayout(new GridBagLayout());

    JLabel title = new JLabel(ProjectController.getInstance().getCurrentProjectName() + " Project");
    title.setBorder(ViewUtil.getBigBorder());
    title.setOpaque(false);//  w ww .j  a va 2  s  .  c om
    title.setFont(ViewUtil.getMediumTitleFont());

    CollapsiblePanes panes = new CollapsiblePanes();

    panes.add(createPatientSummary());
    panes.add(createVariantSummary());
    panes.add(createReferenceSummary());

    panes.addExpansion();

    view.add(title);
    view.add(panes);

    return view;
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

private void initGui(final String initialPath) {
    this.setLayout(new BorderLayout());
    JLabel pathLabel = new JLabel(Messages.getMessage("browser.location"));
    pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
    pathField = new JTextField(80);
    pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f));
    pathField.setToolTipText(Messages.getMessage("nav.pathTooltip"));
    GuiUtils.addBlinkOnFocusGain(pathField);
    pathLabel.setLabelFor(pathField);//  w  w  w  .j  av  a 2  s . c o m
    pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0));

    InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED);
    inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH");
    inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE);
    pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) {

        @Override
        protected void performLongOperation(CheckBeforeActionResult actionResult) {
            try {
                FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim());
                if (resolveFile != null && resolveFile.getType() == FileType.FILE) {
                    loadAndSelSingleFile(resolveFile);
                    pathField.setText(resolveFile.getURL().toString());
                    actionApproveDelegate.actionPerformed(
                            // TODO:  Does actionResult provide an ID for 2nd param here,
                            // or should use a Random number?
                            new ActionEvent(actionResult, (int) new java.util.Date().getTime(),
                                    "SELECTED_FILE"));
                    return;
                }
            } catch (FileSystemException fse) {
                // Intentionally empty
            }
            goToUrl(pathField.getText().trim());
        }

        @Override
        protected boolean canGoUrl() {
            return true;
        }

        @Override
        protected boolean canExecuteDefaultAction() {
            return false;
        }

    });
    actionFocusOnTable = new

    AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            tableFiles.requestFocusInWindow();
            if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) {
                tableFiles.getSelectionModel().setSelectionInterval(0, 0);
            }
        }
    };
    pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable);

    BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this);
    goUpButton = new JButton(goUpAction);

    BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this);
    JButton refreshButton = new JButton(refreshAction);

    JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName"));
    upperPanel.setRollover(true);
    upperPanel.add(pathLabel);
    upperPanel.add(pathField, "growx");
    upperPanel.add(goUpButton);
    upperPanel.add(refreshButton);

    AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction(
            this);
    JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction);
    addCurrentLocationToFavoriteButton.setText("");
    upperPanel.add(addCurrentLocationToFavoriteButton);

    previewComponent = new PreviewComponent();

    vfsTableModel = new VfsTableModel();

    tableFiles = new JTable(vfsTableModel);
    tableFiles.setFillsViewportHeight(true);
    tableFiles.getColumnModel().getColumn(0).setMinWidth(140);
    tableFiles.getColumnModel().getColumn(1).setMaxWidth(80);
    tableFiles.getColumnModel().getColumn(2).setMaxWidth(80);
    tableFiles.getColumnModel().getColumn(3).setMaxWidth(180);
    tableFiles.getColumnModel().getColumn(3).setMinWidth(120);

    sorter = new TableRowSorter<VfsTableModel>(vfsTableModel);
    final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator();
    sorter.addRowSorterListener(new RowSorterListener() {
        @Override
        public void sorterChanged(RowSorterEvent e) {
            RowSorterEvent.Type type = e.getType();
            if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) {
                List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys();
                for (RowSorter.SortKey sortKey : sortKeys) {
                    if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) {
                        fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder());
                    }
                }
            }
        }
    });
    sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator);

    tableFiles.setRowSorter(sorter);
    tableFiles.setShowGrid(false);
    tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            try {
                selectionChanged();
            } catch (FileSystemException e1) {
                LOGGER.error("Error during update state", e);
            }
        }
    });
    tableFiles.setColumnSelectionAllowed(false);
    vfsTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateStatusText();
        }
    });

    tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer());
    tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer());
    tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer());
    tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer());

    tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent));

    JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]"));
    favoritesUserListModel = new MutableListModel<Favorite>();

    List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations();
    List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration);
    List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks();
    for (Favorite favorite : favUser) {
        favoritesUserListModel.add(favorite);
    }
    favoritesUserListModel.addListDataListener(new ListDataListener() {
        @Override
        public void intervalAdded(ListDataEvent e) {
            saveFavorites();

        }

        @Override
        public void intervalRemoved(ListDataEvent e) {
            saveFavorites();
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
            saveFavorites();
        }

        protected void saveFavorites() {
            FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList());
        }
    });

    favoritesUserList = new JList(favoritesUserListModel);
    favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList));
    new MutableListDragListener(favoritesUserList);
    favoritesUserList.setCellRenderer(new FavoriteListCellRenderer());
    favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter());

    addOpenActionToList(favoritesUserList);
    addEditActionToList(favoritesUserList, favoritesUserListModel);

    favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction(
            Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) {

        @Override
        public void actionPerformed(ActionEvent e) {
            Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex());
            if (!Favorite.Type.USER.equals(favorite.getType())) {
                return;
            }
            int response = JOptionPane.showConfirmDialog(VfsBrowser.this,
                    Messages.getMessage("favorites.areYouSureToDeleteConnections"),
                    Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION);

            if (response == JOptionPane.YES_OPTION) {
                favoritesUserListModel.remove(favoritesUserList.getSelectedIndex());
            }
        }
    });
    InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED);
    favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE);

    ActionMap actionMap = tableFiles.getActionMap();
    actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this));
    actionMap.put(ACTION_GO_UP, goUpAction);
    actionMap.put(ACTION_APPROVE, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (actionApproveButton.isEnabled()) {
                actionApproveDelegate.actionPerformed(e);
            }
        }
    });

    InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED);
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE);

    inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP);
    addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE);

    JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations));
    favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer());
    addOpenActionToList(favoriteSystemList);
    addPopupMenu(favoriteSystemList, ACTION_OPEN);
    favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter());

    JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser));
    addOpenActionToList(favoriteJVfsList);
    favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer());
    addPopupMenu(favoriteJVfsList, ACTION_OPEN);
    favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter());

    JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"),
            COMPUTER_ICON);
    favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList);
    favoritesSystemLocationsLabel
            .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0));
    favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16");
    favoritesPanel.add(favoriteSystemList, "growx");
    JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"),
            Icons.getInstance().getStar());
    favoritesFavoritesLabel.setLabelFor(favoritesUserList);
    favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0));
    favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16");
    favoritesPanel.add(favoritesUserList, "growx");

    if (favoriteJVfsList.getModel().getSize() > 0) {
        JLabel favoritesJVfsFileChooser = getTitleListLabel(
                Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null);
        favoritesJVfsFileChooser.setDisplayedMnemonic(
                Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0));
        favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList);
        favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16");
        favoritesPanel.add(favoriteJVfsList, "growx");
    }

    tableFiles.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null);
            }
        }
    });
    tableFiles.addKeyListener(new QuickSearchKeyAdapter());

    cardLayout = new CardLayout();
    tablePanel = new JPanel(cardLayout);
    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString(Messages.getMessage("browser.loading"));
    loadingProgressBar.setIndeterminate(true);
    loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline());
    skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks"));
    skipCheckingLinksButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (taskContext != null) {
                taskContext.setStop(skipCheckingLinksButton.isSelected());
            }
        }
    });

    showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden);
    showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip"));
    showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0));
    Font tmpFont = showHidCheckBox.getFont();
    showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f));
    showHidCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUiFilters();
        }
    });

    final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText");
    filterField = new JTextField("", 16);
    filterField.setForeground(filterField.getDisabledTextColor());
    filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip"));
    PromptSupport.setPrompt(defaultFilterText, filterField);
    filterField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            documentChanged();
        }

        void documentChanged() {
            if (filterField.getText().length() == 0) {
                updateUiFilters();
            }
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            documentChanged();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            documentChanged();
        }
    });
    filterField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            updateUiFilters();
        }
    });

    AbstractAction actionClearRegexFilter = new

    AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            filterField.setText("");
        }
    };
    filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable);
    filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter);

    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
            ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            ACTION_CLEAR_REGEX_FILTER);

    JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter"));
    nameFilterLabel.setLabelFor(filterField);
    nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0));

    sorter.setRowFilter(createFilter());
    statusLabel = new JLabel();

    actionApproveButton = new JButton();
    actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD));
    actionCancelButton = new JButton();

    ActionMap browserActionMap = this.getActionMap();
    browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            filterField.requestFocus();
            filterField.selectAll();
            GuiUtils.blinkComponent(filterField);
        }
    });

    browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField));
    browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox));
    browserActionMap.put(ACTION_REFRESH, refreshAction);
    browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction);
    browserActionMap.put(ACTION_GO_UP, goUpAction);
    browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles));

    InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER);
    browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH);
    browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH);
    browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN);
    browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH);
    browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH);
    browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES);
    browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP);
    browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE);

    //DO layout
    // create the layer for the panel using our custom layerUI
    tableScrollPane = new JScrollPane(tableFiles);

    JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout());
    tableScrollPaneWithFilter.add(tableScrollPane);
    JToolBar filtersToolbar = new JToolBar("Filters");
    filtersToolbar.setFloatable(false);
    filtersToolbar.setBorderPainted(true);
    tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH);
    filtersToolbar.add(nameFilterLabel);
    filtersToolbar.add(filterField);
    filtersToolbar.add(showHidCheckBox);
    JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
            tableScrollPaneWithFilter, previewComponent);
    tableWithPreviewPane.setOneTouchExpandable(true);

    JPanel loadingPanel = new JPanel(new MigLayout());
    loadingPanel.add(loadingIconLabel, "right");
    loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap");
    loadingPanel.add(skipCheckingLinksButton, "span, right");
    tablePanel.add(loadingPanel, LOADING);
    tablePanel.add(tableWithPreviewPane, TABLE);

    JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel),
            tablePanel);
    jSplitPane.setOneTouchExpandable(true);
    jSplitPane.setDividerLocation(180);

    JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", ""));
    southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    southPanel.add(statusLabel);
    southPanel.add(actionApproveButton);
    southPanel.add(actionCancelButton);

    this.add(upperPanel, BorderLayout.NORTH);
    this.add(jSplitPane, BorderLayout.CENTER);
    this.add(southPanel, BorderLayout.SOUTH);

    try {
        selectionChanged();
    } catch (FileSystemException e) {
        LOGGER.error("Can't initialize default selection mode", e);
    }
    // Why this not done in EDT?
    // Is it assume that constructor is invoked from an  EDT?
    try {
        if (initialPath == null) {
            goToUrl(VFSUtils.getUserHome());
        } else {
            try {
                FileObject resolveFile = VFSUtils.resolveFileObject(initialPath);
                if (resolveFile != null && resolveFile.getType() == FileType.FILE) {
                    loadAndSelSingleFile(resolveFile);
                    pathField.setText(resolveFile.getURL().toString());
                    targetFileSelected = true;
                    return;
                }
            } catch (FileSystemException fse) {
                // Intentionally empty
            }
            goToUrl(initialPath);
        }
    } catch (FileSystemException e1) {
        LOGGER.error("Can't initialize default location", e1);
    }
    showTable();
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

private JLabel getTitleListLabel(String text, Icon icon) {
    JLabel jLabel = new JLabel(text, icon, SwingConstants.CENTER);
    Font font = jLabel.getFont();
    jLabel.setFont(font.deriveFont(Font.ITALIC | Font.BOLD, font.getSize() * 1.1f));
    jLabel.setBorder(BorderFactory.createEmptyBorder(10, 3, 0, 3));

    return jLabel;
}

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

/**
 * Singleton pattern : private constructor Use instead.
 *///w  ww. j  av  a 2 s  .  co  m
private MMMainFrame() {
    super(NODE_NAME, false, true, false, true);
    instancing = true;
    // --------------
    // INITIALIZATION
    // --------------
    _sysConfigFile = "";
    _isConfigLoaded = false;
    _root = PluginPreferences.getPreferences().node(NODE_NAME);
    final MainFrame mainFrame = Icy.getMainInterface().getMainFrame();

    // --------------
    // PROGRESS FRAME
    // --------------
    ThreadUtil.invokeLater(new Runnable() {
        @Override
        public void run() {
            _progressFrame = new IcyFrame("", false, false, false, false);
            _progressBar = new JProgressBar();
            _progressBar.setString("Please wait while loading...");
            _progressBar.setStringPainted(true);
            _progressBar.setIndeterminate(true);
            _progressBar.setMinimum(0);
            _progressBar.setMaximum(1000);
            _progressBar.setBounds(50, 50, 100, 30);
            _progressFrame.setSize(300, 100);
            _progressFrame.setResizable(false);
            _progressFrame.add(_progressBar);
            _progressFrame.addToMainDesktopPane();
            loadConfig(true);
            if (_sysConfigFile == "") {
                instancing = false;
                return;
            }
            ThreadUtil.bgRun(new Runnable() {

                @Override
                public void run() {
                    while (!_isConfigLoaded) {
                        if (!instancing)
                            return;
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                        }
                    }
                    ThreadUtil.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            // --------------------
                            // START INITIALIZATION
                            // --------------------
                            if (_progressBar != null)
                                getContentPane().remove(_progressBar);
                            if (mCore == null) {
                                close();
                                return;
                            }

                            // ReportingUtils.setCore(mCore);
                            _afMgr = new AutofocusManager(MMMainFrame.this);
                            acqMgr = new AcquisitionManager();
                            PositionList posList = new PositionList();

                            _camera_label = MMCoreJ.getG_Keyword_CameraName();
                            if (_camera_label == null)
                                _camera_label = "";
                            try {
                                setPositionList(posList);
                            } catch (MMScriptException e1) {
                                e1.printStackTrace();
                            }
                            posListDlg_ = new PositionListDlg(mCore, MMMainFrame.this, _posList, null, dlg);
                            posListDlg_.setModalityType(ModalityType.APPLICATION_MODAL);

                            callback = new EventCallBackManager();
                            mCore.registerCallback(callback);

                            engine_ = new AcquisitionWrapperEngineIcy();
                            engine_.setParentGUI(MMMainFrame.this);
                            engine_.setCore(mCore, getAutofocusManager());
                            engine_.setPositionList(getPositionList());

                            setSystemMenuCallback(new MenuCallback() {

                                @Override
                                public JMenu getMenu() {
                                    JMenu toReturn = MMMainFrame.this.getDefaultSystemMenu();
                                    JMenuItem hconfig = new JMenuItem("Configuration Wizard");
                                    hconfig.setIcon(new IcyIcon("cog", MENU_ICON_SIZE));

                                    hconfig.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            if (!_pluginListEmpty && !ConfirmDialog.confirm("Are you sure ?",
                                                    "<html>Loading the Configuration Wizard will unload all the devices and pause all running acquisitions.</br> Are you sure you want to continue ?</html>"))
                                                return;
                                            notifyConfigAboutToChange(null);
                                            try {
                                                mCore.unloadAllDevices();
                                            } catch (Exception e1) {
                                                e1.printStackTrace();
                                            }
                                            String previous_config = _sysConfigFile;
                                            ConfiguratorDlg2 configurator = new ConfiguratorDlg2(mCore,
                                                    _sysConfigFile);
                                            configurator.setVisible(true);
                                            String res = configurator.getFileName();
                                            if (_sysConfigFile == "" || _sysConfigFile == res || res == "") {
                                                _sysConfigFile = previous_config;
                                                loadConfig();
                                            }
                                            refreshGUI();
                                            notifyConfigChanged(null);
                                        }
                                    });

                                    JMenuItem menuPxSizeConfigItem = new JMenuItem("Pixel Size Config");
                                    menuPxSizeConfigItem.setIcon(new IcyIcon("link", MENU_ICON_SIZE));
                                    menuPxSizeConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    menuPxSizeConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            CalibrationListDlg dlg = new CalibrationListDlg(mCore);
                                            dlg.setDefaultCloseOperation(2);
                                            dlg.setParentGUI(MMMainFrame.this);
                                            dlg.setVisible(true);
                                            dlg.addWindowListener(new WindowAdapter() {
                                                @Override
                                                public void windowClosed(WindowEvent e) {
                                                    super.windowClosed(e);
                                                    notifyConfigChanged(null);
                                                }
                                            });
                                            notifyConfigAboutToChange(null);
                                        }
                                    });

                                    JMenuItem loadConfigItem = new JMenuItem("Load Configuration");
                                    loadConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    loadConfigItem.setIcon(new IcyIcon("folder_open", MENU_ICON_SIZE));
                                    loadConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            loadConfig();
                                            initializeGUI();
                                            refreshGUI();
                                        }
                                    });
                                    JMenuItem saveConfigItem = new JMenuItem("Save Configuration");
                                    saveConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    saveConfigItem.setIcon(new IcyIcon("save", MENU_ICON_SIZE));
                                    saveConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            saveConfig();
                                        }
                                    });
                                    JMenuItem advancedConfigItem = new JMenuItem("Advanced Configuration");
                                    advancedConfigItem.setIcon(new IcyIcon("wrench_plus", MENU_ICON_SIZE));
                                    advancedConfigItem.addActionListener(new ActionListener() {

                                        /**
                                         */
                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            new ToolTipFrame(
                                                    "<html><h3>About Advanced Config</h3><p>Advanced Configuration is a tool "
                                                            + "in which you fill some data <br/>about your configuration that some "
                                                            + "plugins may need to access to.<br/> Exemple: the real values of the magnification"
                                                            + "of your objectives.</p></html>",
                                                    "MM4IcyAdvancedConfig");
                                            if (advancedDlg == null)
                                                advancedDlg = new AdvancedConfigurationDialog();
                                            advancedDlg.setVisible(!advancedDlg.isVisible());
                                            advancedDlg.setLocationRelativeTo(mainFrame);
                                        }
                                    });
                                    JMenuItem loadPresetConfigItem = new JMenuItem(
                                            "Load Configuration Presets");
                                    loadPresetConfigItem.setIcon(new IcyIcon("doc_import", MENU_ICON_SIZE));
                                    loadPresetConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            notifyConfigAboutToChange(null);
                                            loadPresets();
                                            notifyConfigChanged(null);
                                        }
                                    });
                                    JMenuItem savePresetConfigItem = new JMenuItem(
                                            "Save Configuration Presets");
                                    savePresetConfigItem.setIcon(new IcyIcon("doc_export", MENU_ICON_SIZE));
                                    savePresetConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            savePresets();
                                        }
                                    });
                                    JMenuItem aboutItem = new JMenuItem("About");
                                    aboutItem.setIcon(new IcyIcon("info", MENU_ICON_SIZE));
                                    aboutItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            final JDialog dialog = new JDialog(mainFrame, "About");
                                            JPanel panel_container = new JPanel();
                                            panel_container
                                                    .setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
                                            JPanel center = new JPanel(new BorderLayout());
                                            final JLabel value = new JLabel("<html><body>"
                                                    + "<h2>About</h2><p>Micro-Manager for Icy is being developed by Thomas Provoost."
                                                    + "<br/>Copyright 2011, Institut Pasteur</p><br/>"
                                                    + "<p>This plugin is based on Micro-Manager v1.4.6. which is developed under the following license:<br/>"
                                                    + "<i>This software is distributed free of charge in the hope that it will be<br/>"
                                                    + "useful, but WITHOUT ANY WARRANTY; without even the implied<br/>"
                                                    + "warranty of merchantability or fitness for a particular purpose. In no<br/>"
                                                    + "event shall the copyright owner or contributors be liable for any direct,<br/>"
                                                    + "indirect, incidental spacial, examplary, or consequential damages.<br/>"
                                                    + "Copyright University of California San Francisco, 2007, 2008, 2009,<br/>"
                                                    + "2010. All rights reserved.</i>" + "</p>"
                                                    + "</body></html>");
                                            JLabel link = new JLabel(
                                                    "<html><a href=\"\">For more information, please follow this link.</a></html>");
                                            link.addMouseListener(new MouseAdapter() {
                                                @Override
                                                public void mousePressed(MouseEvent mouseevent) {
                                                    NetworkUtil.openBrowser(
                                                            "http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager");
                                                }
                                            });
                                            value.setSize(new Dimension(50, 18));
                                            value.setAlignmentX(SwingConstants.HORIZONTAL);
                                            value.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0));

                                            center.add(value, BorderLayout.CENTER);
                                            center.add(link, BorderLayout.SOUTH);

                                            JPanel panel_south = new JPanel();
                                            panel_south.setLayout(new BoxLayout(panel_south, BoxLayout.X_AXIS));
                                            JButton btn = new JButton("OK");
                                            btn.addActionListener(new ActionListener() {

                                                @Override
                                                public void actionPerformed(ActionEvent actionevent) {
                                                    dialog.dispose();
                                                }
                                            });
                                            panel_south.add(Box.createHorizontalGlue());
                                            panel_south.add(btn);
                                            panel_south.add(Box.createHorizontalGlue());

                                            dialog.setLayout(new BorderLayout());
                                            panel_container.setLayout(new BorderLayout());
                                            panel_container.add(center, BorderLayout.CENTER);
                                            panel_container.add(panel_south, BorderLayout.SOUTH);
                                            dialog.add(panel_container, BorderLayout.CENTER);
                                            dialog.setResizable(false);
                                            dialog.setVisible(true);
                                            dialog.pack();
                                            dialog.setLocation(
                                                    (int) mainFrame.getSize().getWidth() / 2
                                                            - dialog.getWidth() / 2,
                                                    (int) mainFrame.getSize().getHeight() / 2
                                                            - dialog.getHeight() / 2);
                                            dialog.setLocationRelativeTo(mainFrame);
                                        }
                                    });
                                    JMenuItem propertyBrowserItem = new JMenuItem("Property Browser");
                                    propertyBrowserItem.setAccelerator(
                                            KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, SHORTCUTKEY_MASK));
                                    propertyBrowserItem.setIcon(new IcyIcon("db", MENU_ICON_SIZE));
                                    propertyBrowserItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            editor.setVisible(!editor.isVisible());
                                        }
                                    });
                                    int idx = 0;
                                    toReturn.insert(hconfig, idx++);
                                    toReturn.insert(loadConfigItem, idx++);
                                    toReturn.insert(saveConfigItem, idx++);
                                    toReturn.insert(advancedConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(loadPresetConfigItem, idx++);
                                    toReturn.insert(savePresetConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(propertyBrowserItem, idx++);
                                    toReturn.insert(menuPxSizeConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(aboutItem, idx++);
                                    return toReturn;
                                }
                            });

                            saveConfigButton_ = new JButton("Save Button");

                            // SETUP
                            _groupPad = new ConfigGroupPad();
                            _groupPad.setParentGUI(MMMainFrame.this);
                            _groupPad.setFont(new Font("", 0, 10));
                            _groupPad.setCore(mCore);
                            _groupPad.setParentGUI(MMMainFrame.this);
                            _groupButtonsPanel = new ConfigButtonsPanel();
                            _groupButtonsPanel.setCore(mCore);
                            _groupButtonsPanel.setGUI(MMMainFrame.this);
                            _groupButtonsPanel.setConfigPad(_groupPad);

                            // LEFT PART OF INTERFACE
                            _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));

                            // MIDDLE PART OF INTERFACE
                            _panel_cameraSettings = new JPanel();
                            _panel_cameraSettings.setLayout(new GridLayout(5, 2));
                            _panel_cameraSettings.setMinimumSize(new Dimension(100, 200));

                            _txtExposure = new JTextField();
                            try {
                                mCore.setExposure(90.0D);
                                _txtExposure.setText(String.valueOf(mCore.getExposure()));
                            } catch (Exception e2) {
                                _txtExposure.setText("90");
                            }
                            _txtExposure.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20));
                            _txtExposure.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyPressed(KeyEvent keyevent) {
                                    if (keyevent.getKeyCode() == KeyEvent.VK_ENTER)
                                        setExposure();
                                }
                            });
                            _panel_cameraSettings.add(new JLabel("Exposure [ms]: "));
                            _panel_cameraSettings.add(_txtExposure);

                            _combo_binning = new JComboBox();
                            _combo_binning.setMaximumRowCount(4);
                            _combo_binning.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
                            _combo_binning.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    changeBinning();
                                }
                            });

                            _panel_cameraSettings.add(new JLabel("Binning: "));
                            _panel_cameraSettings.add(_combo_binning);

                            _combo_shutters = new JComboBox();
                            _combo_shutters.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
                                    try {
                                        if (_combo_shutters.getSelectedItem() != null) {
                                            mCore.setShutterDevice((String) _combo_shutters.getSelectedItem());
                                            _prefs.put(PREF_SHUTTER, (String) _combo_shutters
                                                    .getItemAt(_combo_shutters.getSelectedIndex()));
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                            _combo_shutters.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
                            _panel_cameraSettings.add(new JLabel("Shutter : "));
                            _panel_cameraSettings.add(_combo_shutters);

                            ActionListener action_listener = new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    updateHistogram();
                                }
                            };

                            _cbAbsoluteHisto = new JCheckBox();
                            _cbAbsoluteHisto.addActionListener(action_listener);
                            _cbAbsoluteHisto.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent actionevent) {
                                    _comboBitDepth.setEnabled(_cbAbsoluteHisto.isSelected());
                                    _prefs.putBoolean(PREF_ABS_HIST, _cbAbsoluteHisto.isSelected());
                                }
                            });
                            _panel_cameraSettings.add(new JLabel("Display absolute histogram ?"));
                            _panel_cameraSettings.add(_cbAbsoluteHisto);

                            _comboBitDepth = new JComboBox(new String[] { "8-bit", "9-bit", "10-bit", "11-bit",
                                    "12-bit", "13-bit", "14-bit", "15-bit", "16-bit" });
                            _comboBitDepth.addActionListener(action_listener);
                            _comboBitDepth.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent actionevent) {
                                    _prefs.putInt(PREF_BITDEPTH, _comboBitDepth.getSelectedIndex());
                                }
                            });
                            _comboBitDepth.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20));
                            _comboBitDepth.setEnabled(false);
                            _panel_cameraSettings.add(new JLabel("Select your bit depth for abs. hitogram: "));
                            _panel_cameraSettings.add(_comboBitDepth);

                            // Acquisition
                            _panelAcquisitions = new JPanel();
                            _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS));

                            // Color settings
                            _panelColorChooser = new JPanel();
                            _panelColorChooser.setLayout(new BoxLayout(_panelColorChooser, BoxLayout.Y_AXIS));
                            painterPreferences = MicroscopePainterPreferences.getInstance();
                            painterPreferences.setPreferences(_prefs.node("paintersPreferences"));
                            painterPreferences.loadColors();

                            HashMap<String, Color> allColors = painterPreferences.getColors();
                            String[] allKeys = (String[]) allColors.keySet().toArray(new String[0]);
                            String[] columnNames = { "Painter", "Color", "Transparency" };
                            Object[][] data = new Object[allKeys.length][3];

                            for (int i = 0; i < allKeys.length; ++i) {
                                final int actualRow = i;
                                String actualKey = allKeys[i].toString();
                                data[i][0] = actualKey;
                                data[i][1] = allColors.get(actualKey);
                                final JSlider slider = new JSlider(0, 255, allColors.get(actualKey).getAlpha());
                                slider.addChangeListener(new ChangeListener() {

                                    @Override
                                    public void stateChanged(ChangeEvent changeevent) {
                                        painterTable.setValueAt(slider, actualRow, 2);
                                    }
                                });
                                data[i][2] = slider;
                            }
                            final AbstractTableModel tableModel = new JTableEvolvedModel(columnNames, data);
                            painterTable = new JTable(tableModel);
                            painterTable.getModel().addTableModelListener(new TableModelListener() {

                                @Override
                                public void tableChanged(TableModelEvent tablemodelevent) {
                                    if (tablemodelevent.getType() == TableModelEvent.UPDATE) {
                                        int row = tablemodelevent.getFirstRow();
                                        int col = tablemodelevent.getColumn();
                                        String columnName = tableModel.getColumnName(col);
                                        String painterName = (String) tableModel.getValueAt(row, 0);
                                        if (columnName.contains("Color")) {
                                            // New color value
                                            int alpha = painterPreferences.getColor(painterName).getAlpha();
                                            Color coloNew = (Color) tableModel.getValueAt(row, 1);
                                            painterPreferences.setColor(painterName, new Color(coloNew.getRed(),
                                                    coloNew.getGreen(), coloNew.getBlue(), alpha));
                                        } else if (columnName.contains("Transparency")) {
                                            // New alpha value
                                            Color c = painterPreferences.getColor(painterName);
                                            int alphaValue = ((JSlider) tableModel.getValueAt(row, 2))
                                                    .getValue();
                                            painterPreferences.setColor(painterName, new Color(c.getRed(),
                                                    c.getGreen(), c.getBlue(), alphaValue));
                                        }
                                        /*
                                         * for (int i = 0; i <
                                         * tableModel.getRowCount(); ++i) { try {
                                         * String painterName = (String)
                                         * tableModel.getValueAt(i, 0); Color c =
                                         * (Color) tableModel.getValueAt(i, 1); int
                                         * alphaValue; if (ASpinnerChanged &&
                                         * tablemodelevent.getFirstRow() == i) {
                                         * alphaValue = ((JSlider)
                                         * tableModel.getValueAt(i, 2)).getValue();
                                         * } else { alphaValue =
                                         * painterPreferences.getColor
                                         * (painterPreferences
                                         * .getPainterName(i)).getAlpha(); }
                                         * painterPreferences.setColor(painterName,
                                         * new Color(c.getRed(), c.getGreen(),
                                         * c.getBlue(), alphaValue)); } catch
                                         * (Exception e) { System.out.println(
                                         * "error with painter table update"); } }
                                         */
                                    }
                                }
                            });
                            painterTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
                            painterTable.setFillsViewportHeight(true);

                            // Create the scroll pane and add the table to it.
                            JScrollPane scrollPane = new JScrollPane(painterTable);

                            // Set up renderer and editor for the Favorite Color
                            // column.
                            painterTable.setDefaultRenderer(Color.class, new ColorRenderer(true));
                            painterTable.setDefaultEditor(Color.class, new ColorEditor());

                            painterTable.setDefaultRenderer(JSlider.class, new SliderRenderer(0, 255));
                            painterTable.setDefaultEditor(JSlider.class, new SliderEditor());

                            _panelColorChooser.add(scrollPane);
                            _panelColorChooser.add(Box.createVerticalGlue());

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

                            // EDITOR
                            // will refresh the data and verify if any change
                            // occurs.
                            // editor = new PropertyEditor(MMMainFrame.this);
                            // editor.setCore(mCore);
                            // editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                            // editor.addToMainDesktopPane();
                            // editor.refresh();
                            // editor.start();

                            editor = new PropertyEditor();
                            editor.setGui(MMMainFrame.this);
                            editor.setCore(mCore);
                            editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                            // editor.addToMainDesktopPane();
                            // editor.refresh();
                            // editor.start();

                            add(_mainPanel);
                            initializeGUI();
                            loadPreferences();
                            refreshGUI();
                            setResizable(true);
                            addToMainDesktopPane();
                            instanced = true;
                            instancing = false;
                            _singleton = MMMainFrame.this;
                            setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                            addFrameListener(new IcyFrameAdapter() {
                                @Override
                                public void icyFrameClosing(IcyFrameEvent e) {
                                    customClose();
                                }
                            });
                            acceptListener = new AcceptListener() {

                                @Override
                                public boolean accept(Object source) {
                                    close();
                                    return _pluginListEmpty;
                                }
                            };

                            adapter = new MainAdapter() {

                                @Override
                                public void sequenceOpened(MainEvent event) {
                                    updateHistogram();
                                }

                            };
                            Icy.getMainInterface().addCanExitListener(acceptListener);
                            Icy.getMainInterface().addListener(adapter);
                        }
                    });
                }
            });
        }
    });
}

From source file:Proiect.uploadFTP.java

public void actionFTP() {
    adressf.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
            InetAddress thisIp;//  w  ww .  jav a 2  s  .  c o  m
            try {
                thisIp = InetAddress.getLocalHost();
                titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText());
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            }
        }
    });

    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            saveState();
            uploadFTP.dispose();
            tree.dispose();
        }
    });

    connect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            FTPClient client = new FTPClient();
            FileInputStream fis = null;
            String pass = String.valueOf(passf.getPassword());
            try {
                if (filename == null) {
                    status.setText("File does not exist!");
                } else {
                    // Server address
                    client.connect(adressf.getText());
                    // Login credentials
                    client.login(userf.getText(), pass);
                    if (client.isConnected()) {
                        status.setText("Succesfull transfer!");
                        // File type
                        client.setFileType(FTP.BINARY_FILE_TYPE);
                        // File location
                        File file = new File(filepath);
                        fis = new FileInputStream(file);
                        // Change the folder on the server
                        client.changeWorkingDirectory(folderf.getText());
                        // Save the file on the server
                        client.storeFile(filename, fis);
                    } else {
                        status.setText("Transfer failed!");
                    }
                }
                client.logout();
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
                    }
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }
        }
    });

    browsef.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int retval = chooserf.showOpenDialog(chooserf);
            if (retval == JFileChooser.APPROVE_OPTION) {
                status.setText("");
                filename = chooserf.getSelectedFile().getName().toString();
                filepath = chooserf.getSelectedFile().getPath();
                filenf.setText(chooserf.getSelectedFile().getName().toString());
            }
        }
    });

    adv.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            tree.setSize(220, uploadFTP.getHeight());
            tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
            tree.setResizable(false);
            tree.setIconImage(Toolkit.getDefaultToolkit()
                    .getImage(getClass().getClassLoader().getResource("assets/ico.png")));
            tree.setUndecorated(true);
            tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2));
            tree.setVisible(true);
            tree.setLayout(new BorderLayout());

            JLabel labeltree = new JLabel("Server documents");
            labeltree.setOpaque(true);
            labeltree.setBackground(Encrypter.color_light);
            labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light));
            labeltree.setForeground(Encrypter.color_blue);
            labeltree.setFont(Encrypter.font16);

            JButton refresh = new JButton("");
            ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png");
            refresh.setIcon(refresh_icon);
            refresh.setBackground(Encrypter.color_light);
            refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
            refresh.setForeground(Encrypter.color_black);
            refresh.setFont(Encrypter.font16);
            refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            final FTPClient client = new FTPClient();
            DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText());
            DefaultMutableTreeNode files = null;
            DefaultMutableTreeNode leaf = null;

            final JTree tree_view = new JTree(top);
            tree_view.setForeground(Encrypter.color_black);
            tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
            tree_view.putClientProperty("JTree.lineStyle", "None");
            tree_view.setBackground(Encrypter.color_light);
            JScrollPane scrolltree = new JScrollPane(tree_view);
            scrolltree.setBackground(Encrypter.color_light);
            scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));

            UIManager.put("Tree.textBackground", Encrypter.color_light);
            UIManager.put("Tree.selectionBackground", Encrypter.color_blue);
            UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue);

            tree_view.updateUI();

            final String pass = String.valueOf(passf.getPassword());
            try {
                client.connect(adressf.getText());
                client.login(userf.getText(), pass);
                client.enterLocalPassiveMode();
                if (client.isConnected()) {
                    try {
                        FTPFile[] ftpFiles = client.listFiles();
                        for (FTPFile ftpFile : ftpFiles) {
                            files = new DefaultMutableTreeNode(ftpFile.getName());
                            top.add(files);
                            if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) {
                                FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName());
                                for (FTPFile ftpFile1 : ftpFiles1) {
                                    leaf = new DefaultMutableTreeNode(ftpFile1.getName());
                                    files.add(leaf);
                                }
                            }
                        }
                    } catch (IOException e1) {
                        Encrypter.printException(e1);
                    }
                    client.disconnect();
                } else {
                    status.setText("Failed connection!");
                }
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }

            tree.add(labeltree, BorderLayout.NORTH);
            tree.add(scrolltree, BorderLayout.CENTER);
            tree.add(refresh, BorderLayout.SOUTH);

            uploadFTP.addComponentListener(new ComponentListener() {

                public void componentMoved(ComponentEvent e) {
                    tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
                }

                public void componentShown(ComponentEvent e) {
                }

                public void componentResized(ComponentEvent e) {
                }

                public void componentHidden(ComponentEvent e) {
                }
            });

            uploadFTP.addWindowListener(new WindowListener() {
                public void windowActivated(WindowEvent e) {
                    tree.toFront();
                }

                public void windowOpened(WindowEvent e) {
                }

                public void windowIconified(WindowEvent e) {
                }

                public void windowDeiconified(WindowEvent e) {
                }

                public void windowDeactivated(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) {
                }

                public void windowClosed(WindowEvent e) {
                }
            });

            refresh.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    tree.dispose();
                    tree.setVisible(true);
                }
            });
        }
    });

}

From source file:rita.ui.component.DialogSelectEnemies.java

/**
 * Initialize the contents of the frame.
 * /*from  w  ww .  j  a v  a  2s .c om*/
 * @throws NoEnemiesException
 */
private void initialize() throws NoEnemiesException {
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.getContentPane().setLayout(new BorderLayout(6, 6));
    this.setTitle(Language.get("selectEnemies"));
    randomMode = new JCheckBox(Language.get("robotsBattleMode.random"));
    randomMode.setSelected(true);
    randomMode.addActionListener(new SelectUnselectPositionAction());

    icon = new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/target.jpg"));

    JPanel panelRobots = new JPanel();
    panelRobots.setBorder(new EmptyBorder(0, 12, 12, 0));
    panelRobots.setLayout(new BorderLayout(0, 0));

    JPanel panelSelectAllNone = new JPanel();
    panelSelectAllNone.setBorder(new EmptyBorder(0, 12, 0, 12));
    panelRobots.add(panelSelectAllNone, BorderLayout.EAST);
    this.getContentPane().add(panelRobots, BorderLayout.CENTER);

    GridBagLayout gbl_panelSelectAllNone = new GridBagLayout();
    gbl_panelSelectAllNone.columnWidths = new int[] { 0, 0 };
    gbl_panelSelectAllNone.rowHeights = new int[] { 0, 0, 8 };
    gbl_panelSelectAllNone.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_panelSelectAllNone.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    panelSelectAllNone.setLayout(gbl_panelSelectAllNone);

    JButton btnSelectAll = new JButton(Language.get("selectAllEnemies"));
    GridBagConstraints gbc_btnSelectAll = new GridBagConstraints();
    gbc_btnSelectAll.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnSelectAll.insets = new Insets(0, 0, 5, 0);
    gbc_btnSelectAll.gridx = 0;
    gbc_btnSelectAll.gridy = 0;
    panelSelectAllNone.add(btnSelectAll, gbc_btnSelectAll);

    JButton btnSelectNone = new JButton(Language.get("selectNoEnemies"));
    GridBagConstraints gbc_btnSelectNone = new GridBagConstraints();
    gbc_btnSelectNone.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnSelectNone.gridx = 0;
    gbc_btnSelectNone.gridy = 1;
    panelSelectAllNone.add(btnSelectNone, gbc_btnSelectNone);

    /*
     * btnInitialPositionsConfig = new
     * JButton(Language.get("selectRobotsInitialPositions"));
     * GridBagConstraints gbc_btnInitialPositionsConfig = new
     * GridBagConstraints(); gbc_btnSelectNone.fill =
     * GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0;
     * gbc_btnSelectNone.gridy = 1;
     * panelSelectAllNone.add(btnInitialPositionsConfig,
     * gbc_btnInitialPositionsConfig);
     * btnInitialPositionsConfig.addActionListener(new ActionListener() {
     * public void actionPerformed(ActionEvent evt) {
     * selectRobotsInitialPositions(); } });
     */

    JLabel label = new JLabel(String.format(Language.get("youtRobotAgainst"), HelperEditor.currentRobotName));
    label.setBorder(new EmptyBorder(12, 12, 0, 12));
    label.setIcon(new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/compite2.png")));
    label.setVerticalAlignment(SwingConstants.TOP);
    label.setFont(label.getFont().deriveFont(Font.BOLD, 14));

    panelSelectRobots = new JPanel();
    panelSelectRobots.setLayout(new GridLayout(0, 2));
    panelSelectRobots.setAutoscrolls(true);

    panelRobots.add(label, BorderLayout.NORTH);
    panelRobots.add(panelSelectRobots, BorderLayout.CENTER);

    // posicion de mi robot
    JPanel panelSetMyRobotPosition = new JPanel();
    // panelRobots.add(panelSetMyRobotPosition, BorderLayout.PAGE_END);
    panelSetMyRobotPosition.setLayout(new FlowLayout());
    JLabel ownPosition = new JLabel(Language.get("myRobotPosition") + " " + HelperEditor.currentRobotName);
    ownPosition.setFont(new Font("sansserif", Font.BOLD, 12));
    panelSetMyRobotPosition.add(ownPosition);
    // Posicion de mi robot
    buttonPos = new JButton(icon);
    buttonPos.addActionListener(new PosicionRobotAction(HelperEditor.currentRobotName)); // el nombre aqui es solo a
    // modo informativo
    buttonPos.setPreferredSize(new Dimension(30, 30));
    panelSetMyRobotPosition.add(buttonPos);
    positionComponents.add(buttonPos);

    // Matas
    JPanel panelSelectRoundsNumber = new JPanel();
    // panelRobots.add(panelSelectRoundsNumber, BorderLayout.SOUTH);
    panelSelectRoundsNumber.setLayout(new FlowLayout());
    panelSelectRoundsNumber.add(new JLabel(Language.get("selectRoundsNumber")));
    //      this.roundsNumberTextField = new JTextField(
    //            Integer.toString(Batalla.NUMBER_OF_ROUNDS), 5);
    this.roundsNumberSpinner = new JSpinner(new SpinnerNumberModel(Batalla.NUMBER_OF_ROUNDS,
            Batalla.MIN_NUMBER_OF_ROUNDS, Batalla.MAX_NUMBER_OF_ROUNDS, 1));

    panelSelectRoundsNumber.add(this.roundsNumberSpinner);

    JPanel panelSouth = new JPanel();
    panelSouth.setLayout(new GridLayout(4, 1));

    panelSouth.add(panelSetMyRobotPosition);
    //this.getContentPane().add(randomMode, BorderLayout.SOUTH);
    panelSouth.add(randomMode);
    panelSouth.add(new JSeparator());
    panelSouth.add(panelSelectRoundsNumber);
    panelRobots.add(panelSouth, BorderLayout.SOUTH);

    JPanel panelOkCancel = new JPanel();
    this.getContentPane().add(panelOkCancel, BorderLayout.SOUTH);
    panelOkCancel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 12));

    btnOK = new JButton(Language.get("selectStartBattle"));
    btnOK.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            startBattle(panelSelectRobots);
        }
    });
    // comienza deshabilitado hasta que se seleccione 1 enemigo
    // btnOK.setEnabled(false);
    panelOkCancel.add(btnOK);

    JButton btnCancel = new JButton(Language.get("cancel"));
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            closeDialog();
        }
    });
    panelOkCancel.add(btnCancel);

    btnSelectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            selectChecks(panelSelectRobots, true);
            // btnOK.setEnabled(true);
        }
    });

    btnSelectNone.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            selectChecks(panelSelectRobots, false);
            // btnOK.setEnabled(false);
        }
    });

    // TODO Agregar funcionalidad de elegir las posiciones iniciales de los
    // robots.
    // TODO Averiguar como pasar las posiciones para que se elijan de manera
    // random, probar (0,0,0)

    try {
        robotNameClicked = new RobotNameClickedEvent(btnOK);
        addRobotsToPanel(panelSelectRobots);

        this.setResizable(false);
        this.pack();
        PositionCalc.centerDialog(this);
        enablePositionOptions(false);
        this.setVisible(true);
    } catch (FileNotFoundException e) {
        throw new NoEnemiesException(e.getMessage());
    }

}

From source file:se.trixon.jota.client.ui.TabCloser.java

public TabCloser(final TabHolder pane) {
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    setOpaque(false);/*  w w  w.  ja v a2s  . c o  m*/

    JLabel label = new JLabel() {
        @Override
        public String getText() {
            int i = pane.indexOfTabComponent(TabCloser.this);
            if (i != -1) {
                setText(pane.getTitleAt(i));
                return super.getText();
            }
            return null;
        }
    };

    add(label);
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    mButton = new TabButton();
    int buttonPos = SystemUtils.IS_OS_WINDOWS ? 1 : 0;
    add(mButton, buttonPos);
    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}