Example usage for javax.swing BorderFactory createMatteBorder

List of usage examples for javax.swing BorderFactory createMatteBorder

Introduction

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

Prototype

public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Icon tileIcon) 

Source Link

Document

Creates a matte-look border that consists of multiple tiles of a specified icon.

Usage

From source file:org.nuclos.client.ui.collect.Chart.java

private void init(int iScrollPane) {
    contentPane.add(toolbar,//from  www  .  j  a va  2  s . c o m
            toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST);

    // Configure table
    JFreeChart chart = new JFreeChart(new Plot() {

        @Override
        public String getPlotType() {
            return null;
        }

        @Override
        public void draw(Graphics2D arg0, Rectangle2D arg1, Point2D arg2, PlotState arg3,
                PlotRenderingInfo arg4) {
        }
    });

    panel = new ChartPanel(chart, false, false, true, false, false);
    if (bFromProperties) {
        panel.setPopupMenu(null);
    }

    if (iScrollPane == -1)
        scrollPane.add(panel, BorderLayout.CENTER);
    else {
        ((JScrollPane) scrollPane).getViewport().setBackground(panel.getBackground());

        JLabel labCorner = new JLabel();
        labCorner.setEnabled(false);
        labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY));
        labCorner.setBackground(Color.LIGHT_GRAY);
        ((JScrollPane) scrollPane).setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner);

        if (iScrollPane != 2) { //both
            if (iScrollPane == 0) { // horizontal
                JPanel pnl = new ScrollPaneHeightTrackingPanel(new BorderLayout());
                pnl.add(panel, BorderLayout.CENTER);
                ((JScrollPane) scrollPane).getViewport().setView(pnl);
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
                ((JScrollPane) scrollPane)
                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            } else if (iScrollPane == 1) { // vertical
                JPanel pnl = new ScrollPaneWidthTrackingPanel(new BorderLayout());
                pnl.add(panel, BorderLayout.CENTER);
                ((JScrollPane) scrollPane).getViewport().setView(pnl);
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
                ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            } else if (iScrollPane == -1) { // none
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
                ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            }
        } else {
            ((JScrollPane) scrollPane).getViewport().setView(panel);
        }
    }
}

From source file:org.datavyu.controllers.component.TrackController.java

/**
 * Creates a new TrackController./* w w w  . j  a  v  a2  s .c  o m*/
 *
 * @param trackPainter the track painter for this controller to manage.
 */
