Example usage for javax.swing JPanel setBorder

List of usage examples for javax.swing JPanel setBorder

Introduction

In this page you can find the example usage for javax.swing JPanel 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:captureplugin.drivers.defaultdriver.AdditionalParams.java

/**
 * Create List-Panel/*from   w w w  .j av a2 s.  c  o m*/
 * @return List-Panel
 */
private Component createListPanel() {
    JPanel panel = new JPanel(new BorderLayout(0, 2));
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));

    panel.add(new JLabel(mLocalizer.msg("command", "Command")), BorderLayout.NORTH);

    mList = new JList(mListModel);
    panel.add(new JScrollPane(mList), BorderLayout.CENTER);

    JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT));

    JButton add = new JButton(TVBrowserIcons.newIcon(TVBrowserIcons.SIZE_SMALL));
    add.setToolTipText(Localizer.getLocalization(Localizer.I18N_ADD));
    add.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addPressed();
        }

    });

    buttons.add(add);

    JButton remove = new JButton(TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL));
    remove.setToolTipText(Localizer.getLocalization(Localizer.I18N_DELETE));

    remove.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            removePressed();
        }

    });

    buttons.add(remove);

    final JButton up = new JButton(TVBrowserIcons.up(TVBrowserIcons.SIZE_SMALL));
    up.setToolTipText(Localizer.getLocalization(Localizer.I18N_UP));
    buttons.add(up);

    up.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            upPressed();
        }

    });

    final JButton down = new JButton(TVBrowserIcons.down(TVBrowserIcons.SIZE_SMALL));
    down.setToolTipText(Localizer.getLocalization(Localizer.I18N_DOWN));
    buttons.add(down);

    down.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            downPressed();
        }

    });

    mStartStop = new JButton(mStartIcon);
    mStartStop.setToolTipText(mLocalizer.msg("startstop", "Activate or Deactivate Parameter"));

    mStartStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            startStopPressed();
        }
    });

    buttons.add(mStartStop);

    panel.add(buttons, BorderLayout.SOUTH);

    mList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            selectionChanged();
            if (mList.getSelectedIndex() == 0) {
                up.setEnabled(false);
                down.setEnabled(true);
            } else if (mList.getSelectedIndex() == mListModel.getSize() - 1) {
                up.setEnabled(true);
                down.setEnabled(false);
            } else {
                up.setEnabled(true);
                down.setEnabled(true);
            }
        }

    });

    selectionChanged();
    return panel;
}

From source file:com.raphfrk.craftproxyclient.gui.CraftProxyGUI.java

