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:eu.delving.sip.Application.java

private static void memoryNotConfigured() {
    String os = System.getProperty("os.name");
    Runtime rt = Runtime.getRuntime();
    int totalMemory = (int) (rt.totalMemory() / 1024 / 1024);
    StringBuilder out = new StringBuilder();
    String JAR_NAME = "SIP-Creator-2014-XX-XX.jar";
    if (os.startsWith("Windows")) {
        out.append(":: SIP-Creator Startup Batch file for Windows (more memory than ").append(totalMemory)
                .append("Mb)\n");
        out.append("java -jar -Xms1024m -Xmx1024m ").append(JAR_NAME);
    } else if (os.startsWith("Mac")) {
        out.append("# SIP-Creator Startup Script for Mac OSX (more memory than ").append(totalMemory)
                .append("Mb)\n");
        out.append("java -jar -Xms1024m -Xmx1024m ").append(JAR_NAME);
    } else {/*from w w  w  .j a  va  2s  .c o  m*/
        System.out.println("Unrecognized OS: " + os);
    }
    String script = out.toString();
    final JDialog dialog = new JDialog(null, "Memory Not Configured Yet!",
            Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea scriptArea = new JTextArea(3, 40);
    scriptArea.setText(script);
    scriptArea.setSelectionStart(0);
    scriptArea.setSelectionEnd(script.length());
    JPanel scriptPanel = new JPanel(new BorderLayout());
    scriptPanel.setBorder(BorderFactory.createTitledBorder("Script File"));
    scriptPanel.add(scriptArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    JButton ok = new JButton("OK, Continue anyway");
    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            EventQueue.invokeLater(LAUNCH);
        }
    });
    buttonPanel.add(ok);
    JPanel centralPanel = new JPanel(new GridLayout(0, 1));
    centralPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25));
    centralPanel.add(
            new JLabel("<html><b>The SIP-Creator started directly can have too little default memory allocated."
                    + "<br>It should be started with the following script:</b>"));
    centralPanel.add(scriptPanel);
    centralPanel.add(new JLabel(
            "<html><b>Please copy the above text into a batch or script file and execute that instead.</b>"));
    dialog.getContentPane().add(centralPanel, BorderLayout.CENTER);
    dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    dialog.pack();
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - dialog.getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - dialog.getHeight()) / 2);
    dialog.setLocation(x, y);
    dialog.setVisible(true);
}

From source file:YAxisDiffAlign.java

private static Container makeIt(String title, boolean more) {
    JPanel container = new JPanel() {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Insets insets = getInsets();
            int width = getWidth() - insets.left - insets.right;
            int halfWidth = width / 2 + insets.left;
            int height = getHeight();
            int halfHeight = height / 2 + insets.top;
            g.drawLine(halfWidth, 0, halfWidth, height);
        }//from  w ww.  j a  v  a2s .c  o  m
    };
    container.setBorder(BorderFactory.createTitledBorder(title));
    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
    container.setLayout(layout);

    JButton button;
    button = new JButton("0.0");
    button.setOpaque(false);
    button.setAlignmentX(Component.LEFT_ALIGNMENT);
    container.add(button);
    if (more) {
        button = new JButton(".25");
        button.setOpaque(false);
        button.setAlignmentX(0.25f);
        container.add(button);
        button = new JButton(".5");
        button.setOpaque(false);
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        container.add(button);
        button = new JButton(".75");
        button.setOpaque(false);
        button.setAlignmentX(0.75f);
        container.add(button);
    }
    button = new JButton("1.0");
    button.setOpaque(false);
    button.setAlignmentX(Component.RIGHT_ALIGNMENT);
    container.add(button);

    return container;
}

From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java

/**
 * //from   w  ww  . j a  v  a 2 s . c om
 * @param components
 * @return
 */
public static JPanel actionPanel(final JComponent... components) {

    final JPanel panel = ComponentFactory.createPanel();
    panel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY));

    for (final JComponent component : components) {
        panel.add(component);
    }

    return panel;
}

From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java

/**
 * //from  ww w. j  a va 2 s . c o  m
 * @param applet
 * @param container
 */
public static void updateDisplay(final JApplet applet, final Container container) {
    if (container != null) {

        final PanelBuilder builder = createBuilder(new String[] { "5dlu", "fill:default:grow", "5dlu" },
                new String[] { "5dlu", "fill:default:grow", "5dlu" });
        final CellConstraints cc = new CellConstraints();
        builder.add(container, cc.xy(2, 2));

        final JPanel panel = createPanel(builder);
        panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));

        applet.getContentPane().removeAll();
        applet.getContentPane().add(panel);
        applet.getContentPane().validate();
        applet.getContentPane().repaint();

    }
}

