Example usage for javax.swing JPanel setBorder

List of usage examples for javax.swing JPanel setBorder

Introduction

In this page you can find the example usage for javax.swing JPanel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:org.jfree.chart.demo.selection.SelectionDemo8.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 *
 * @param title  the frame title.//from   w w w  .j  a  va  2s.c  om
 */
public SelectionDemo8(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setRangeZoomable(false);

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (TimeSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "Period:", "Value:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);

}

From source file:org.jfree.chart.demo.selection.SelectionDemo1.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * /*from w w w. java  2s .  c  om*/
 * @param title  the frame title.
 */
public SelectionDemo1(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (TimeSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "Period:", "Value:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);

}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel p = new JPanel(new BorderLayout());
    JTextField tf = new JTextField(5);
    JLabel label = new JLabel(new ImageIcon("Test.gif"));
    label.setOpaque(true);//from w  ww .j av a2  s.co m
    label.setBackground(tf.getBackground());
    label.setPreferredSize(new Dimension(label.getPreferredSize().width, tf.getPreferredSize().height));
    p.setBorder(tf.getBorder());
    tf.setBorder(null);
    p.add(label, BorderLayout.WEST);
    p.add(tf, BorderLayout.CENTER);
    JPanel p1 = new JPanel();
    p1.add(p);
    getContentPane().add(p1);
    pack();
    setLocationRelativeTo(null);
}

From source file:components.FrameDemo2.java

protected JComponent createButtonPane() {
    JButton button = new JButton("New window");
    button.setActionCommand(CREATE_WINDOW);
    button.addActionListener(this);
    defaultButton = button; //Used later to make this the frame's default button.

    //Center the button in a panel with some space around it.
    JPanel pane = new JPanel(); //use default FlowLayout
    pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pane.add(button);/*www.  j ava 2s .  co  m*/

    return pane;
}

From source file:bigdata.explorer.nutch.grapview.tests.WebGraphTreeLayout.java

public WebGraphTreeLayout() throws IOException {

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

    createTree();//from   w  w w  .jav a 2 s  .c o  m

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

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

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

    final ScalingControl scaler = new CrossoverScalingControl();

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

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

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

                LayoutTransition<String, Number> lt = new LayoutTransition<String, Number>(vv, treeLayout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, Number> lt = new LayoutTransition<String, Number>(vv, radialLayout,
                        treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

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

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);

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

From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java

/**
 * ???/*from  w  w w.  j av  a2s. c  o m*/
 */
public Classgenerator() {
    setTitle("?");
    setSize(WIDTH, HEIGHT);
    setLocationRelativeTo(null);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 1));

    JPanel _beanPanel = new JPanel();
    _beanPanel.setBorder(BorderFactory.createTitledBorder("?"));

    JPanel _otherPanel = new JPanel();
    _otherPanel.setBorder(BorderFactory.createTitledBorder("?"));

    JLabel _tbLabel = new JLabel("??*");
    _tb = new JTextField(25);
    _beanPanel.add(_tbLabel);
    _beanPanel.add(_tb);

    JLabel _stbbLabel = new JLabel("??*");
    _stb = new JTextField(25);
    _beanPanel.add(_stbbLabel);
    _beanPanel.add(_stb);

    JLabel _ibatisLabel = new JLabel("IBTS*");
    _ibatis = new JTextField(25);
    _beanPanel.add(_ibatisLabel);
    _beanPanel.add(_ibatis);

    JLabel _svLabel = new JLabel("SERVICE");
    _sv = new JTextField(23);
    _otherPanel.add(_svLabel);
    _otherPanel.add(_sv);

    //      JLabel _sviLabel = new JLabel("??*");
    //      _zwmc = new JTextField("?",25);
    //      _zwmc.setEditable(false);
    //      _otherPanel.add(_sviLabel);
    //      _otherPanel.add(_zwmc);

    JLabel _detail = new JLabel("(?ServiceService??,");
    JLabel _detail2 = new JLabel("??Service???.impl)");
    _detail.setFont(new Font("", Font.ITALIC, 12));
    _detail2.setFont(new Font("", Font.ITALIC, 12));
    _otherPanel.add(_detail);
    _otherPanel.add(_detail2);
    panel.add(_beanPanel);
    panel.add(_otherPanel);

    add(panel, BorderLayout.CENTER);

    JPanel btnPanel = new JPanel();
    JButton _saveBtn = new JButton("?");

    _saveBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int msg_code = clickSaveBtn(e);
            showMsg(msg_code);
        }
    });

    JButton _restBtn = new JButton("?");

    //?
    _restBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _tb.setText(null);
            _stb.setText(null);
            _ibatis.setText(null);
            _sv.setText(null);
            //            _svi.setText(null);
        }
    });
    btnPanel.add(_saveBtn);
    btnPanel.add(_restBtn);
    add(btnPanel, BorderLayout.SOUTH);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.SaveChartDialog.java

/**
 * Creates and lays out the controls inside this dialog's content pane.
 * <p>/*from w w w.j a  va  2 s  .  co m*/
 * This method is called upon initialization only.
 * </p>
 */
