Example usage for javax.swing BorderFactory createEmptyBorder

List of usage examples for javax.swing BorderFactory createEmptyBorder

Introduction

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

Prototype

public static Border createEmptyBorder(int top, int left, int bottom, int right) 

Source Link

Document

Creates an empty border that takes up space but which does no drawing, specifying the width of the top, left, bottom, and right sides.

Usage

From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java

protected JPanel buildFileSelectionSubPanel() {
    final JPanel panel = new JPanel();

    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalGlue());

    JButton openButton = new JButton(resourceBundle.getString("Select_file"));
    openButton.setMnemonic('O');
    openButton.setToolTipText(resourceBundle.getString("ToolTip.Select_file"));
    panel.add(openButton);/*w w w .j  a v  a 2  s. c  om*/
    panel.add(Box.createRigidArea(new Dimension(10, 10)));

    JLabel fileLabel = new ABIFileLabel();
    panel.add(fileLabel);

    // Open button listener.
    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int returnVal = fileChooser.showOpenDialog(appWindow);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                abiFile = fileChooser.getSelectedFile();
                panel.repaint();
                saveButton.setEnabled(true);
            }
        }
    });

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);

    return panel;
}

From source file:edu.ku.brc.specify.config.AgentSearchDialogES.java

/**
 * Creates the Default UI for Lable task
 *
 *///from   w  w w. ja  v  a2 s. c o  m
protected void createUI() {
    searchText = createTextField(30);
    searchBtn = createButton(getResourceString("SEARCH"));
    ActionListener doQuery = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            form.getDataFromUI();

            StringBuilder strBuf = new StringBuilder(128);
            for (String key : formFieldToColumnMap.keySet()) {
                String value = dataMap.get(key);
                if (isNotEmpty(value)) {
                    if (strBuf.length() > 0) {
                        strBuf.append(" OR ");
                    }
                    strBuf.append(formFieldToColumnMap.get(key) + ":" + value);
                }

            }
            searchText.setText(strBuf.toString());
            doQuery();
        }
    };

    searchBtn.addActionListener(doQuery);
    searchText.addActionListener(doQuery);
    searchText.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (searchText.getBackground() != textBGColor) {
                searchText.setBackground(textBGColor);
            }
        }
    });

    String viewName = "test";
    String name = null; // use the default

    formView = AppContextMgr.getInstance().getView(name, viewName);
    if (formView != null) {
        form = ViewFactory.createFormView(null, formView, null, dataMap, MultiView.NO_OPTIONS, null);
        if (form != null) {
            add(form.getUIComponent(), BorderLayout.CENTER);
        } else {
            return;
        }
    } else {
        log.info("Couldn't load form with name [" + name + "] Id [" + viewName + "]");
    }
    //form.setDataObj(prefNode);
    //form.getValidator().validateForm();

    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 10));

    PanelBuilder builder = new PanelBuilder(new FormLayout("p,1dlu,p", "p,2dlu,p,2dlu,p"));
    CellConstraints cc = new CellConstraints();

    //builder.addSeparator(getResourceString("AgentSearchTitle"), cc.xywh(1,1,3,1));
    builder.add(form.getUIComponent(), cc.xy(1, 1));
    builder.add(searchBtn, cc.xy(3, 1));

    panel.add(builder.getPanel(), BorderLayout.NORTH);
    contentPanel = new JPanel(new NavBoxLayoutManager(0, 2));
    //contentPanel.setMaximumSize(new Dimension(300,300));
    //contentPanel.setPreferredSize(new Dimension(300,300));

    scrollPane = new JScrollPane(contentPanel);
    panel.add(scrollPane, BorderLayout.CENTER);
    //scrollPane.setMaximumSize(new Dimension(300,300));
    scrollPane.setPreferredSize(new Dimension(300, 200));

    // Bottom Button UI
    cancelBtn = createButton(getResourceString("CANCEL"));
    okBtn = createButton(getResourceString("OK"));

    okBtn.addActionListener(this);
    getRootPane().setDefaultButton(okBtn);

    ButtonBarBuilder btnBuilder = new ButtonBarBuilder();
    btnBuilder.addGlue();
    btnBuilder.addGriddedButtons(new JButton[] { cancelBtn, okBtn });

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setVisible(false);
        }
    });

    panel.add(btnBuilder.getPanel(), BorderLayout.SOUTH);

    setContentPane(panel);
    pack();
    updateUI();
}

