Example usage for javax.swing BorderFactory createEtchedBorder

List of usage examples for javax.swing BorderFactory createEtchedBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createEtchedBorder.

Prototype

public static Border createEtchedBorder() 

Source Link

Document

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Usage

From source file:gdt.jgui.entity.procedure.JProcedurePanel.java

/**
 * The default constructor.//from  ww w. j a v  a2  s.c o m
 */
public JProcedurePanel() {
    sourcePanel = new JEditorPane();
    JScrollPane scrollPaneTop = new JScrollPane(sourcePanel);
    scrollPaneTop.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Java Source",
            TitledBorder.CENTER, TitledBorder.TOP));
    reportPanel = new JEditorPane();
    JScrollPane scrollPaneBottom = new JScrollPane(reportPanel);
    scrollPaneBottom.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Report",
            TitledBorder.CENTER, TitledBorder.TOP));
    setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPaneTop, scrollPaneBottom);
    splitPane.setDividerLocation(0.5);
    add(splitPane);
    splitPane.addComponentListener(new ShowListener());
}

From source file:FocusTraversalDemo.java

public FocusTraversalDemo() {
    super(new BorderLayout());

    JTextField tf1 = new JTextField("Field 1");
    JTextField tf2 = new JTextField("A Bigger Field 2");
    JTextField tf3 = new JTextField("Field 3");
    JTextField tf4 = new JTextField("A Bigger Field 4");
    JTextField tf5 = new JTextField("Field 5");
    JTextField tf6 = new JTextField("A Bigger Field 6");
    JTable table = new JTable(4, 3);
    togglePolicy = new JCheckBox("Custom FocusTraversalPolicy");
    togglePolicy.setActionCommand("toggle");
    togglePolicy.addActionListener(this);
    togglePolicy.setFocusable(false); // Remove it from the focus cycle.
    // Note that HTML is allowed and will break this run of text
    // across two lines.
    label = new JLabel(
            "<html>Use Tab (or Shift-Tab) to navigate from component to component.Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>");

    JPanel leftTextPanel = new JPanel(new GridLayout(3, 2));
    leftTextPanel.add(tf1, BorderLayout.PAGE_START);
    leftTextPanel.add(tf3, BorderLayout.CENTER);
    leftTextPanel.add(tf5, BorderLayout.PAGE_END);
    leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel rightTextPanel = new JPanel(new GridLayout(3, 2));
    rightTextPanel.add(tf2, BorderLayout.PAGE_START);
    rightTextPanel.add(tf4, BorderLayout.CENTER);
    rightTextPanel.add(tf6, BorderLayout.PAGE_END);
    rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel tablePanel = new JPanel(new GridLayout(0, 1));
    tablePanel.add(table, BorderLayout.CENTER);
    tablePanel.setBorder(BorderFactory.createEtchedBorder());
    JPanel bottomPanel = new JPanel(new GridLayout(2, 1));
    bottomPanel.add(togglePolicy, BorderLayout.PAGE_START);
    bottomPanel.add(label, BorderLayout.PAGE_END);

    add(leftTextPanel, BorderLayout.LINE_START);
    add(rightTextPanel, BorderLayout.CENTER);
    add(tablePanel, BorderLayout.LINE_END);
    add(bottomPanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    Vector<Component> order = new Vector<Component>(7);
    order.add(tf1);/* www  . j a  va 2 s. c o m*/
    order.add(tf2);
    order.add(tf3);
    order.add(tf4);
    order.add(tf5);
    order.add(tf6);
    order.add(table);
    newPolicy = new MyOwnFocusTraversalPolicy(order);
}

From source file:api3.transform.PlotWave.java

public void plot(double[][] signal, String name, long samplerate) {

    frame.setTitle(name);/*w w  w.j  a  v a 2s . c  o m*/

    XYSeries[] soundWave = new XYSeries[signal.length];
    for (int j = 0; j < signal.length; ++j) {
        soundWave[j] = new XYSeries("sygnal" + j);
        for (int i = 0; i < signal[0].length; ++i) {
            double index = (samplerate == 0) ? i : 1000.0 * (double) i / (double) samplerate;
            soundWave[j].add(index, signal[j][i]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int j = 0; j < signal.length; ++j) {
        dataset.addSeries(soundWave[j]);
    }

    JFreeChart chart = //            (samplerate ==0 )?
            //            ChartFactory.createXYBarChart(
            //            name,
            //            "prbka",
            //            false,
            //            "warto",
            //            new XYBarDataset(dataset,0.0625),
            //            PlotOrientation.VERTICAL,
            //            true,false,false)
            //            :
            ChartFactory.createXYLineChart(name, "prbka", "warto", dataset,
                    PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();

    slider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            int value = slider.getValue();
            double minimum = domainAxis.getRange().getLowerBound();
            double maximum = domainAxis.getRange().getUpperBound();
            double delta = (0.1f * (domainAxis.getRange().getLength()));
            if (value < lastValue) { // left
                minimum = minimum - delta;
                maximum = maximum - delta;
            } else { // right
                minimum = minimum + delta;
                maximum = maximum + delta;
            }
            DateRange range = new DateRange(minimum, maximum);
            domainAxis.setRange(range);
            lastValue = value;
            if (lastValue == slider.getMinimum() || lastValue == slider.getMaximum()) {
                slider.setValue(SLIDER_DEFAULT_VALUE);
            }
        }

    });

    plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1)));

    ChartPanel chartPanel = new ChartPanel(chart);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);

    chartPanel.addMouseWheelListener(addZoomWheel());

    panel.add(chartPanel);
    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
    dashboard.add(slider);
    panel.add(dashboard, BorderLayout.SOUTH);

    frame.getContentPane().add((JPanel) panel, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
}

