Example usage for javax.swing JComponent setBorder

List of usage examples for javax.swing JComponent setBorder

Introduction

In this page you can find the example usage for javax.swing JComponent 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:greenfoot.gui.export.ExportPublishPane.java

/**
 * Creates a login panel with a username and password and a create account option
 * @return Login panel Component/*from w  w w .  j a  v a 2  s  .  com*/
 */
private JComponent getLoginPanel() {
    JComponent loginPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 8, 4));

    loginPanel.setBackground(background);
    loginPanel.setAlignmentX(LEFT_ALIGNMENT);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(12, 12, 12, 12));
    loginPanel.setBorder(border);

    JLabel text = new JLabel(Config.getString("export.publish.login"));
    text.setForeground(headingColor);
    text.setVerticalAlignment(SwingConstants.TOP);
    loginPanel.add(text);

    text = new JLabel(Config.getString("export.publish.username"), SwingConstants.TRAILING);
    text.setFont(font);
    loginPanel.add(text);
    userNameField = new JTextField(10);
    userNameField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            String text = userNameField.getText();
            return text.length() > 0;
        }
    });
    userNameField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            checkForExistingScenario();
        }
    });
    loginPanel.add(userNameField);
    text = new JLabel(Config.getString("export.publish.password"), SwingConstants.TRAILING);
    text.setFont(font);
    loginPanel.add(text);
    passwordField = new JPasswordField(10);
    loginPanel.add(passwordField);

    JLabel createAccountLabel = new JLabel(Config.getString("export.publish.createAccount"));
    {
        createAccountLabel.setBackground(background);

        createAccountLabel.setHorizontalAlignment(SwingConstants.RIGHT);
        GreenfootUtil.makeLink(createAccountLabel, createAccountUrl);
    }
    loginPanel.add(createAccountLabel);
    return loginPanel;
}

From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java

private void initLayout() {
    Container content = this.getContentPane();
    JComponent controls = Box.createVerticalBox();
    {//w w  w.  j  a  v a2  s.  c  o m
        JPanel filePanel = new JPanel(new BorderLayout());
        {
            filePanel.setBorder(BorderFactory.createTitledBorder("Stock Market Trading Data"));
            JPanel dataButtons = new JPanel(new GridLayout(2, 1));
            {
                dataButtons.add(this.loadFileButton);
                dataButtons.add(this.viewDataButton);
            }
            filePanel.add(dataButtons, BorderLayout.EAST);
            JPanel fileControls = new JPanel(new FlowLayout());
            {
                fileControls.add(new JLabel("Stock data File:"));
                fileControls.add(this.fileField);
                fileControls.add(this.fileBrowseButton);
                fileControls.add(new JLabel("  Stock data format:"));
                fileControls.add(this.fileFormatCombo);
            }
            filePanel.add(fileControls, BorderLayout.CENTER);
        }
        controls.add(filePanel);
        JComponent simPanel = new JPanel(new BorderLayout());
        {
            simPanel.setBorder(BorderFactory.createTitledBorder("Simulation Run"));
            simPanel.add(this.runButton, BorderLayout.EAST);
            JComponent simControlsPanel = Box.createVerticalBox();
            {
                JPanel accountControls = new JPanel(new FlowLayout());
                {
                    accountControls.add(new JLabel("Initial Cash:"));
                    accountControls.add(this.initialCashField);
                    accountControls.add(new JLabel("  Per Trade Fee:"));
                    accountControls.add(this.perTradeFeeField);
                    accountControls.add(new JLabel("  Per Share Trade Commission:"));
                    accountControls.add(this.perShareTradeCommissionField);
                    accountControls.add(new JLabel("  Compare:"));
                    accountControls.add(this.compareIndexSymbolField);
                }
                simControlsPanel.add(accountControls);
                JPanel runControls = new JPanel(new FlowLayout());
                {
                    runControls.add(this.strategyField);
                    runControls.add(new JLabel("Start Date:"));
                    runControls.add(this.startDateField);
                    runControls.add(new JLabel("  End Date:"));
                    runControls.add(this.endDateField);
                    runControls.add(new JLabel("  Strategy:"));
                    runControls.add(this.strategyField);
                    runControls.add(this.editButton);
                    runControls.add(this.compileButton);
                }
                simControlsPanel.add(runControls);
            }
            simPanel.add(simControlsPanel, BorderLayout.CENTER);
        }
        controls.add(simPanel);
    }
    content.add(controls, BorderLayout.NORTH);
    JSplitPane vSplit = this.vSplit;
    {
        vSplit.setResizeWeight(0.5);
        vSplit.add(this.chartPanel, JSplitPane.TOP);
        JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        {
            hSplit.setResizeWeight(0.5); // enough for no hscrollbar in 1024 width
            JSplitPane reportSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
            {
                reportSplit.setResizeWeight(0.5);
                JScrollPane reportScroll = new JScrollPane(this.reportArea);
                {
                    reportScroll.setBorder(BorderFactory.createTitledBorder("Report"));
                }
                reportSplit.add(reportScroll, JSplitPane.TOP);
                JScrollPane monthScroll = new JScrollPane(this.monthlyLogArea);
                {
                    monthScroll.setBorder(BorderFactory.createTitledBorder("Monthly Log"));
                }
                reportSplit.add(monthScroll, JSplitPane.BOTTOM);
            }
            hSplit.add(reportSplit, JSplitPane.LEFT);
            JScrollPane tradeScroll = new JScrollPane(this.tradeLogArea);
            {
                tradeScroll.setBorder(BorderFactory.createTitledBorder("Trade Log"));
            }
            hSplit.add(tradeScroll, JSplitPane.RIGHT);
        }
        vSplit.add(hSplit, JSplitPane.BOTTOM);
    }
    content.add(vSplit, BorderLayout.CENTER);
}