From source file:edu.ku.brc.specify.plugins.FishBase.java

public void initialize(final Properties properties, final boolean isViewMode) {
    textField = new JTextField();
    Insets insets = textField.getBorder().getBorderInsets(textField);
    textField.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.bottom));
    textField.setForeground(Color.BLACK);
    textField.setEditable(false);//from  w  ww .  j a v  a2 s.  c  o m

    ColorWrapper viewFieldColor = AppPrefsCache.getColorWrapper("ui", "formatting", "viewfieldcolor");
    if (viewFieldColor != null) {
        textField.setBackground(viewFieldColor.getColor());
    }

    PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g,1px,p", "c:p"), this);
    CellConstraints cc = new CellConstraints();

    builder.add(textField, cc.xy(1, 1));

    infoBtn = new JButton(IconManager.getIcon("FishBase", IconManager.IconSize.Std16));
    infoBtn.setFocusable(false);
    infoBtn.setMargin(new Insets(1, 1, 1, 1));
    infoBtn.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    builder.add(infoBtn, cc.xy(3, 1));

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));

    infoBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createInfoFrame();
                }
            });
        }
    });
}

From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java

private JPanel createHelpPanel(JFreeChart chart) {
    JPanel wrap = new JPanel(new GridLayout(1, 1));

    JPanel helpPanel = new JPanel(new GridLayout(1, 1));
    helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    //       helpPanel.setBorder(BorderFactory.createTitledBorder(
    //            BorderFactory.createEtchedBorder(), "Help Topics"));

    SpringLayout spring = new SpringLayout();
    JPanel inner = new JPanel(spring);
    inner.setBorder(BorderFactory.createEmptyBorder());

    final IHelpProvider provider = new Plot1DHelpProvider();
    final JList list = new JList(provider.getHelpMap().keySet().toArray());
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //      list.setBorder(BorderFactory.createEtchedBorder());
    JScrollPane listPane1 = new JScrollPane(list);
    inner.add(listPane1);//  w w w.  j  av  a 2s  . c  o m
    listPane1.setMaximumSize(new Dimension(140, 0));
    listPane1.setMinimumSize(new Dimension(70, 0));
    //      JPanel contentPanel = new JPanel(new GridLayout(2, 1));
    //      inner.add(list);
    final JTextField keyField = new JTextField();
    keyField.setMaximumSize(new Dimension(400, 20));
    keyField.setEditable(false);
    //      keyField.setMaximumSize();
    //      keyArea.setLineWrap(true);
    //      keyArea.setWrapStyleWord(true);
    //      keyArea.setBorder(BorderFactory.createEtchedBorder());
    inner.add(keyField);
    //      contentPanel.add(new JLabel());
    //      contentPanel.add(new JLabel());
    final JTextArea helpArea = new JTextArea();
    JScrollPane areaPane = new JScrollPane(helpArea);
    helpArea.setEditable(false);
    helpArea.setLineWrap(true);
    helpArea.setWrapStyleWord(true);
    //      helpArea.setBorder(BorderFactory.createEtchedBorder());
    inner.add(areaPane);
    //      contentPanel.add(new JLabel());
    //      contentPanel.add(new JLabel());
    //      inner.add(contentPanel);
    spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner);
    spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner);
    spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1);
    spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner);
    spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField);
    spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1);
    spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField);
    spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner);
    spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane);
    spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner);

    list.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            Object[] selected = list.getSelectedValues();
            if (selected.length >= 0) {
                HelpObject help = provider.getHelpMap().get(selected[0]);
                if (help != null) {
                    keyField.setText(help.getKey());
                    helpArea.setText(help.getDiscription());
                }
            }
        }
    });

    helpPanel.add(inner, BorderLayout.NORTH);
    wrap.setName("Help");

    wrap.add(helpPanel, BorderLayout.NORTH);
    return wrap;

}

From source file:net.sourceforge.processdash.ev.ui.ScheduleBalancingDialog.java