From source file:FocusTraversalDemo.java

public FocusTraversalDemo() {
    super(new BorderLayout());
    newPolicy = new MyOwnFocusTraversalPolicy();

    tf1 = new JTextField("Field 1");
    tf2 = new JTextField("A Bigger Field 2");
    tf3 = new JTextField("Field 3");
    tf4 = new JTextField("A Bigger Field 4");
    tf5 = new JTextField("Field 5");
    tf6 = new JTextField("A Bigger Field 6");
    table = new JTable(4, 3);
    togglePolicy = new JCheckBox("Custom FocusTraversalPolicy");
    togglePolicy.setActionCommand("toggle");
    togglePolicy.addActionListener(this);
    togglePolicy.setFocusable(false); //Remove it from the focus cycle.
    //Note that HTML is allowed and will break this run of text
    //across two lines.
    label = new JLabel(
            "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>");

    JPanel leftTextPanel = new JPanel(new GridLayout(3, 2));
    leftTextPanel.add(tf1, BorderLayout.PAGE_START);
    leftTextPanel.add(tf3, BorderLayout.CENTER);
    leftTextPanel.add(tf5, BorderLayout.PAGE_END);
    leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel rightTextPanel = new JPanel(new GridLayout(3, 2));
    rightTextPanel.add(tf2, BorderLayout.PAGE_START);
    rightTextPanel.add(tf4, BorderLayout.CENTER);
    rightTextPanel.add(tf6, BorderLayout.PAGE_END);
    rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel tablePanel = new JPanel(new GridLayout(0, 1));
    tablePanel.add(table, BorderLayout.CENTER);
    tablePanel.setBorder(BorderFactory.createEtchedBorder());
    JPanel bottomPanel = new JPanel(new GridLayout(2, 1));
    bottomPanel.add(togglePolicy, BorderLayout.PAGE_START);
    bottomPanel.add(label, BorderLayout.PAGE_END);

    add(leftTextPanel, BorderLayout.LINE_START);
    add(rightTextPanel, BorderLayout.CENTER);
    add(tablePanel, BorderLayout.LINE_END);
    add(bottomPanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:com.sshtools.sshterm.SshTermCommandTab.java

/**
 * Creates a new SshToolsConnectionCommandTab object.
 *//*from   w  ww.ja  v  a 2 s  .  c o  m*/
public SshTermCommandTab() {
    super();

    JPanel main = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);

    Insets ins2 = new Insets(2, 24, 2, 2);
    gbc.weightx = 1.0;
    requestPseudoTerminal.getModel().setSelected(false);
    disconnectOnSessionClose.getModel().setSelected(true);
    UIUtil.jGridBagAdd(main, requestPseudoTerminal, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, disconnectOnSessionClose, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, new JSeparator(JSeparator.HORIZONTAL), gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, onceAuthenticated, gbc, GridBagConstraints.REMAINDER);
    group.add(doNothing);
    group.add(startShell);
    group.add(executeCommands);
    startShell.setSelected(true);
    UIUtil.jGridBagAdd(main, doNothing, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, startShell, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, executeCommands, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = ins2;
    gbc.weighty = 1.0;

    //commands.setLineWrap(true);
    commands.setBorder(BorderFactory.createEtchedBorder());

    JScrollPane scroll = new JScrollPane(commands);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    UIUtil.jGridBagAdd(main, scroll, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(COMMANDS_ICON), main);
    commands.setRows(8);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:ui.results.ResultChartPanel.java

/**
 * Construct new Result panel/*from  ww  w. j ava 2  s .c  om*/
 */
public ResultChartPanel() {
    // The charting objects
    dataset = new DefaultStatisticalCategoryDataset();
    upper = new DefaultCategoryDataset();
    lower = new DefaultCategoryDataset();

    // The Renderers
    lineRenderer0 = new LineAndShapeRenderer();
    lineRenderer1 = new LineAndShapeRenderer();
    lineRenderer2 = new LineAndShapeRenderer();
    lineRenderer0.setSeriesPaint(0, lowerColor);
    lineRenderer1.setSeriesPaint(0, mspColor);
    lineRenderer2.setSeriesPaint(0, upperColor);
    lineRenderer0.setSeriesShapesVisible(0, false);
    lineRenderer1.setSeriesShapesVisible(0, false);
    lineRenderer2.setSeriesShapesVisible(0, false);

    barRenderer = new StatisticalBarRenderer();
    barRenderer.setSeriesPaint(0, mspColor);

    // The Plot: begin as a line plot
    CategoryPlot plot = new CategoryPlot();
    plot.setDomainAxis(new CategoryAxis("Datasets"));
    plot.setRangeAxis(new NumberAxis("MSP"));
    plot.setRenderer(0, lineRenderer0);
    plot.setRenderer(1, lineRenderer1);
    plot.setRenderer(2, lineRenderer2);
    plot.setDataset(0, lower);
    plot.setDataset(1, dataset);
    plot.setDataset(2, upper);

    // Adding the new plot
    chart = new JFreeChart(plot);
    panel = new ChartPanel(chart);

    // Listening to changes
    //dataset.addChangeListener(chart.getPlot());
    chart.getPlot().addChangeListener(chart);
    chart.addChangeListener(panel);

    ((CategoryPlot) chart.getPlot()).getRangeAxis().setAutoRange(true);

    // Choice panel: choicing between line and bar chart
    JPanel choicePanel = createChoicePanel();

    // Doing the interface
    setLayout(new BorderLayout());
    add(choicePanel, BorderLayout.NORTH);
    add(panel, BorderLayout.CENTER);
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Chart"));

    // size stuff
    //setPreferredSize(new Dimension(500, 400));
}

From source file:net.sf.jabref.gui.preftabs.PreferencesDialog.java

public PreferencesDialog(JabRefFrame parent) {
    super(parent, Localization.lang("JabRef preferences"), false);
    JabRefPreferences prefs = JabRefPreferences.getInstance();
    frame = parent;/* ww  w .  j av a2 s.  c  om*/

    main = new JPanel();
    JPanel mainPanel = new JPanel();
    JPanel lower = new JPanel();

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(lower, BorderLayout.SOUTH);

    final CardLayout cardLayout = new CardLayout();
    main.setLayout(cardLayout);

    List<PrefsTab> tabs = new ArrayList<>();
    tabs.add(new GeneralTab(prefs));
    tabs.add(new NetworkTab(prefs));
    tabs.add(new FileTab(frame, prefs));
    tabs.add(new FileSortTab(prefs));
    tabs.add(new EntryEditorPrefsTab(frame, prefs));
    tabs.add(new GroupsPrefsTab(prefs));
    tabs.add(new AppearancePrefsTab(prefs));
    tabs.add(new ExternalTab(frame, this, prefs));
    tabs.add(new TablePrefsTab(prefs));
    tabs.add(new TableColumnsTab(prefs, parent));
    tabs.add(new LabelPatternPrefTab(prefs, parent.getCurrentBasePanel()));
    tabs.add(new PreviewPrefsTab(prefs));
    tabs.add(new NameFormatterTab(prefs));
    tabs.add(new ImportSettingsTab(prefs));
    tabs.add(new XmpPrefsTab(prefs));
    tabs.add(new AdvancedTab(prefs));

    // add all tabs
    tabs.forEach(tab -> main.add((Component) tab, tab.getTabName()));

    mainPanel.setBorder(BorderFactory.createEtchedBorder());

    String[] tabNames = tabs.stream().map(PrefsTab::getTabName).toArray(String[]::new);
    JList<String> chooser = new JList<>(tabNames);
    chooser.setBorder(BorderFactory.createEtchedBorder());
    // Set a prototype value to control the width of the list:
    chooser.setPrototypeCellValue("This should be wide enough");
    chooser.setSelectedIndex(0);
    chooser.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Add the selection listener that will show the correct panel when
    // selection changes:
    chooser.addListSelectionListener(e -> {
        if (e.getValueIsAdjusting()) {
            return;
        }
        String o = chooser.getSelectedValue();
        cardLayout.show(main, o);
    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new GridLayout(4, 1));
    buttons.add(importPreferences, 0);
    buttons.add(exportPreferences, 1);
    buttons.add(showPreferences, 2);
    buttons.add(resetPreferences, 3);

    JPanel westPanel = new JPanel();
    westPanel.setLayout(new BorderLayout());
    westPanel.add(chooser, BorderLayout.CENTER);
    westPanel.add(buttons, BorderLayout.SOUTH);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(main, BorderLayout.CENTER);
    mainPanel.add(westPanel, BorderLayout.WEST);

    JButton ok = new JButton(Localization.lang("OK"));
    JButton cancel = new JButton(Localization.lang("Cancel"));
    ok.addActionListener(new OkAction());
    CancelAction cancelAction = new CancelAction();
    cancel.addActionListener(cancelAction);
    lower.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(lower);
    buttonBarBuilder.addGlue();
    buttonBarBuilder.addButton(ok);
    buttonBarBuilder.addButton(cancel);
    buttonBarBuilder.addGlue();

    // Key bindings:
    KeyBinder.bindCloseDialogKeyToCancelAction(this.getRootPane(), cancelAction);

    // Import and export actions:
    exportPreferences.setToolTipText(Localization.lang("Export preferences to file"));
    exportPreferences.addActionListener(e -> {
        String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")),
                Collections.singletonList(".xml"), JFileChooser.SAVE_DIALOG, false);
        if (filename == null) {
            return;
        }
        File file = new File(filename);
        if (!file.exists() || (JOptionPane.showConfirmDialog(PreferencesDialog.this,
                Localization.lang("'%0' exists. Overwrite file?", file.getName()),
                Localization.lang("Export preferences"),
                JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)) {

            try {
                prefs.exportPreferences(filename);
            } catch (JabRefException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Export preferences"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    importPreferences.setToolTipText(Localization.lang("Import preferences from file"));
    importPreferences.addActionListener(e -> {
        String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")),
                Collections.singletonList(".xml"), JFileChooser.OPEN_DIALOG, false);
        if (filename != null) {
            try {
                prefs.importPreferences(filename);
                updateAfterPreferenceChanges();
                JOptionPane.showMessageDialog(PreferencesDialog.this,
                        Localization.lang("You must restart JabRef for this to come into effect."),
                        Localization.lang("Import preferences"), JOptionPane.WARNING_MESSAGE);
            } catch (JabRefException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Import preferences"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    showPreferences.addActionListener(
            e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame)
                    .setVisible(true));
    resetPreferences.addActionListener(e -> {
        if (JOptionPane.showConfirmDialog(PreferencesDialog.this,
                Localization.lang("Are you sure you want to reset all settings to default values?"),
                Localization.lang("Reset preferences"),
                JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
            try {
                prefs.clear();
                JOptionPane.showMessageDialog(PreferencesDialog.this,
                        Localization.lang("You must restart JabRef for this to come into effect."),
                        Localization.lang("Reset preferences"), JOptionPane.WARNING_MESSAGE);
            } catch (BackingStoreException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Reset preferences"), JOptionPane.ERROR_MESSAGE);
            }
            updateAfterPreferenceChanges();
        }
    });

    setValues();

    pack();

}

From source file:Cal.java

/** Build the GUI. Assumes that setYYMMDD has been called. */
private void buildGUI() {
    getAccessibleContext().setAccessibleDescription("Calendar not accessible yet. Sorry!");
    setBorder(BorderFactory.createEtchedBorder());

    setLayout(new BorderLayout());

    JPanel tp = new JPanel();
    tp.add(monthChoice = new JComboBox());
    for (int i = 0; i < months.length; i++)
        monthChoice.addItem(months[i]);//from www .j a  va 2s. com
    monthChoice.setSelectedItem(months[mm]);
    monthChoice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int i = monthChoice.getSelectedIndex();
            if (i >= 0) {
                mm = i;
                // System.out.println("Month=" + mm);
                recompute();
            }
        }
    });
    monthChoice.getAccessibleContext().setAccessibleName("Months");
    monthChoice.getAccessibleContext().setAccessibleDescription("Choose a month of the year");

    tp.add(yearChoice = new JComboBox());
    yearChoice.setEditable(true);
    for (int i = yy - 5; i < yy + 5; i++)
        yearChoice.addItem(Integer.toString(i));
    yearChoice.setSelectedItem(Integer.toString(yy));
    yearChoice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int i = yearChoice.getSelectedIndex();
            if (i >= 0) {
                yy = Integer.parseInt(yearChoice.getSelectedItem().toString());
                // System.out.println("Year=" + yy);
                recompute();
            }
        }
    });
    add(BorderLayout.CENTER, tp);

    JPanel bp = new JPanel();
    bp.setLayout(new GridLayout(7, 7));
    labs = new JButton[6][7]; // first row is days

    bp.add(b0 = new JButton("S"));
    bp.add(new JButton("M"));
    bp.add(new JButton("T"));
    bp.add(new JButton("W"));
    bp.add(new JButton("R"));
    bp.add(new JButton("F"));
    bp.add(new JButton("S"));

    ActionListener dateSetter = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String num = e.getActionCommand();
            if (!num.equals("")) {
                // set the current day highlighted
                setDayActive(Integer.parseInt(num));
                // When this becomes a Bean, you can
                // fire some kind of DateChanged event here.
                // Also, build a similar daySetter for day-of-week btns.
            }
        }
    };

    // Construct all the buttons, and add them.
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 7; j++) {
            bp.add(labs[i][j] = new JButton(""));
            labs[i][j].addActionListener(dateSetter);
        }

    add(BorderLayout.SOUTH, bp);
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java

JPanel createMoviehitsList() {
    /* Movies List panel...*/
    JPanel panelMoviesList = new JPanel();
    panelMoviesList.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                    Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    listMovies = new JList() {

        public String getToolTipText(MouseEvent e) {

            if (getCellBounds(0, 0) == null)
                return null;

            String retVal = null;

            int row = (int) e.getPoint().getY() / (int) getCellBounds(0, 0).getHeight();

            if (row >= 0 && row < getModel().getSize()
                    && getMoviesList().getModel().getElementAt(row) instanceof ModelIMDbSearchHit) {
                retVal = ((ModelIMDbSearchHit) getMoviesList().getModel().getElementAt(row)).getAka();

                if (retVal != null && retVal.trim().equals("")) //$NON-NLS-1$
                    retVal = null;//from  w w  w .j  a  va2s  . c om
            }

            return retVal;
        }

        public JToolTip createToolTip() {
            JMultiLineToolTip tooltip = new JMultiLineToolTip();
            tooltip.setComponent(this);
            return tooltip;
        }
    };

    // Unfortunately setting tooltip timeout affects ALL tooltips
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.registerComponent(listMovies);
    ttm.setInitialDelay(0);
    ttm.setReshowDelay(0);

    listMovies.setFixedCellHeight(18);

    listMovies.setFont(new Font(listMovies.getFont().getName(), Font.PLAIN, listMovies.getFont().getSize()));
    listMovies.setLayoutOrientation(JList.VERTICAL);
    listMovies.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listMovies.setCellRenderer(new MovieHitListCellRenderer());

    listMovies.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {

            // Open we page
            if (SwingUtilities.isRightMouseButton(event)) {

                int index = listMovies.locationToIndex(event.getPoint());

                if (index >= 0) {
                    ModelIMDbSearchHit hit = (ModelIMDbSearchHit) listMovies.getModel().getElementAt(index);

                    if (hit.getUrlID() != null && !hit.getUrlID().equals("")) {
                        BrowserOpener opener = new BrowserOpener(hit.getCompleteUrl());
                        opener.executeOpenBrowser(MovieManager.getConfig().getSystemWebBrowser(),
                                MovieManager.getConfig().getBrowserPath());
                    }
                }
            } else if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() >= 2) {
                buttonSelect.doClick();
            }
        }
    });

    KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
    ActionListener listKeyBoardActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            log.debug("ActionPerformed: " + "Movielist - ENTER pressed."); //$NON-NLS-1$
            buttonSelect.doClick();
        }
    };
    listMovies.registerKeyboardAction(listKeyBoardActionListener, enterKeyStroke, JComponent.WHEN_FOCUSED);

    JScrollPane scrollPaneMovies = new JScrollPane(listMovies);
    scrollPaneMovies.setAutoscrolls(true);
    //scrollPaneMovies.registerKeyboardAction(listKeyBoardActionListener,enterKeyStroke, JComponent.WHEN_FOCUSED);

    panelMoviesList.setLayout(new BorderLayout());
    panelMoviesList.add(scrollPaneMovies, BorderLayout.CENTER);

    return panelMoviesList;
}