public CraftProxyGUI(String buildId) {

    pf = new PropertiesFile("CraftProxyClientGUI.txt");

    try {/* w  w  w. j av a 2  s . co m*/
        pf.load();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to open settings file");
    }

    String defaultHostname = pf.getString("connect_hostname", "");
    int defaultPort = pf.getInt("connect_port", 20000);
    int listenPort = pf.getInt("listen_port", 25565);
    int desired = pf.getInt("cache_size", 48);

    try {
        pf.save();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to save settings file");
    }

    setTitle("CraftProxyClient Local (" + buildId + ")");
    setSize(500, 375);
    setLocation(40, 150);

    topPanel.setLayout(new BorderLayout());
    topPanel.setBorder(new TitledBorder("Remote Server"));
    topPanel.setBackground(Color.WHITE);
    secondPanel.setLayout(new BorderLayout());
    secondPanel.setBorder(new TitledBorder("Local Server"));
    secondPanel.setBackground(Color.WHITE);

    serverName = new JTextField(defaultHostname, 20);
    TitledBorder border = new TitledBorder("Name");
    serverName.setBorder(border);
    serverName.addActionListener(this);

    portNum = new JTextField(Integer.toString(defaultPort), 6);
    border = new TitledBorder("Port");
    portNum.setBorder(border);
    portNum.addActionListener(this);

    localServerName = new JLabel("localhost");
    localServerName.setBackground(Color.GRAY);
    border = new TitledBorder("Name");
    localServerName.setBorder(border);

    localServerPortnum = new JTextField(Integer.toString(listenPort), 6);
    border = new TitledBorder("Port");
    localServerPortnum.setBorder(border);
    localServerPortnum.addActionListener(this);

    topPanel.add(serverName, BorderLayout.CENTER);
    topPanel.add(portNum, BorderLayout.LINE_END);

    secondPanel.setLayout(new BorderLayout());
    secondPanel.add(localServerName, BorderLayout.CENTER);
    secondPanel.add(localServerPortnum, BorderLayout.LINE_END);

    combinedTop.setLayout(new BorderLayout());
    combinedTop.add(topPanel, BorderLayout.CENTER);
    combinedTop.add(secondPanel, BorderLayout.SOUTH);

    currentSize = new JTextField("Unknown");
    currentSize.setBorder(new TitledBorder("Current Size (MB)"));
    currentSize.setEditable(false);

    desiredSize = new JTextField(Integer.toString(desired));
    desiredSize.setBorder(new TitledBorder("Max Size (MB)"));

    connect = new JButton(buttonText);
    connect.addActionListener(this);

    filePanel = new JPanel();
    filePanel.setLayout(new BorderLayout());
    JPanel fileLinePanel = new JPanel();
    fileLinePanel.setBorder(new TitledBorder("Cache Size"));
    fileLinePanel.setLayout(new GridLayout(1, 3));
    fileLinePanel.add(currentSize);
    fileLinePanel.add(desiredSize);
    filePanel.add(fileLinePanel, BorderLayout.CENTER);
    filePanel.add(connect, BorderLayout.PAGE_END);

    info = new JLabel();
    border = new TitledBorder("Status");
    info.setBorder(border);

    setLayout(new BorderLayout());
    add(combinedTop, BorderLayout.PAGE_START);
    add(info, BorderLayout.CENTER);
    add(filePanel, BorderLayout.PAGE_END);

    this.setResizable(false);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.addWindowListener(this);

}

From source file:gridvisual.GridVisualize.java

public GridVisualize() {

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();/*from  w ww . j av a 2s.co m*/

    layout = new TreeLayout<String, Integer>(graph);
    radialLayout = new BalloonLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(900, 900));
    vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings(radialLayout);

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());

    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    vv.scaleToLayout(scaler);

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Balloon");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        layout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });
    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);
    controls.add(hyperView);
    content.add(controls, BorderLayout.SOUTH);

    for (String v : layout.getGraph().getVertices()) {

        java.awt.Point p = nodeTable.get(new Integer(Integer.parseInt(v))).coord;

        layout.setLocation(v, p);
    }

    /*
     Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() {
    public Paint transform(Integer i) {
        return Color.GREEN;
    }
    };*/

    /*   Transformer<Integer, Paint> vertexPaint = new Transformer<Integer, Paint>() {
    private final Color[] palette = {Color.GREEN, Color.BLUE, Color.RED}; 
            
    public Paint transform(Integer i) {
       return palette[i.intValue() % palette.length];
    }
    };*/

    vv.getRenderContext().setVertexFillPaintTransformer(new MyTransformer(this.nodeTable));
}

From source file:DateChooserPanel.java

/**
 * Returns a panel that appears at the bottom of the calendar panel - 
 * contains a button for selecting today's date.
 *
 * @return the panel./*from w w w  . j  av  a2 s . c o m*/
 */
private JPanel constructControlPanel() {

    final JPanel p = new JPanel();
    p.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 5));
    this.todayButton = new JButton("Today");
    this.todayButton.addActionListener(this);
    this.todayButton.setActionCommand("todayButtonClicked");
    p.add(this.todayButton);
    return p;

}

From source file:com.floreantpos.config.ui.TerminalConfigurationView.java