private void buildAndShowGUI() {
    chartData = null;/*from  w  ww .  ja  v  a  2 s .  com*/
    int numScheduleRows = scheduleRows.size();

    sumUpTotalTime();
    originalTotalTime = totalRow.time;
    if (originalTotalTime == 0)
        // if the rows added up to zero, choose a nominal target total time
        // corresponding to 10 hours per included schedule
        originalTotalTime = numScheduleRows * 60 * 10;

    JPanel panel = new JPanel(new GridBagLayout());
    if (numScheduleRows == 1) {
        totalRow.rowLabel = scheduleRows.get(0).rowLabel;
    } else {
        for (int i = 0; i < numScheduleRows; i++)
            scheduleRows.get(i).addToPanel(panel, i);
        scheduleRows.get(numScheduleRows - 1).showPercentageTickMarks();
        addChartToPanel(panel, numScheduleRows + 1);
    }
    totalRow.addToPanel(panel, numScheduleRows);

    if (rowsAreEditable == false) {
        String title = TaskScheduleDialog.resources.getString("Balance.Read_Only_Title");
        JOptionPane.showMessageDialog(parent.frame, panel, title, JOptionPane.PLAIN_MESSAGE);

    } else {
        String title = TaskScheduleDialog.resources.getString("Balance.Editable_Title");
        JDialog dialog = new JDialog(parent.frame, title, true);
        addButtons(dialog, panel, numScheduleRows + 2);
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        dialog.getContentPane().add(panel);
        dialog.pack();
        dialog.setLocationRelativeTo(parent.frame);
        dialog.setResizable(true);
        dialog.setVisible(true);
    }
}

From source file:com.eviware.soapui.impl.wsdl.panels.request.AbstractWsdlRequestDesktopPanel.java

protected JComponent buildStatusLabel() {
    statusBar = new JEditorStatusBarWithProgress();
    statusBar.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));

    return statusBar;
}

From source file:com.sshtools.sshvnc.SshVncSessionPanel.java

/**
 *
 *
 * @param application/* ww  w.  ja  v a 2  s . c o  m*/
 *
 * @throws SshToolsApplicationException
 */
public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);

    setLayout(new BorderLayout());
    sendTimer = new javax.swing.Timer(500, this);
    sendTimer.setRepeats(false);
    receiveTimer = new javax.swing.Timer(500, this);
    receiveTimer.setRepeats(false);

    statusBar = new StatusBar();
    statusBar.setUser("");
    statusBar.setHost("");
    statusBar.setStatusText("Disconnected");
    statusBar.setConnected(false);
    setLayout(new BorderLayout());

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation);

    terminal.requestFocus();

    //
    try {
        vnc = new SshVNCViewer();

        //  Additional connection tabs
        additionalTabs = new SshToolsConnectionTab[] { new VNCTab(), new VNCAdvancedTab() };
        add(vnc, BorderLayout.CENTER);
        initActions();
    } catch (Throwable t) {
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));

        IconWrapperPanel p = new IconWrapperPanel(UIManager.getIcon("OptionPane.errorIcon"),
                new ErrorTextBox(((t.getMessage() == null) ? "<no message supplied>" : t.getMessage())
                        + (debug ? ("\n\n" + sw.getBuffer().toString()) : "")));
        p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
        add(p, BorderLayout.CENTER);
        throw new SshToolsApplicationException("Failed to start SshVNC. ", t);
    }
}

From source file:com.tascape.qa.th.android.driver.App.java

/**
 * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting
 * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction.
 *
 * @param timeoutMinutes timeout in minutes to fail the manual steps
 *
 * @throws Exception if case of error/*from  w ww.  j  av  a2s . c om*/
 */