public TrackController(final MixerModel mixerModel, final TrackPainter trackPainter) {
    isMoveable = true;

    view = new JPanel();
    view.setLayout(new MigLayout("fillx, ins 0", "[]0[]"));
    view.setBorder(BorderFactory.createLineBorder(TrackConstants.BORDER_COLOR, 1));

    this.trackPainter = trackPainter;

    this.mixerModel = mixerModel;
    trackModel = new TrackModel();
    trackModel.setState(TrackState.NORMAL);
    trackModel.clearBookmarks();
    trackModel.setLocked(false);

    trackPainter.setMixerView(mixerModel);
    trackPainter.setTrackModel(trackModel);

    mixerModel.getViewportModel().addPropertyChangeListener(this);

    listenerList = new EventListenerList();

    final TrackPainterListener painterListener = new TrackPainterListener();
    trackPainter.addMouseListener(painterListener);
    trackPainter.addMouseMotionListener(painterListener);

    menu = new JPopupMenu();
    menu.setName("trackPopUpMenu");

    setBookmarkMenuItem = new JMenuItem("Set bookmark");
    setBookmarkMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            TrackController.this.setBookmarkAction();
        }
    });

    clearBookmarkMenuItem = new JMenuItem("Clear bookmarks");
    clearBookmarkMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            TrackController.this.clearBookmarkAction();
        }
    });
    menu.add(setBookmarkMenuItem);
    menu.add(clearBookmarkMenuItem);

    trackPainter.add(menu);

    // Create the Header panel and its components
    trackLabel = new JLabel("", SwingConstants.CENTER);
    trackLabel.setName("trackLabel");
    trackLabel.setHorizontalAlignment(SwingConstants.CENTER);
    trackLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    iconLabel = new JLabel("", SwingConstants.CENTER);
    iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
    iconLabel.setHorizontalTextPosition(SwingConstants.CENTER);

    header = new JPanel(new MigLayout("ins 0, wrap 6"));
    header.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 0, 1, TrackConstants.BORDER_COLOR),
            BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    header.setBackground(Color.LIGHT_GRAY);

    // Normally I would use pushx instead of defining the width, but in this
    // case I defined the width because span combined with push makes the
    // first action icon cell push out as well. 136 was calculated from
    // 140 pixels minus 2 minus 2 (from the empty border defined above).
    header.add(trackLabel, "span 6, w 136!, center, growx");
    header.add(iconLabel, "span 6, w 136!, h 32!, center, growx");

    // Set up the button used for locking/unlocking track movement
    {
        lockUnlockButton = new JButton(TrackConstants.UNLOCK_ICON);
        lockUnlockButton.setName("lockUnlockButton");
        lockUnlockButton.setContentAreaFilled(false);
        lockUnlockButton.setBorderPainted(false);
        lockUnlockButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleLockUnlockButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 0 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(lockUnlockButton, sub.replace(template));
    }

    // Set up the button used for hiding/showing a track's data viewer
    {
        visibleButton = new JButton(TrackConstants.VIEWER_HIDE_ICON);
        visibleButton.setName("visibleButton");
        visibleButton.setContentAreaFilled(false);
        visibleButton.setBorderPainted(false);
        visibleButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleVisibleButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 1 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(visibleButton, sub.replace(template));
    }

    // Set up the button used for removing a track and its plugin
    {
        rubbishButton = new JButton(TrackConstants.DELETE_ICON);
        rubbishButton.setName("rubbishButton");
        rubbishButton.setContentAreaFilled(false);
        rubbishButton.setBorderPainted(false);
        rubbishButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleDeleteButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 5 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(rubbishButton, sub.replace(template));
    }

    // Add the header to our layout.
    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.HEADER_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT));

        String template = "w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        view.add(header, sub.replace(template));
    }

    // Add the track carriage to our layout.
    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT));

        String template = "pushx, growx, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        view.add(trackPainter, sub.replace(template));
    }

    view.validate();
}

From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java

private void setBorder(JLabel tLabel, Color deltaColor) {
    if (deltaColor == null) {
        deltaColor = Color.white;
    }//from  w  w w . j ava2s.  co  m
    Dimension size = tLabel.getSize();
    tLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 5, 1, 5, deltaColor),
                    BorderFactory.createEmptyBorder(1, 3, 1, 3))));
    size.width = size.width + 18;
    size.height = size.height + 6;
    tLabel.setSize(size);
    tLabel.setPreferredSize(size);
    tLabel.setMaximumSize(size);
    tLabel.setMinimumSize(size);
}

From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java