From source file:brainflow.app.toplevel.BrainFlow.java

public void addCanvas(IBrainCanvas canvas) {
    //todo sync with DisplayManager?
    JComponent comp = canvas.getComponent();
    comp.setRequestFocusEnabled(true);//  www  .  j  a  va 2 s  .  co m
    comp.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    BrainCanvasTransferHandler handler = new BrainCanvasTransferHandler();
    comp.setTransferHandler(handler);
    CanvasBar cbar = new CanvasBar();

    canvas.getComponent().add(cbar.getComponent(), BorderLayout.NORTH);
    String canvasName = "Canvas-" + (documentPane.getDocumentCount() + 1);
    documentPane.openDocument(createCanvasDocument(canvas, canvasName));
    documentPane.setActiveDocument(canvasName);
    DisplayManager.get().setSelectedCanvas(canvas);

}

From source file:brainflow.app.toplevel.BrainFlow.java

private void initializeWorkspace() throws Exception {
    StopWatch watch = new StopWatch();

    watch.start("laying out workspace");
    log.info("initializing workspace");

    //_frame.getDockableBarManager().getMainContainer().setLayout(new BorderLayout());
    //_frame.getDockableBarManager().getMainContainer().add(_tabbedPane, BorderLayout.CENTER);

    //brainFrame.getMainPanel().add(documentPane, BorderLayout.CENTER);
    brainFrame.getDockingManager().getWorkspace().setLayout(new BorderLayout());
    brainFrame.getDockingManager().getWorkspace().add(documentPane, BorderLayout.CENTER);

    brainFrame.getDockingManager().beginLoadLayoutData();
    brainFrame.getDockingManager().setInitSplitPriority(DefaultDockingManager.SPLIT_EAST_WEST_SOUTH_NORTH);

    JComponent canvas = DisplayManager.get().getSelectedCanvas().getComponent();
    canvas.setRequestFocusEnabled(true);
    canvas.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    watch.stopAndReport("laying out workspace");
    watch.start("opening document");
    documentPane.setTabPlacement(DocumentPane.BOTTOM);
    documentPane.openDocument(createCanvasDocument(DisplayManager.get().getSelectedCanvas(), "Canvas-1"));
    documentPane.setActiveDocument("Canvas-1");
    watch.stopAndReport("opening document");

    log.info("initializing loading dock");
    watch.start("init loading dock");
    initLoadingDock();/*from  www .java 2 s . com*/
    watch.stopAndReport("init loading dock");
    log.info("initializing project view");
    watch.start("init project view");
    initProjectView();
    watch.stopAndReport("init project view");
    log.info("initializing image table view");
    watch.start("init ploadable image table view");
    initLoadableImageTableView();
    watch.stopAndReport("init ploadable image table view");
    log.info("initializing control panel");
    watch.start("init control panel");
    initControlPanel();
    initCoordinatePanel();
    watch.stopAndReport("init control panel");
    log.info("initializing event monitor");
    watch.start("event bus monitor");
    initEventBusMonitor();
    log.info("initializing log monitor");
    watch.stopAndReport("event bus monitor");

    watch.start("log monitor");
    initLogMonitor();
    watch.stopAndReport("log monitor");

    watch.start("layout docks");

    brainFrame.getDockableBarManager().loadLayoutData();
    // brainFrame.toFront();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    brainFrame.setSize((int) screenSize.getWidth(), (int) screenSize.getHeight() - 50);

    watch.stopAndReport("layout docks");

    watch.start("canvas bar");
    CanvasBar cbar = new CanvasBar();
    canvas.add(cbar.getComponent(), BorderLayout.NORTH);
    watch.stopAndReport("canvas bar");

    brainFrame.getDockingManager().loadLayoutData();

}