public void interactManually(int timeoutMinutes) throws Exception {
    LOG.info("Start manual UI interaction");
    long end = System.currentTimeMillis() + timeoutMinutes * 60000L;

    AtomicBoolean visible = new AtomicBoolean(true);
    AtomicBoolean pass = new AtomicBoolean(false);
    String tName = Thread.currentThread().getName() + "m";
    SwingUtilities.invokeLater(() -> {
        JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail());
        jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        JPanel jpContent = new JPanel(new BorderLayout());
        jd.setContentPane(jpContent);
        jpContent.setPreferredSize(new Dimension(1088, 828));
        jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        JPanel jpInfo = new JPanel();
        jpContent.add(jpInfo, BorderLayout.PAGE_START);
        jpInfo.setLayout(new BorderLayout());
        {
            JButton jb = new JButton("PASS");
            jb.setForeground(Color.green.darker());
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_START);
            jb.addActionListener(event -> {
                pass.set(true);
                jd.dispose();
                visible.set(false);
            });
        }
        {
            JButton jb = new JButton("FAIL");
            jb.setForeground(Color.red);
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_END);
            jb.addActionListener(event -> {
                pass.set(false);
                jd.dispose();
                visible.set(false);
            });
        }

        JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        new SwingWorker<Long, Long>() {
            @Override
            protected Long doInBackground() throws Exception {
                while (System.currentTimeMillis() < end) {
                    Thread.sleep(1000);
                    long left = (end - System.currentTimeMillis()) / 1000;
                    this.publish(left);
                }
                return 0L;
            }

            @Override
            protected void process(List<Long> chunks) {
                Long l = chunks.get(chunks.size() - 1);
                jlTimeout.setText(l + " seconds left");
                if (l < 850) {
                    jlTimeout.setForeground(Color.red);
                }
            }
        }.execute();

        JPanel jpResponse = new JPanel(new BorderLayout());
        JPanel jpProgress = new JPanel(new BorderLayout());
        jpResponse.add(jpProgress, BorderLayout.PAGE_START);

        JTextArea jtaJson = new JTextArea();
        jtaJson.setEditable(false);
        jtaJson.setTabSize(4);
        Font font = jtaJson.getFont();
        jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize()));

        JTree jtView = new JTree();

        JTabbedPane jtp = new JTabbedPane();
        jtp.add("tree", new JScrollPane(jtView));
        jtp.add("json", new JScrollPane(jtaJson));

        jpResponse.add(jtp, BorderLayout.CENTER);

        JPanel jpScreen = new JPanel();
        jpScreen.setMinimumSize(new Dimension(200, 200));
        jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS));
        JScrollPane jsp1 = new JScrollPane(jpScreen);
        jpResponse.add(jsp1, BorderLayout.LINE_START);

        JPanel jpJs = new JPanel(new BorderLayout());
        JTextArea jtaJs = new JTextArea();
        jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER);

        JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs);
        jSplitPane.setResizeWeight(0.88);
        jpContent.add(jSplitPane, BorderLayout.CENTER);

        JPanel jpLog = new JPanel();
        jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS));

        JCheckBox jcbTap = new JCheckBox("Enable Click", null, false);
        jpLog.add(jcbTap);
        jpLog.add(Box.createHorizontalStrut(8));

        JButton jbLogUi = new JButton("Log Screen");
        jpResponse.add(jpLog, BorderLayout.PAGE_END);
        {
            jpLog.add(jbLogUi);
            jbLogUi.addActionListener((ActionEvent event) -> {
                jtaJson.setText("waiting for screenshot...");
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        LOG.debug("\n\n");
                        try {
                            WindowHierarchy wh = device.loadWindowHierarchy();
                            jtView.setModel(getModel(wh));

                            jtaJson.setText("");
                            jtaJson.append(wh.root.toJson().toString(2));
                            jtaJson.append("\n");

                            File png = device.takeDeviceScreenshot();
                            BufferedImage image = ImageIO.read(png);

                            int w = device.getDisplayWidth();
                            int h = device.getDisplayHeight();

                            BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = resizedImg.createGraphics();
                            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                            g2.drawImage(image, 0, 0, w, h, null);
                            g2.dispose();

                            JLabel jLabel = new JLabel(new ImageIcon(resizedImg));
                            jpScreen.removeAll();
                            jsp1.setPreferredSize(new Dimension(w + 30, h));
                            jpScreen.add(jLabel);

                            jLabel.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY());
                                    if (jcbTap.isSelected()) {
                                        device.click(e.getPoint().x, e.getPoint().y);
                                        device.waitForIdle();
                                        jbLogUi.doClick();
                                    }
                                }
                            });
                        } catch (Exception ex) {
                            LOG.error("Cannot log screen", ex);
                            jtaJson.append("Cannot log screen");
                        }
                        jtaJson.append("\n\n\n");
                        LOG.debug("\n\n");

                        jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1);
                        jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1);
                    }
                };
                t.start();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbLogMsg = new JButton("Log Message");
            jpLog.add(jbLogMsg);
            JTextField jtMsg = new JTextField(10);
            jpLog.add(jtMsg);
            jtMsg.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent pE) {
                }

                @Override
                public void focusGained(final FocusEvent pE) {
                    jtMsg.selectAll();
                }
            });
            jtMsg.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(java.awt.event.KeyEvent e) {
                    if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                        jbLogMsg.doClick();
                    }
                }
            });
            jbLogMsg.addActionListener(event -> {
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        String msg = jtMsg.getText();
                        if (StringUtils.isNotBlank(msg)) {
                            LOG.info("{}", msg);
                            jtMsg.selectAll();
                        }
                    }
                };
                t.start();
                try {
                    t.join();
                } catch (InterruptedException ex) {
                    LOG.error("Cannot take screenshot", ex);
                }
                jtMsg.requestFocus();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbClear = new JButton("Clear");
            jpLog.add(jbClear);
            jbClear.addActionListener(event -> {
                jtaJson.setText("");
            });
        }

        JPanel jpAction = new JPanel();
        jpContent.add(jpAction, BorderLayout.PAGE_END);
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jpJs.add(jpAction, BorderLayout.PAGE_END);

        jd.pack();
        jd.setVisible(true);
        jd.setLocationRelativeTo(null);

        jbLogUi.doClick();
    });

    while (visible.get()) {
        if (System.currentTimeMillis() > end) {
            LOG.error("Manual UI interaction timeout");
            break;
        }
        Thread.sleep(500);
    }

    if (pass.get()) {
        LOG.info("Manual UI Interaction returns PASS");
    } else {
        Assert.fail("Manual UI Interaction returns FAIL");
    }
}