private void initControls() {
    JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4));
    sizePanel.setBorder(BorderFactory.createTitledBorder(Messages.DI_IMAGESIZE));

    // Add a spinner for choosing width
    sizePanel.add(new JLabel(Messages.DI_WIDTH, SwingConstants.RIGHT));
    int width = ChartPanel.DEFAULT_WIDTH;
    int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH;
    int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH;
    SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1);
    sizePanel.add(widthSpinner = new JSpinner(widthSettings));
    sizePanel.add(new JLabel(Messages.DI_PIXELS));

    // Add a spinner for choosing height
    sizePanel.add(new JLabel(Messages.DI_HEIGHT, SwingConstants.RIGHT));
    int height = ChartPanel.DEFAULT_HEIGHT;
    int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT;
    int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT;
    SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1);
    sizePanel.add(heightSpinner = new JSpinner(heightSettings));
    sizePanel.add(new JLabel(Messages.DI_PIXELS));

    // Add Save and Cancel buttons
    JPanel buttons = new JPanel(new GridLayout(1, 2, 4, 0));
    buttons.add(btnSave = Utils.createButton(Messages.DI_SAVE, null, this));
    buttons.add(btnCancel = Utils.createButton(Messages.DI_CANCEL, null, this));
    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    buttonsBox.add(buttons);
    buttonsBox.add(Box.createHorizontalGlue());

    Container contentPane = getContentPane();
    contentPane.add(sizePanel, BorderLayout.NORTH);
    contentPane.add(Box.createVerticalStrut(Utils.BORDER_SIZE / 2));
    contentPane.add(buttonsBox, BorderLayout.PAGE_END);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Utils.setStandardBorder(getRootPane());
}

From source file:com.apatar.ui.JFeatureRequestHelpDialog.java

private void createDialog() {
    setLayout(new BorderLayout(5, 5));

    setSize(400, 400);//from w  w  w.j a va 2 s .c  o m

    JPanel textPanel = new JPanel(new BorderLayout(5, 5));
    textPanel.setBorder(new EmptyBorder(10, 5, 5, 5));
    text.setLineWrap(true);
    text.setWrapStyleWord(true);
    text.setFont(UiUtils.NORMAL_SIZE_12_FONT);

    textPanel.add(new JLabel("What new Apatar features would you like to request? Please describe them:"),
            BorderLayout.NORTH);
    textPanel.add(new JScrollPane(text), BorderLayout.CENTER);

    JPanel contactPanel = new JPanel();
    contactPanel.setLayout(new BoxLayout(contactPanel, BoxLayout.Y_AXIS));

    JPanel firstNamePanel = new JPanel();
    firstNamePanel.setLayout(new BoxLayout(firstNamePanel, BoxLayout.X_AXIS));
    firstNamePanel.add(new JLabel("Your First Name:"));
    firstNamePanel.add(Box.createHorizontalStrut(5));
    firstNamePanel.add(firstNameField);

    JPanel lastNamePanel = new JPanel();
    lastNamePanel.setLayout(new BoxLayout(lastNamePanel, BoxLayout.X_AXIS));
    lastNamePanel.add(new JLabel("Your Last Name:"));
    lastNamePanel.add(Box.createHorizontalStrut(5));
    lastNamePanel.add(lastNameField);

    JPanel emailPanel = new JPanel();
    emailPanel.setLayout(new BoxLayout(emailPanel, BoxLayout.X_AXIS));
    emailPanel.add(new JLabel("Your E-mail:"));
    emailPanel.add(Box.createHorizontalStrut(28));
    emailPanel.add(emailField);

    contactPanel.add(firstNamePanel);
    contactPanel.add(Box.createVerticalStrut(5));
    contactPanel.add(lastNamePanel);
    contactPanel.add(Box.createVerticalStrut(5));
    contactPanel.add(emailPanel);

    textPanel.add(contactPanel, BorderLayout.SOUTH);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(sendButton);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.add(cancel);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.setBorder(new EmptyBorder(0, 0, 5, 0));

    getContentPane().add(textPanel, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
}

From source file:BasicDnD.java

protected JPanel createVerticalBoxPanel() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    return p;//from  w  w  w  . ja v a 2 s.  c o m
}

From source file:eu.delving.sip.frames.OutputFrame.java

private JPanel createOutputPanel() {
    final JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createTitledBorder("Output record"));
    outputArea = new JTextArea(sipModel.getRecordCompileModel().getOutputDocument());
    outputArea.setLineWrap(true);/*from   w  w w.jav  a 2 s.  c om*/
    outputArea.setFont(MONOSPACED);
    outputArea.setWrapStyleWord(true);
    outputArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            try {
                String first = documentEvent.getDocument().getText(0, 1);
                final boolean error = first.startsWith("#");
                setError(outputArea, error);
                sipModel.exec(new Swing() {
                    @Override
                    public void run() {
                        outputArea.setCaretPosition(0);
                    }
                });
            } catch (BadLocationException e) {
                // who cares
            }
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
        }
    });
    outputArea.getInputMap().put(KeystrokeHelper.DOWN, "next");
    outputArea.getInputMap().put(KeystrokeHelper.RIGHT, "next");
    outputArea.getInputMap().put(KeystrokeHelper.UP, "prev");
    outputArea.getInputMap().put(KeystrokeHelper.LEFT, "prev");
    outputArea.getActionMap().put("next", new NextAction());
    outputArea.getActionMap().put("prev", new PrevAction());
    searchField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            found.clear();
            foundSelected = 0;
            String xml = outputArea.getText().toLowerCase();
            String sought = searchField.getText().toLowerCase();
            if (!sought.isEmpty()) {
                int start = 0;
                while (found.size() < 30) {
                    int pos = xml.indexOf(sought, start);
                    if (pos < 0)
                        break;
                    found.add(pos);
                    start = pos + sought.length();
                }
            }
            selectFound();
        }
    });
    JPanel sp = new JPanel();
    JLabel label = new JLabel("Search:", JLabel.RIGHT);
    label.setLabelFor(searchField);
    sp.add(label);
    sp.add(searchField);
    sp.add(new JLabel("Press ENTER, then use arrow keys"));
    p.add(scrollVH(outputArea), BorderLayout.CENTER);
    p.add(sp, BorderLayout.SOUTH);
    return p;
}