From source file:com.diversityarrays.kdxplore.curate.SampleEntryPanel.java

private JPanel generateStatControls() {

    JPanel statsPanel = new JPanel();
    GBH gbh = new GBH(statsPanel);

    int x = 0;/*w  w w .  j a  v a2 s.  com*/

    for (StatType statType : StatType.values()) {
        JButton button = new JButton(statType.label);
        button.addActionListener(statButtonActionListener);

        statButtonByStatType.put(statType, button);

        JComponent valueLabel = null;
        if (statType == StatType.MODE) {
            JComboBox<String> combo = new JComboBox<String>();
            combo.addActionListener(statButtonActionListener);

            valueLabel = combo;
            valueLabel.setMaximumSize(new Dimension(100, 25));
        } else {
            JButton btn = new JButton();
            btn.addActionListener(statButtonActionListener);

            valueLabel = btn;
        }
        statComponentByStatType.put(statType, valueLabel);
        statTypeByButton.put(valueLabel, statType);

        Font myFont = new Font(Font.SANS_SERIF, Font.BOLD, 10);
        TitledBorder roundedTitledBorder = new TitledBorder(BorderFactory.createRaisedBevelBorder(),
                statType.name(), 1, 2, myFont);

        valueLabel.setBorder(roundedTitledBorder);

        gbh.add(x, 0, 1, 1, GBH.BOTH, 2, 3, GBH.CENTER, valueLabel);
        x++;
    }
    return statsPanel;
}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

/**
 * Sets a border on the component as defined in the properties.
 * @param comp the component//  w  w w .  ja v a 2s .c o m
 * @param props the list of properties
 */
protected void setBorder(final JComponent comp, final Properties props) {
    if (props != null) {
        String borderType = props.getProperty("border");
        if (StringUtils.isNotEmpty(borderType)) {
            if (borderType.equals("etched")) {
                comp.setBorder(BorderFactory.createEtchedBorder());

            } else if (borderType.equals("lowered")) {
                comp.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

            } else if (borderType.equals("raised")) {
                comp.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

            } else if (borderType.equals("empty")) {
                comp.setBorder(BorderFactory.createEmptyBorder());

            } else if (borderType.equals("line")) {
                Color color = Color.LIGHT_GRAY;
                String borderColor = props.getProperty("bordercolor");
                if (StringUtils.isNotEmpty(borderColor)) {
                    try {
                        color = UIHelper.parseRGB(borderColor);

                    } catch (ConfigurationException ex) {
                        log.error(ex);
                    }
                }
                comp.setBorder(BorderFactory.createLineBorder(color));
            }
        }
    }
}