private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel(new MigLayout("gap 5px 10px", "[][][grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel lblTerminalNumber = new JLabel(Messages.getString("TerminalConfigurationView.TERMINAL_NUMBER")); //$NON-NLS-1$
    contentPanel.add(lblTerminalNumber, "alignx left,aligny center"); //$NON-NLS-1$

    tfTerminalNumber = new IntegerTextField();
    tfTerminalNumber.setColumns(10);/*from  w ww . j  av  a2  s . c o  m*/
    contentPanel.add(tfTerminalNumber, "aligny top,wrap"); //$NON-NLS-1$

    JLabel lblTerminalLocation = new JLabel(Messages.getString("TerminalConfigurationView.24")); //$NON-NLS-1$
    taTerminalLocation = new JTextArea();
    taTerminalLocation.setLineWrap(true);
    taTerminalLocation.setPreferredSize(PosUIManager.getSize(350, 40));

    JScrollPane taScrollPane = new JScrollPane(taTerminalLocation);

    contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.9"))); //$NON-NLS-1$
    tfSecretKeyLength = new IntegerTextField(3);
    contentPanel.add(tfSecretKeyLength, "wrap"); //$NON-NLS-1$

    contentPanel.add(cbShowDbConfiguration, "spanx 3"); //$NON-NLS-1$

    cbAutoLogoff.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (cbAutoLogoff.isSelected()) {
                tfLogoffTime.setEnabled(true);
            } else {
                tfLogoffTime.setEnabled(false);
            }
        }
    });
    contentPanel.add(cbAutoLogoff, "newline"); //$NON-NLS-1$
    contentPanel.add(tfLogoffTime, "wrap"); //$NON-NLS-1$

    contentPanel.add(cbTranslatedName, "span 2"); //$NON-NLS-1$
    contentPanel.add(cbFullscreenMode, "newline, span"); //$NON-NLS-1$
    contentPanel.add(cbUseSettlementPrompt, "newline, span"); //$NON-NLS-1$
    contentPanel.add(cbShowBarCodeOnReceipt, "newline,span"); //$NON-NLS-1$
    contentPanel.add(cbGroupKitchenReceiptItems, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkEnabledMultiCurrency, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkAllowToDelPrintedItem, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkAllowQuickMaintenance, "newline,span"); //$NON-NLS-1$
    contentPanel.add(chkModifierCannotExceedMaxLimit, "newline,span"); //$NON-NLS-1$

    contentPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.17")), "newline"); //$NON-NLS-1$//$NON-NLS-2$
    contentPanel.add(cbFonts, "span 2, wrap"); //$NON-NLS-1$

    Vector<String> defaultViewList = new Vector<String>();

    List<OrderType> orderTypes = Application.getInstance().getOrderTypes();
    if (orderTypes != null) {
        for (OrderType orderType : orderTypes) {
            defaultViewList.add(orderType.getName());
        }
    }
    defaultViewList.add(SwitchboardOtherFunctionsView.VIEW_NAME);
    defaultViewList.add(KitchenDisplayView.VIEW_NAME);
    defaultViewList.add(SwitchboardView.VIEW_NAME);

    cbDefaultView = new JComboBox<String>(defaultViewList);

    contentPanel.add(new JLabel("Default View"), "newline"); //$NON-NLS-1$//$NON-NLS-2$
    contentPanel.add(cbDefaultView, "span 2, wrap"); //$NON-NLS-1$

    contentPanel.add(lblTerminalLocation, "alignx left,aligny top"); //$NON-NLS-1$
    contentPanel.add(taScrollPane, "aligny top, spanx 2,wrap"); //$NON-NLS-1$

    JPanel touchConfigurationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 10));
    touchConfigurationPanel.setBorder(BorderFactory.createTitledBorder("-")); //$NON-NLS-1$
    touchConfigurationPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.18"))); //$NON-NLS-1$
    tfButtonHeight = new IntegerTextField(5);
    //touchConfigPanel.add(tfButtonHeight);

    int FPS_MIN = 10;
    int FPS_MAX = 50;
    int FPS_INIT = 10;
    jsResize = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT);
    jsResize.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                double fps = (int) source.getValue();
                fps = fps / 10;
                tfScaleFactor.setText(String.valueOf(fps));
            }
        }
    });
    touchConfigurationPanel.add(jsResize);

    //touchConfigPanel.add(new JLabel("Menu item button height"));
    tfScaleFactor = new DoubleTextField(5);
    touchConfigurationPanel.add(tfScaleFactor);

    //touchConfigPanel.add(new JLabel(Messages.getString("TerminalConfigurationView.20"))); //$NON-NLS-1$
    tfFontSize = new IntegerTextField(5);
    //touchConfigPanel.add(tfFontSize);

    contentPanel.add(touchConfigurationPanel, "span 3, wrap"); //$NON-NLS-1$

    addCashDrawerConfig();

    JScrollPane scrollPane = new JScrollPane(contentPanel);
    scrollPane.setBorder(null);
    add(scrollPane);
}