public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration,
        final OpenAnalysisJobActionListener openAnalysisJobActionListener) {
    super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT);
    _file = file;/*from w  ww. j a  v a2  s .  c  o  m*/
    _openAnalysisJobActionListener = openAnalysisJobActionListener;

    setLayout(new BorderLayout());
    setBorder(WidgetUtils.BORDER_LIST_ITEM);

    final AnalysisJobMetadata metadata = getMetadata(configuration);
    final String jobName = metadata.getJobName();
    final String jobDescription = metadata.getJobDescription();
    final String datastoreName = metadata.getDatastoreName();

    final boolean isDemoJob = isDemoJob(metadata);

    final DCPanel labelListPanel = new DCPanel();
    labelListPanel.setLayout(new VerticalLayout(4));
    labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0));

    final String title;
    final String filename = file.getName().getBaseName();
    if (Strings.isNullOrEmpty(jobName)) {
        final String extension = FileFilters.ANALYSIS_XML.getExtension();
        if (filename.toLowerCase().endsWith(extension)) {
            title = filename.substring(0, filename.length() - extension.length());
        } else {
            title = filename;
        }
    } else {
        title = jobName;
    }

    final JButton titleButton = new JButton(title);
    titleButton.setFont(WidgetUtils.FONT_HEADER1);
    titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM);
    titleButton.setHorizontalAlignment(SwingConstants.LEFT);
    titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM));
    titleButton.setToolTipText("Open job");
    titleButton.setOpaque(false);
    titleButton.setMargin(new Insets(0, 0, 0, 0));
    titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titleButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                _openAnalysisJobActionListener.openFile(_file);
            }
        }
    });

    final JButton executeButton = new JButton(executeIcon);
    executeButton.setOpaque(false);
    executeButton.setToolTipText("Execute job directly");
    executeButton.setMargin(new Insets(0, 0, 0, 0));
    executeButton.setBorderPainted(false);
    executeButton.setHorizontalAlignment(SwingConstants.RIGHT);
    executeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE);
                final String question = "Are you sure you want to execute the job\n'" + title + "'?";
                final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?",
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge);
                if (choice == JOptionPane.YES_OPTION) {
                    final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file);
                    if (injector != null) {
                        final ResultWindow resultWindow = injector.getInstance(ResultWindow.class);
                        resultWindow.open();
                        resultWindow.startAnalysis();
                    }
                }
            }
        }
    });

    final DCPanel titlePanel = new DCPanel();
    titlePanel.setLayout(new BorderLayout());
    titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER);
    titlePanel.add(executeButton, BorderLayout.EAST);

    labelListPanel.add(titlePanel);

    if (!Strings.isNullOrEmpty(jobDescription)) {
        String desc = StringUtils.replaceWhitespaces(jobDescription, " ");
        desc = StringUtils.replaceAll(desc, "  ", " ");
        final JLabel label = new JLabel(desc);
        label.setFont(WidgetUtils.FONT_SMALL);
        labelListPanel.add(label);
    }

    final Icon icon;
    {
        if (!StringUtils.isNullOrEmpty(datastoreName)) {
            final JLabel label = new JLabel(" " + datastoreName);
            label.setFont(WidgetUtils.FONT_SMALL);
            labelListPanel.add(label);

            final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName);
            if (isDemoJob) {
                icon = demoBadgeIcon;
            } else {
                icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore);
            }
        } else {
            icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE);
        }
    }

    final JLabel iconLabel = new JLabel(icon);
    iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));

    add(iconLabel, BorderLayout.WEST);
    add(labelListPanel, BorderLayout.CENTER);
}

From source file:org.executequery.gui.editor.QueryEditor.java