From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java

private void start() throws Exception {
    SwingUtilities.invokeLater(() -> {
        jd = new ViewerParameterDialog("Launch Android App");

        JPanel jpParameters = new JPanel();
        jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS));
        jd.setParameterPanel(jpParameters);
        {/*from w  ww.jav a 2 s  . com*/
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Devices"));
            jp.add(jcbDevices);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("App Package Name"));
            jp.add(jtfApp);
            if (StringUtils.isNotEmpty(appPackageName)) {
                jtfApp.setText(appPackageName);
            }

            jtfApp.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                        jbLaunch.doClick();
                    }
                }
            });
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Interaction time (minute)"));
            jsDebugMinutes.getEditor().setEnabled(false);
            jp.add(jsDebugMinutes);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(Box.createRigidArea(new Dimension(518, 2)));
        }

        JPanel jpAction = new JPanel();
        jd.setActionPanel(jpAction);
        jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD));
        jbLaunch.setBorder(BorderFactory.createEtchedBorder());
        jbLaunch.setEnabled(false);
        jpAction.add(jbLaunch);
        jbLaunch.addActionListener(event -> {
            new Thread() {
                @Override
                public void run() {
                    launchApp();
                }
            }.start();
        });

        jd.showDialog();

        new Thread() {
            @Override
            public void run() {
                try {
                    detectDevices();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }.start();
    });
}