From source file:emailplugin.MailCreator.java

/**
 * Show the EMail-Open Dialog./*from  w  w w  . jav a 2 s.  co m*/
 *
 * This Dialog says that the EMail should have been opened. It gives the User
 * a chance to specify another EMail Program if it went wrong.
 *
 * @param parent
 *          Parent-Frame
 */
private void showEMailOpenedDialog(Frame parent) {
    final JDialog dialog = new JDialog(parent, true);

    dialog.setTitle(mLocalizer.msg("EMailOpenedTitel", "Email was opened"));

    JPanel panel = (JPanel) dialog.getContentPane();
    panel.setLayout(new FormLayout("fill:200dlu:grow", "default, 3dlu, default, 3dlu, default"));
    panel.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("EMailOpened", "Email was opened. Configure it?")),
            cc.xy(1, 1));

    final JCheckBox dontShowAgain = new JCheckBox(
            mLocalizer.msg("DontShowAgain", "Don't show this Dialog again"));
    panel.add(dontShowAgain, cc.xy(1, 3));

    JButton configure = new JButton(mLocalizer.msg("configure", "Configure"));
    configure.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Plugin.getPluginManager().showSettings(mPlugin);
            dialog.setVisible(false);
        }
    });

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (dontShowAgain.isSelected()) {
                mSettings.setShowEmailOpened(false);
            }
            dialog.setVisible(false);
        }
    });

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.add(configure);
    buttonPanel.add(ok);
    panel.add(buttonPanel, cc.xy(1, 5));

    UiUtilities.registerForClosing(new WindowClosingIf() {
        public void close() {
            dialog.setVisible(false);
        }

        public JRootPane getRootPane() {
            return dialog.getRootPane();
        }
    });

    dialog.getRootPane().setDefaultButton(ok);

    dialog.pack();
    UiUtilities.centerAndShow(dialog);
}

From source file:net.sf.jabref.importer.ImportCustomizationDialog.java

/**
 *
 * @param frame//  w  ww. j  av  a 2  s . com
 */