private void init() throws Exception {

    // construct the two query text area and results panels
    statusBar = new QueryEditorStatusBar();
    statusBar.setBorder(BorderFactory.createEmptyBorder(0, -1, -2, -2));

    editorPanel = new QueryEditorTextPanel(this);
    resultsPanel = new QueryEditorResultsPanel(this);

    delegate = new QueryEditorDelegate(this);

    popup = new QueryEditorPopupMenu(delegate);
    editorPanel.addEditorPaneMouseListener(popup);

    baseEditorPanel = new JPanel(new BorderLayout());
    baseEditorPanel.add(editorPanel, BorderLayout.CENTER);
    baseEditorPanel.add(statusBar, BorderLayout.SOUTH);
    baseEditorPanel//  w  w w .  j  ava 2s  .  co  m
            .setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, GUIUtilities.getDefaultBorderColour()));

    // add to a base panel - when last tab closed visible set
    // to false on the tab pane and split collapses - want to avoid this
    resultsBase = new JPanel(new BorderLayout());
    resultsBase.add(resultsPanel, BorderLayout.CENTER);

    if (new SplitPaneFactory().usesCustomSplitPane()) {

        splitPane = new EditorSplitPane(JSplitPane.VERTICAL_SPLIT, baseEditorPanel, resultsBase);
    } else {
        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, baseEditorPanel, resultsBase);
    }

    splitPane.setDividerSize(4);
    splitPane.setResizeWeight(0.5);

    // ---------------------------------------
    // the tool bar and conn combo
    toolBar = new QueryEditorToolBar(editorPanel.getTextPaneActionMap(), editorPanel.getTextPaneInputMap());

    Vector<DatabaseConnection> connections = ConnectionManager.getActiveConnections();
    connectionsCombo = new OpenConnectionsComboBox(this, connections);

    maxRowCountCheckBox = new JCheckBox();
    maxRowCountCheckBox.setToolTipText("Enable/disable max records");
    maxRowCountCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            maxRowCountCheckBoxSelected();
        }
    });

    maxRowCountField = new MaxRowCountField(this);

    toolsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridy++;
    gbc.gridx++;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    toolsPanel.add(toolBar, gbc);
    gbc.gridy++;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 7;
    gbc.insets.left = 5;
    gbc.insets.right = 10;
    toolsPanel.add(createLabel("Connection:", 'C'), gbc);
    gbc.gridx++;
    gbc.weightx = 1.0;
    gbc.insets.top = 2;
    gbc.insets.bottom = 2;
    gbc.insets.left = 0;
    gbc.insets.right = 0;
    toolsPanel.add(connectionsCombo, gbc);

    gbc.gridx++;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.insets.top = 7;
    gbc.insets.right = 10;
    gbc.insets.left = 10;
    toolsPanel.add(createLabel("Filter:", 'l'), gbc);
    gbc.gridx++;
    gbc.weightx = 0.8;
    gbc.insets.top = 2;
    gbc.insets.bottom = 2;
    gbc.insets.right = 2;
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.BOTH;
    toolsPanel.add(createResultSetFilterTextField(), gbc);

    gbc.gridx++;
    gbc.weightx = 0;
    gbc.insets.top = 5;
    gbc.insets.left = 10;
    toolsPanel.add(maxRowCountCheckBox, gbc);
    gbc.gridx++;
    gbc.insets.left = 0;
    gbc.insets.top = 7;
    gbc.insets.right = 10;
    toolsPanel.add(createLabel("Max Rows:", 'R'), gbc);
    gbc.gridx++;
    gbc.weightx = 0.3;
    gbc.insets.top = 2;
    gbc.insets.bottom = 2;
    gbc.insets.right = 2;
    gbc.fill = GridBagConstraints.BOTH;
    toolsPanel.add(maxRowCountField, gbc);

    splitPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 3));

    JPanel base = new JPanel(new BorderLayout());
    base.add(toolsPanel, BorderLayout.NORTH);
    base.add(splitPane, BorderLayout.CENTER);

    gbc.gridy = 1;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets.top = 0;
    gbc.insets.bottom = 0;
    gbc.insets.left = 0;
    gbc.insets.right = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    add(base, gbc);

    // register for connection and keyword events
    EventMediator.registerListener(this);

    addDeleteLineActionMapping();

    setEditorPreferences();

    statusBar.setCaretPosition(1, 1);
    statusBar.setInsertionMode("INS");
}

From source file:org.executequery.gui.ExportResultSetPanel.java