From source file:forge.toolbox.FSkin.java

public static void setTempBorder(final JComponent comp, final SkinBorder skinBorder) {
    comp.setBorder(skinBorder.createBorder());
}

From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java

/**
 * @param e//  ww  w  .ja va  2 s .  c  o  m
 * @param b
 * @return true if a form was effectively rendered, i.e. when at least 1
 *         parameter was available
 */
@SuppressWarnings("unchecked")
private boolean renderCompositeModelComponent(final CompositeActor e, final JPanel b) {
    if (logger.isDebugEnabled()) {
        logger.debug("renderCompositeModelComponent() - Entity " + e.getFullName()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    final IPasserelleEditorPaneFactory epf = getEditorPaneFactoryForComponent(e);
    final IPasserelleQuery pQuery = epf.createEditorPaneWithAuthorizer(e, this, this);
    final JComponent c = (JComponent) pQuery.getPasserelleComponent();

    if (pQuery != null) {
        boolean nonEmptyForm = !(pQuery instanceof PasserelleEmptyQuery);
        // remove the default message in an empty query
        if (!nonEmptyForm) {
            ((PasserelleEmptyQuery) pQuery).setText("");
        } else if (!pQuery.hasAutoSync()) {
            try {
                final Set<ParameterToWidgetBinder> queryBindings = pQuery.getParameterBindings();
                for (final ParameterToWidgetBinder parameterToWidgetBinder : queryBindings) {
                    hmiFields.put(parameterToWidgetBinder.getBoundParameter().getFullName(),
                            parameterToWidgetBinder);
                }
            } catch (final Exception exception) {
                throw new RuntimeException("Error creating bindings for passerelleQuery", exception);
            }
        }

        final String name = ModelUtils.getFullNameButWithoutModelName(getCurrentModel(), e);
        final List subActors = e.entityList();
        // TODO: && changed by || because was not displaying parameters for
        // composite
        // still a problem of display with multiactor
        if (pQuery instanceof PasserelleQuery || !subActors.isEmpty()) {
            final JPanel compositeBox = createCompositePanel(b, c, name);
            renderModelComponentAnnotations(e, compositeBox);
            for (final Iterator<NamedObj> subActorItr = subActors.iterator(); subActorItr.hasNext();) {
                final NamedObj subActor = subActorItr.next();
                nonEmptyForm |= renderModelComponent(true, subActor, compositeBox);
            }
            if (nonEmptyForm) {
                b.add(compositeBox);
                StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, name, c);
                StateMachine.getInstance().compile();
            }
            return nonEmptyForm;
        } else if (!(pQuery instanceof PasserelleEmptyQuery)) {
            // System.out.println("else name" + name);
            c.setName(name);
            c.setBorder(BorderFactory.createTitledBorder(name));
            b.add(c);
            StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, name, c);
            StateMachine.getInstance().compile();
            return true;
        }
    }
    // System.out.println("renderComposite - out");
    return false;
}

From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java

private void setBorder(JComponent source, AWTEvent event) {
    Border border = source.getBorder();
    switch (event.getID()) {
    case MouseEvent.MOUSE_ENTERED:
        if (border != null) {
            source.setBorder(new DebugBorder(border));
        }/* w  w  w. j a v a  2s  .co m*/
        break;
    case MouseEvent.MOUSE_EXITED:
        if (border != null && border instanceof DebugBorder) {
            source.setBorder(((DebugBorder) border).getDelegate());
        }
        break;
    }
}

From source file:nz.ac.massey.cs.gql4jung.browser.ResultBrowser.java

private void addBorder(JComponent c) {
    c.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
}