From source file:de.tbuchloh.kiskis.gui.dialogs.SecuredElementCreationDlg.java

private JPanel createButtonGroup() {
    final JPanel main = new JPanel(new GridLayout(TYPES.length, 1, 5, 5));
    main.setBorder(BorderFactory.createEmptyBorder(15, 50, 5, 150));
    _bg = new ButtonGroup();
    _buttons = new JRadioButton[TYPES.length];
    final String lastSelected = P.get(K_LAST_CREATED_SECURED_ELEMENT, NetAccount.class.getName());
    LOG.debug("Last created class: " + lastSelected);
    for (int i = 0; i < TYPES.length; ++i) {
        _buttons[i] = new JRadioButton(TYPES[i]._label);
        final Class c = TYPES[i]._clazz;
        if (c.getName().equals(lastSelected)) {
            _buttons[i].setSelected(true);
        }/*from   w  w w.  j a v  a2  s  . c o  m*/
        _bg.add(_buttons[i]);
        Component comp = _buttons[i];
        if (c == GenericAccount.class) {
            final JPanel p = new JPanel(new BorderLayout(10, 0));
            p.add(comp);
            p.add(_templates, BorderLayout.EAST);
            _templates.addItemListener(new RadioItemListener(_buttons[i]));
            comp.setEnabled(_templates.isEnabled());
            comp = p;
        }
        main.add(comp);
    }
    return main;
}

From source file:org.jfree.chart.demo.SuperDemo.java

private JPanel createSourceCodePanel() {
    JPanel jpanel = new JPanel(new BorderLayout());
    jpanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    JEditorPane jeditorpane = new JEditorPane();
    jeditorpane.setEditable(false);/*w w w .  j av a 2s  . c o m*/
    java.net.URL url = (SuperDemo.class).getResource("source.html");
    if (url != null)
        try {
            jeditorpane.setPage(url);
        } catch (IOException ioexception) {
            System.err.println("Attempted to read a bad URL: " + url);
        }
    else
        System.err.println("Couldn't find file: source.html");
    JScrollPane jscrollpane = new JScrollPane(jeditorpane);
    jscrollpane.setVerticalScrollBarPolicy(20);
    jscrollpane.setPreferredSize(new Dimension(250, 145));
    jscrollpane.setMinimumSize(new Dimension(10, 10));
    jpanel.add(jscrollpane);
    return jpanel;
}