public ImportCustomizationDialog(final JabRefFrame frame) {
    super(frame, Localization.lang("Manage custom imports"), false);

    ImportTableModel tableModel = new ImportTableModel();
    customImporterTable = new JTable(tableModel);
    TableColumnModel cm = customImporterTable.getColumnModel();
    cm.getColumn(0).setPreferredWidth(COL_0_WIDTH);
    cm.getColumn(1).setPreferredWidth(COL_1_WIDTH);
    cm.getColumn(2).setPreferredWidth(COL_2_WIDTH);
    cm.getColumn(3).setPreferredWidth(COL_3_WIDTH);
    JScrollPane sp = new JScrollPane(customImporterTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    customImporterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    customImporterTable.setPreferredScrollableViewportSize(getSize());
    if (customImporterTable.getRowCount() > 0) {
        customImporterTable.setRowSelectionInterval(0, 0);
    }

    JButton addFromFolderButton = new JButton(Localization.lang("Add from folder"));
    addFromFolderButton.addActionListener(e -> {
        CustomImporter importer = new CustomImporter();
        importer.setBasePath(FileDialogs.getNewDir(frame,
                new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Collections.emptyList(),
                Localization.lang("Select Classpath of New Importer"), JFileChooser.CUSTOM_DIALOG, false));
        String chosenFileStr = null;
        if (importer.getBasePath() != null) {
            chosenFileStr = FileDialogs.getNewFile(frame, importer.getFileFromBasePath(),
                    Collections.singletonList(".class"), Localization.lang("Select new ImportFormat subclass"),
                    JFileChooser.CUSTOM_DIALOG, false);
        }
        if (chosenFileStr != null) {
            try {
                importer.setClassName(pathToClass(importer.getFileFromBasePath(), new File(chosenFileStr)));
                importer.setName(importer.getInstance().getFormatName());
                importer.setCliId(importer.getInstance().getId());
                addOrReplaceImporter(importer);
                customImporterTable.revalidate();
                customImporterTable.repaint();
            } catch (Exception exc) {
                JOptionPane.showMessageDialog(frame,
                        Localization.lang("Could not instantiate %0", chosenFileStr));
            } catch (NoClassDefFoundError exc) {
                JOptionPane.showMessageDialog(frame, Localization.lang(
                        "Could not instantiate %0. Have you chosen the correct package path?", chosenFileStr));
            }

        }
    });
    addFromFolderButton
            .setToolTipText(Localization.lang("Add a (compiled) custom ImportFormat class from a class path.")
                    + "\n" + Localization.lang("The path need not be on the classpath of JabRef."));

    JButton addFromJarButton = new JButton(Localization.lang("Add from jar"));
    addFromJarButton.addActionListener(e -> {
        String basePath = FileDialogs.getNewFile(frame,
                new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Arrays.asList(".zip", ".jar"),
                Localization.lang("Select a Zip-archive"), JFileChooser.CUSTOM_DIALOG, false);

        if (basePath != null) {
            try (ZipFile zipFile = new ZipFile(new File(basePath), ZipFile.OPEN_READ)) {
                ZipFileChooser zipFileChooser = new ZipFileChooser(this, zipFile);
                zipFileChooser.setVisible(true);
                customImporterTable.revalidate();
                customImporterTable.repaint(10);
            } catch (IOException exc) {
                LOGGER.info("Could not open Zip-archive.", exc);
                JOptionPane.showMessageDialog(frame, Localization.lang("Could not open %0", basePath) + "\n"
                        + Localization.lang("Have you chosen the correct package path?"));
            } catch (NoClassDefFoundError exc) {
                LOGGER.info("Could not instantiate Zip-archive reader.", exc);
                JOptionPane.showMessageDialog(frame, Localization.lang("Could not instantiate %0", basePath)
                        + "\n" + Localization.lang("Have you chosen the correct package path?"));
            }
        }
    });
    addFromJarButton
            .setToolTipText(Localization.lang("Add a (compiled) custom ImportFormat class from a Zip-archive.")
                    + "\n" + Localization.lang("The Zip-archive need not be on the classpath of JabRef."));

    JButton showDescButton = new JButton(Localization.lang("Show description"));
    showDescButton.addActionListener(e -> {
        int row = customImporterTable.getSelectedRow();
        if (row == -1) {
            JOptionPane.showMessageDialog(frame, Localization.lang("Please select an importer."));
        } else {
            CustomImporter importer = ((ImportTableModel) customImporterTable.getModel()).getImporter(row);
            try {
                ImportFormat importFormat = importer.getInstance();
                JOptionPane.showMessageDialog(frame, importFormat.getDescription());
            } catch (IOException | ClassNotFoundException | InstantiationException
                    | IllegalAccessException exc) {
                LOGGER.warn("Could not instantiate importer " + importer.getName(), exc);
                JOptionPane.showMessageDialog(frame, Localization.lang("Could not instantiate %0 %1",
                        importer.getName() + ":\n", exc.getMessage()));
            }
        }
    });

    JButton removeButton = new JButton(Localization.lang("Remove"));
    removeButton.addActionListener(e -> {
        int row = customImporterTable.getSelectedRow();
        if (row == -1) {
            JOptionPane.showMessageDialog(frame, Localization.lang("Please select an importer."));
        } else {
            customImporterTable.removeRowSelectionInterval(row, row);
            Globals.prefs.customImports
                    .remove(((ImportTableModel) customImporterTable.getModel()).getImporter(row));
            Globals.IMPORT_FORMAT_READER.resetImportFormats();
            customImporterTable.revalidate();
            customImporterTable.repaint();
        }
    });

    Action closeAction = new AbstractAction() {

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

    JButton closeButton = new JButton(Localization.lang("Close"));
    closeButton.addActionListener(closeAction);

    JButton helpButton = new HelpAction(HelpFile.CUSTOM_IMPORTS).getHelpButton();

    // Key bindings:
    JPanel mainPanel = new JPanel();
    ActionMap am = mainPanel.getActionMap();
    InputMap im = mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", closeAction);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(sp, BorderLayout.CENTER);
    JPanel buttons = new JPanel();
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    bb.addGlue();
    bb.addButton(addFromFolderButton);
    bb.addButton(addFromJarButton);
    bb.addButton(showDescButton);
    bb.addButton(removeButton);
    bb.addButton(closeButton);
    bb.addUnrelatedGap();
    bb.addButton(helpButton);
    bb.addGlue();

    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(buttons, BorderLayout.SOUTH);
    this.setSize(getSize());
    pack();
    this.setLocationRelativeTo(frame);
    new FocusRequester(customImporterTable);
}

From source file:BRHInit.java

public void showVPSPrompt(JSONArray vps) throws Exception {
    vps_list = vps;//from   w ww .  j  a  v a  2 s.  com

    if (vps_list_window == null) {
        vps_list_window = new JFrame("BRH Console");
        vps_list_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel top_panel = new JPanel();
        vps_list_window.getContentPane().add(top_panel);

        top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS));
        top_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        Vector values = new Vector();
        for (int idx = 0; idx < vps_list.length(); ++idx) {
            JSONArray row = vps_list.getJSONArray(idx);
            values.addElement(row.getString(1));
        }

        vps_list_box = new JList(values);
        top_panel.add(new JScrollPane(vps_list_box));

        vps_list_box.setVisibleRowCount(10);

        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        JPanel col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(new JLabel("email"));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(new JLabel("password"));

        p.add(Box.createRigidArea(new Dimension(5, 0)));

        col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(email = new JTextField(20));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(password = new JPasswordField());

        top_panel.add(Box.createRigidArea(new Dimension(0, 10)));

        p = new JPanel();
        top_panel.add(p);
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        p.add(Box.createHorizontalGlue());
        p.add(vps_list_ok = new JButton("OK"));
        p.add(Box.createRigidArea(new Dimension(5, 0)));
        p.add(vps_list_cancel = new JButton("Cancel"));
        p.add(Box.createHorizontalGlue());

        vps_list_ok.addActionListener(this);
        vps_list_cancel.addActionListener(this);

        vps_list_window.pack();
    }

    vps_list_window.setVisible(true);
}