private void init() throws Exception {

    fileNameField = WidgetFactory.createTextField();
    connectionsCombo = WidgetFactory.createComboBox();

    String[] delims = { "|", ",", ";", "#" };
    delimiterCombo = WidgetFactory.createComboBox(delims);
    delimiterCombo.setEditable(true);/* ww w  . j av  a 2s.co  m*/

    combosGroup = new TableSelectionCombosGroup(connectionsCombo);

    includeColumNamesCheck = new JCheckBox("Include column names as first row");

    sqlText = new SimpleSqlTextPanel();
    //        sqlText.getTextPane().setBackground(Color.WHITE);
    sqlText.setBorder(null);
    sqlText.setScrollPaneBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, UIUtils.getDefaultBorderColour()));

    statusBar = new SqlTextPaneStatusBar();
    JPanel sqlPanel = new JPanel(new BorderLayout());
    sqlPanel.add(sqlText, BorderLayout.CENTER);
    sqlPanel.add(statusBar, BorderLayout.SOUTH);
    statusBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));

    outputPanel = new LoggingOutputPanel();
    FlatSplitPane splitPane = new FlatSplitPane(JSplitPane.VERTICAL_SPLIT, sqlPanel, outputPanel);
    splitPane.setResizeWeight(0.5);
    splitPane.setDividerLocation(0.8);
    splitPane.setDividerSize(5);

    JButton button = WidgetFactory.createInlineFieldButton("Browse");
    button.setActionCommand("browse");
    button.addActionListener(this);
    button.setMnemonic('r');

    JPanel mainPanel = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridheight = 1;
    gbc.insets.top = 5;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    gbc.insets.left = 5;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    mainPanel.add(new JLabel("Connection:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(connectionsCombo, gbc);
    gbc.insets.left = 5;
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    mainPanel.add(new JLabel("Data Delimiter:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(delimiterCombo, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 2;
    mainPanel.add(new JLabel("Output File:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(fileNameField, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(button, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets.top = 2;
    gbc.insets.left = 5;
    mainPanel.add(includeColumNamesCheck, gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    mainPanel.add(new JLabel(instructionNote()), gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.insets.top = 0;
    gbc.insets.left = 5;
    gbc.insets.bottom = 5;
    gbc.fill = GridBagConstraints.BOTH;
    mainPanel.add(splitPane, gbc);

    mainPanel.setBorder(BorderFactory.createEtchedBorder());

    int minimumButtonWidth = 85;
    executeButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Execute", "executeAndExport");
    stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop");
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5));
    buttonPanel.add(executeButton);
    buttonPanel.add(stopButton);

    stopButton.setEnabled(false);

    add(mainPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    // register as a keyword and connection listener
    EventMediator.registerListener(this);

    JTextPane textPane = sqlText.getTextPane();
    ActionMap actionMap = textPane.getActionMap();

    String actionKey = "executeQueryAction";
    actionMap.put(actionKey, executeQueryAction);

    InputMap inputMap = textPane.getInputMap();
    inputMap.put(EXECUTE_KEYSTROKE, actionKey);

    JPopupMenu popupMenu = sqlText.getPopup();
    popupMenu.addSeparator();
    popupMenu.add(executeQueryAction);
}

From source file:org.mbs3.juniuploader.gui.pnlSettings.java

private void initGUI() {
    try {//from w  ww  .  j  av a  2s.com
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0 };
        thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 };
        thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 };
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(659, 349));
        {
            {
                grpMain = new ButtonGroup();
            }
            {
                grpGUI = new ButtonGroup();
            }
            {
                grpObjects = new ButtonGroup();
            }
            {
                grpHTTP = new ButtonGroup();
            }
            {
            }
            {
            }
            lblGUI = new JLabel();
            this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblGUI.setText("Graphical Interface");
        }
        {
            lblMain = new JLabel();
            this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblMain.setText("Main Program");
        }
        {
            lblObj = new JLabel();
            this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblObj.setText("Object Messages");
        }
        {
            lblLObj = new JLabel();
            this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblLObj.setText("HTTP Messages");
        }
        {
            lblFatal = new JLabel();
            this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblFatal.setText("Fatal Messages");
        }
        {
            lblError = new JLabel();
            this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblError.setText("Errors");
        }
        {
            lblWarn = new JLabel();
            this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblWarn.setText("Warnings");
        }
        {
            lblInfo = new JLabel();
            this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblInfo.setText("Info Messages");
        }
        {
            lblDebug = new JLabel();
            this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblDebug.setText("Debug Messages");
        }
        {
            lblTrace = new JLabel();
            this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblTrace.setText("Trace Execution");
        }
        {
            btnMainFatal = new JRadioButton();
            this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
        grpMain.add(btnMainFatal);
        btnMainFatal.setActionCommand("fatal");
        btnMainFatal.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                logLevelBtnAction(evt);
            }
        });
        {
            btnMainError = new JRadioButton();
            this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainError);
            btnMainError.setActionCommand("error");
            btnMainError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainWarn = new JRadioButton();
            this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainWarn);
            btnMainWarn.setActionCommand("warn");
            btnMainWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainInfo = new JRadioButton();
            this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainInfo);
            btnMainInfo.setActionCommand("info");
            btnMainInfo.setSelected(true);
            btnMainInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainDebug = new JRadioButton();
            this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainDebug);
            btnMainDebug.setActionCommand("debug");
            btnMainDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainTrace = new JRadioButton();
            this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainTrace);
            btnMainTrace.setActionCommand("trace");
            btnMainTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIFatal = new JRadioButton();
            this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIFatal);
            btnGUIFatal.setActionCommand("fatal");
            btnGUIFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIError = new JRadioButton();
            this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIError);
            btnGUIError.setActionCommand("error");
            btnGUIError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIWarn = new JRadioButton();
            this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIWarn);
            btnGUIWarn.setActionCommand("warn");
            btnGUIWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIInfo = new JRadioButton();
            this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIInfo);
            btnGUIInfo.setActionCommand("info");
            btnGUIInfo.setSelected(true);
            btnGUIInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIDebug = new JRadioButton();
            this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIDebug);
            btnGUIDebug.setActionCommand("debug");
            btnGUIDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUITrace = new JRadioButton();
            this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUITrace);
            btnGUITrace.setActionCommand("trace");
            btnGUITrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjFatal = new JRadioButton();
            this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjFatal);
            btnObjFatal.setActionCommand("fatal");
            btnObjFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjError = new JRadioButton();
            this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjError);
            btnObjError.setActionCommand("error");
            btnObjError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjWarn = new JRadioButton();
            this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjWarn);
            btnObjWarn.setActionCommand("warn");
            btnObjWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjInfo = new JRadioButton();
            this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjInfo);
            btnObjInfo.setActionCommand("info");
            btnObjInfo.setSelected(true);
            btnObjInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjDebug = new JRadioButton();
            this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjDebug);
            btnObjDebug.setActionCommand("debug");
            btnObjDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjTrace = new JRadioButton();
            this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjTrace);
            btnObjTrace.setActionCommand("trace");
            btnObjTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPFatal = new JRadioButton();
            this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPFatal);
            btnHTTPFatal.setActionCommand("fatal");
            btnHTTPFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPError = new JRadioButton();
            this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPError);
            btnHTTPError.setActionCommand("error");
            btnHTTPError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPWarn = new JRadioButton();
            this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPWarn);
            btnHTTPWarn.setActionCommand("warn");
            btnHTTPWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPInfo = new JRadioButton();
            this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPInfo);
            btnHTTPInfo.setActionCommand("info");
            btnHTTPInfo.setSelected(true);
            btnHTTPInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPDebug = new JRadioButton();
            this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPDebug);
            btnHTTPDebug.setActionCommand("debug");
            btnHTTPDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPTrace = new JRadioButton();
            this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPTrace);
            btnHTTPTrace.setActionCommand("trace");
            btnHTTPTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            lblLogLevel = new JLabel();
            this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblLogLevel.setText("Set the level of logging for different parts of this application:");
        }
        {
            lblDeLF = new JLabel();
            this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblDeLF.setText("Set the look and feel for the GUI of this application:");
        }
        {
            LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
            LookAndFeel lf = UIManager.getLookAndFeel();
            DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel();
            for (int i = 0; i < lfs.length; i++) {
                String n = lfs[i].getName();
                cmbLFModel.addElement(n);
                if (lf.getName().equals(lfs[i].getName()))
                    cmbLFModel.setSelectedItem(n);
            }
            cmbLF = new JComboBox();
            this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            cmbLF.setModel(cmbLFModel);
            cmbLF.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    cmbLFItemStateChanged(evt);
                }
            });
        }
        {
            tfUserAgent = new JTextField(Util.getUserAgent());
            this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            tfUserAgent.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent evt) {
                    tfUserAgentKeyReleased(evt);
                }
            });
        }
        {
            lblUserAgent = new JLabel();
            this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblUserAgent.setText("User Agent");
        }
        {
            btnExport = new JToggleButton();
            this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            btnExport.setText("Export All Settings and Data to File");
            btnExport.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnExportActionPerformed(evt);
                }
            });
        }
        {
            txtWarn = new JTextPane();
            this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            txtWarn.setText(
                    "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run.");
            txtWarn.setEditable(false);
            txtWarn.setBackground(new java.awt.Color(255, 255, 255));
            txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0)));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java