From source file:eu.europa.esig.dss.applet.util.ComponentFactory.java

/**
 * @param currentStep/*from w  w w.ja  va 2 s  .  c  o m*/
 * @param maxStep
 * @return
 */
public static JPanel createWizardStepPanel(final int currentStep, final int maxStep) {

    final List<String> colSpecs = new ArrayList<String>();

    for (int i = 1; i <= maxStep; i++) {
        colSpecs.add("default:grow");
    }

    final FormLayout layout = new FormLayout(StringUtils.join(colSpecs, ","), "pref");
    final PanelBuilder builder = ComponentFactory.createBuilder(layout);
    final CellConstraints cc = new CellConstraints();

    for (int i = 1; i <= maxStep; i++) {
        final JPanel subPanel = ComponentFactory
                .createPanel(i == currentStep ? DEFAULT_HIGHLIGHT : DEFAULT_BACKGROUND);
        subPanel.add(ComponentFactory.createLabel(String.valueOf(i)));

        final Border border = (i != maxStep) ? BorderFactory.createMatteBorder(0, 1, 0, 0, Color.GRAY)
                : BorderFactory.createMatteBorder(0, 1, 0, 1, Color.GRAY);
        subPanel.setBorder(border);
        builder.add(subPanel, cc.xy(i, 1));
    }

    final JPanel panel = ComponentFactory.createPanel(builder);
    panel.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.GRAY));
    return panel;
}

From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java

/**
 * /*  w w  w.ja v  a 2  s.co m*/
 * @param currentStep
 * @param maxStep
 * @return
 */
public static JPanel createWizardStepPanel(final int currentStep, final int maxStep) {

    final List<String> colSpecs = new ArrayList<String>();

    for (int i = 1; i <= maxStep; i++) {
        colSpecs.add("default:grow");
    }

    final FormLayout layout = new FormLayout(DSSUtils.join(colSpecs, ","), "pref");
    final PanelBuilder builder = ComponentFactory.createBuilder(layout);
    final CellConstraints cc = new CellConstraints();

    for (int i = 1; i <= maxStep; i++) {
        final JPanel subPanel = ComponentFactory
                .createPanel(i == currentStep ? DEFAULT_HIGHLIGHT : DEFAULT_BACKGROUND);
        subPanel.add(ComponentFactory.createLabel(String.valueOf(i)));

        final Border border = (i != maxStep) ? BorderFactory.createMatteBorder(0, 1, 0, 0, Color.GRAY)
                : BorderFactory.createMatteBorder(0, 1, 0, 1, Color.GRAY);
        subPanel.setBorder(border);
        builder.add(subPanel, cc.xy(i, 1));
    }

    final JPanel panel = ComponentFactory.createPanel(builder);
    panel.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.GRAY));
    return panel;
}

From source file:Test.java

public Test() {
    this.setBounds(100, 100, 200, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createRaisedSoftBevelBorder());

    this.setLayout(new FlowLayout());

    JButton exitButton = new JButton("Exit");
    panel.add(exitButton);/*from  w  w  w  . j  a  v  a2 s .  c o m*/
    this.add(panel);

    exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
}

From source file:Test.java

public Test() {
    this.setBounds(100, 100, 200, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED));
    //  panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.RAISED));

    this.setLayout(new FlowLayout());

    JButton exitButton = new JButton("Exit");
    panel.add(exitButton);//from   w  w  w  .j  ava2s  . c  o  m
    this.add(panel);

    exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
}

From source file:Test.java

public Test() {
    this.setBounds(100, 100, 200, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1, true));

    this.setLayout(new FlowLayout());

    JButton exitButton = new JButton("Exit");
    panel.add(exitButton);/*from  ww  w .  j a va 2s .co  m*/
    this.add(panel);

    exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
}

From source file:Test.java

public Test() {
    this.setBounds(100, 100, 200, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLoweredSoftBevelBorder());

    this.setLayout(new FlowLayout());

    JButton exitButton = new JButton("Exit");
    panel.add(exitButton);/*from w  w  w  .j a  v  a 2 s  .c  o m*/
    this.add(panel);

    exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
}