From source file:edu.uci.ics.jung.samples.HyperbolicVertexImageShaperDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features./*from  ww w.  j av a  2 s  . c om*/
 * 
 */
public HyperbolicVertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();
    Number[] vertices = createVertices(11);

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < vertices.length; i++) {
        map.put(vertices[i], iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < vertices.length; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(HyperbolicVertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(vertices[i], icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    createEdges(vertices);

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(),
            Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.setBackground(Color.white);

    final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));

    // features on and off. For a real application, use VertexIconAndShapeFunction instead.
    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();

    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);

    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);

    // Get the pickedState and add a listener that will decorate the
    // Vertex images with a checkmark icon when they are picked
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    vv.addPostRenderPaintable(new VisualizationServer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);

    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);

    this.viewSupport = new HyperbolicImageLensSupport<Number, Number>(vv);
    this.modelSupport = new LayoutLensSupport<Number, Number>(vv);

    graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener());

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (viewSupport != null) {
                viewSupport.deactivate();
            }
            if (modelSupport != null) {
                modelSupport.deactivate();
            }
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.setBorder(BorderFactory.createTitledBorder("Lens"));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);
    controls.add(lensPanel);
}

From source file:medsavant.enrichment.app.RegionListAggregatePanel.java

public RegionListAggregatePanel(String page) {
    super(page);//www  . ja v  a2s. c om
    setLayout(new BorderLayout());

    variantCounts = new TreeMap<GenomicRegion, Integer>();
    patientCounts = new TreeMap<GenomicRegion, Integer>();

    regionSetCombo = new JComboBox();

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

    progress = new JProgressBar();
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new BoxLayout(banner, BoxLayout.X_AXIS));

    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Region List"));

    banner.add(regionSetCombo);
    banner.add(ViewUtil.getMediumSeparator());
    banner.add(Box.createHorizontalGlue());
    banner.add(progress);

    add(banner, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);

    createSearchableTable();

    regionSetCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            fetchRegions((RegionSet) regionSetCombo.getSelectedItem());
        }
    });

    new MedSavantWorker<List<RegionSet>>(pageName) {
        @Override
        protected List<RegionSet> doInBackground() throws Exception {
            return RegionController.getInstance().getRegionSets();
        }

        @Override
        protected void showProgress(double fraction) {
        }

        @Override
        protected void showSuccess(List<RegionSet> result) {
            if (!result.isEmpty()) {
                updateRegionSetCombo(result);
            }
        }
    }.execute();
}