private JPanel createButtonPanel() {
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();

    buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.windowBorder));
    buttonPanel.setOpaque(true);/*w  w  w.j a  v  a  2s  . c o  m*/
    buttonPanel.setBackground(ColorAndFontConstants.MID_BACKGROUND_COLOR);
    buttonPanel.setComponentOrientation(
            ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    Action helpAction;
    if (ComponentOrientation.LEFT_TO_RIGHT == ComponentOrientation
            .getOrientation(controller.getLocaliser().getLocale())) {
        helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_ICON_FILE,
                "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText",
                HelpContentsPanel.HELP_PREFERENCES_URL);
    } else {
        helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE,
                "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText",
                HelpContentsPanel.HELP_PREFERENCES_URL);
    }
    HelpButton helpButton = new HelpButton(helpAction, controller);
    helpButton.setText("");
    helpButton.setToolTipText(controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip"));
    helpButton.setHorizontalAlignment(SwingConstants.LEADING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 0.3;
    constraints.weighty = 0.1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    buttonPanel.add(helpButton, constraints);

    ShowPreferencesSubmitAction submitAction = new ShowPreferencesSubmitAction(this.bitcoinController,
            this.exchangeController, this, ImageLoader.createImageIcon(ImageLoader.PREFERENCES_ICON_FILE),
            mainFrame);
    MultiBitButton submitButton = new MultiBitButton(submitAction, controller);
    buttonPanel.add(submitButton);

    UndoPreferencesChangesSubmitAction undoChangesAction = new UndoPreferencesChangesSubmitAction(controller,
            ImageLoader.createImageIcon(ImageLoader.UNDO_ICON_FILE));
    undoChangesButton = new MultiBitButton(undoChangesAction, controller);

    buttonPanel.add(undoChangesButton);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 0.1;
    constraints.weighty = 1.0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    buttonPanel.add(submitButton, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.weightx = 0.1;
    constraints.weighty = 1.0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    buttonPanel.add(undoChangesButton, constraints);

    JPanel fill1 = new JPanel();
    fill1.setOpaque(false);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.weightx = 200;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(fill1, constraints);

    return buttonPanel;
}

From source file:org.nuclos.client.ui.collect.SubForm.java

private void init() {
    contentPane.add(toolbar,//from   w ww  .  j a va2 s  .  c om
            toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST);

    // Configure table
    scrollPane.getViewport().setBackground(subformtbl.getBackground());
    subformtbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    subformtbl.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //      subformtbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    scrollPane.getViewport().setView(subformtbl);
    JLabel labCorner = new JLabel();
    labCorner.setEnabled(false);
    labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY));
    labCorner.setBackground(Color.LIGHT_GRAY);
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner);

    rowHeader = createTableRowHeader(subformtbl, scrollPane);
    subformtbl.setRowHeaderTable(rowHeader);

    // subformtbl.addMouseListener(newToolbarContextMenuListener(subformtbl, subformtbl));
    addToolbarMouseListener(subformtbl, subformtbl, subformtbl);
    // scrollPane.getViewport().addMouseListener(newToolbarContextMenuListener(scrollPane.getViewport(), subformtbl));
    addToolbarMouseListener(scrollPane.getViewport(), scrollPane.getViewport(), subformtbl);
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.LocationDialog.java

/**
 * Builds a JPanel holding the main action buttons
 * @return The JPanel holding the lower main action buttons.
 *//*from   w w  w.  j  av  a2  s .  c  om*/
private JPanel buildLowerButtonPanel() {
    TableLayout buttonLayout = createTableLayout(TABLE_PREF_FILL_PREF, TABLE_PREF);
    JPanel buttonPanel = new JPanel(buttonLayout);
    buttonPanel.add(closeButton, "0, 0, l, c");
    buttonPanel.add(refreshButton, "1, 0, l, c");
    buttonPanel.add(addButton, "2, 0, r, c");
    JPanel buttonWrapper = wrapInPaddedPanel(buttonPanel, UI_GAP, 0, 0, 0);
    Border border = BorderFactory.createMatteBorder(1, 0, 0, 0, Color.BLACK);
    buttonWrapper.setBorder(border);
    return buttonWrapper;
}