Example usage for javax.swing BorderFactory createLineBorder

List of usage examples for javax.swing BorderFactory createLineBorder

Introduction

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

Prototype

public static Border createLineBorder(Color color) 

Source Link

Document

Creates a line border with the specified color.

Usage

From source file:ca.sqlpower.wabit.swingui.enterprise.UserPanel.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                WabitWorkspace p = new WabitWorkspace();
                p.setUUID("system");

                // Add data sources to workspace
                DataSourceCollection<SPDataSource> plini = new PlDotIni();
                plini.read(new File(System.getProperty("user.home"), "pl.ini"));
                List<SPDataSource> dataSources = plini.getConnections();
                for (int i = 0; i < 10 && i < dataSources.size(); i++) {
                    p.addDataSource(new WabitDataSource(dataSources.get(i)));
                }/*from w  ww  .  j  a va  2s  .  com*/

                // Add layouts to workspace
                Report layout = new Report("Example Layout");
                p.addReport(layout);
                Page page = layout.getPage();
                page.addContentBox(new ContentBox());
                page.addGuide(new Guide(Axis.HORIZONTAL, 123));
                page.addContentBox(new ContentBox());

                // dd a report task
                ReportTask task = new ReportTask();
                task.setReport(layout);
                p.addReportTask(task);

                User user = new User("admin", "admin");
                user.setParent(p);
                Group group = new Group("Admins");
                group.setParent(p);
                group.addMember(new GroupMember(user));

                Group group2 = new Group("Other Group");
                group2.setParent(p);

                p.addUser(user);
                p.addGroup(group);
                p.addGroup(group2);

                UserPanel panel = new UserPanel(user);

                UserPanel panel2 = new UserPanel(user);

                JFrame f = new JFrame("TEST PANEL");
                JPanel outerPanel = new JPanel(new BorderLayout());
                outerPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE));
                outerPanel.add(panel.getPanel(), BorderLayout.CENTER);
                f.setContentPane(outerPanel);
                f.pack();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setVisible(true);

                JFrame f2 = new JFrame("TEST PANEL");
                JPanel outerPanel2 = new JPanel(new BorderLayout());
                outerPanel2.setBorder(BorderFactory.createLineBorder(Color.BLUE));
                outerPanel2.add(panel2.getPanel(), BorderLayout.CENTER);
                f2.setContentPane(outerPanel2);
                f2.pack();
                f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f2.setVisible(true);

            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    });
}

From source file:cc.siara.csv_ml_demo.MultiLevelCSVSwingDemo.java

/**
 * Constructor that adds components to the container, sets layout and opens
 * with window//from ww w  .  ja  v  a  2  s .c om
 * 
 * @param container
 */
public MultiLevelCSVSwingDemo(Container container) {
    if (container == null)
        container = this;
    if (container instanceof JFrame) {
        JFrame frame = (JFrame) container;
        frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        frame.setLocationByPlatform(true);
        frame.setTitle("Demonstration of Multi-level CSV parsing (csv_ml)");
    }
    container.setSize(800, 600);
    container.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 6));
    container.add(lblInput);
    container.add(cbExamples);
    container.add(lblInputSize);
    container.add(tfInputSize);
    container.add(lblDelimiter);
    container.add(cbDelimiter);
    container.add(tfDelimiter);
    container.add(btnAbout);
    container.add(taInputScroll);
    container.add(lblOutput);
    container.add(btnDDLDML);
    container.add(btnJSON);
    container.add(btnXML);
    container.add(btnXPath);
    container.add(tfXPath);
    container.add(cbPretty);
    container.add(taOutputScroll);
    container.add(lblOutputSize);
    container.add(tfOutputSize);
    container.add(btnToCSV);
    container.add(lblJDBCURL);
    container.add(tfDBURL);
    container.add(btnRunDDL);
    container.add(lblID);
    container.add(tfID);
    container.add(btnGetData);
    JTextField tfID = new JTextField("1", 4);
    taInput.setBorder(BorderFactory.createLineBorder(getForeground()));
    taOutput.setBorder(BorderFactory.createLineBorder(getForeground()));
    setInputText();
    cbExamples.addActionListener(this);
    cbDelimiter.addActionListener(this);
    btnAbout.addActionListener(this);
    btnXML.addActionListener(this);
    btnDDLDML.addActionListener(this);
    btnJSON.addActionListener(this);
    btnToCSV.addActionListener(this);
    btnXPath.addActionListener(this);
    btnRunDDL.addActionListener(this);
    btnGetData.addActionListener(this);
    taInput.addKeyListener(new KeyListener() {
        public void keyTyped(KeyEvent arg0) {
            isInputChanged = true;
        }

        public void keyReleased(KeyEvent arg0) {
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    tfInputSize.setEditable(false);
    tfOutputSize.setEditable(false);
    setVisible(true);
}

From source file:DecimalFormatDemo.java

public DecimalFormatDemo() {

    availableLocales = new LocaleGroup();
    inputFormatter = NumberFormat.getNumberInstance();

    String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000",
            "'hello'###.##" };

    currentPattern = patternExamples[0];

    // Set up the UI for entering a number.
    JLabel numberLabel = new JLabel("Enter the number to format:");
    numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JTextField numberField = new JTextField();
    numberField.setEditable(true);/* w  w w.  j av  a 2s.  c  o  m*/
    numberField.setAlignmentX(Component.LEFT_ALIGNMENT);
    NumberListener numberListener = new NumberListener();
    numberField.addActionListener(numberListener);

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");
    patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setSelectedIndex(0);
    patternList.setEditable(true);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    PatternListener patternListener = new PatternListener();
    patternList.addActionListener(patternListener);

    // Set up the UI for selecting a locale.
    JLabel localeLabel = new JLabel("Select a Locale from the list:");
    localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox localeList = new JComboBox(availableLocales.getStrings());
    localeList.setSelectedIndex(0);
    localeList.setAlignmentX(Component.LEFT_ALIGNMENT);
    LocaleListener localeListener = new LocaleListener();
    localeList.addActionListener(localeListener);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Result", JLabel.LEFT);
    resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setAlignmentX(Component.LEFT_ALIGNMENT);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything
    JPanel numberPanel = new JPanel();
    numberPanel.setLayout(new GridLayout(0, 1));
    numberPanel.add(numberLabel);
    numberPanel.add(numberField);

    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternPanel.add(patternList);

    JPanel localePanel = new JPanel();
    localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS));
    localePanel.add(localeLabel);
    localePanel.add(localeList);

    JPanel resultPanel = new JPanel();
    resultPanel.setLayout(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    localePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

    add(numberPanel);
    add(Box.createVerticalStrut(10));
    add(patternPanel);
    add(Box.createVerticalStrut(10));
    add(localePanel);
    add(Box.createVerticalStrut(10));
    add(resultPanel);

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

    reformat();
    numberField.setText(result.getText());

}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Add a bordered 'sub-panel' with title to a container
 * /*from w ww . j av  a2 s  .  c om*/
 * @param container - parent container
 * @param tableSize - TableLayout table array
 * @param name - panel name
 * @param debug - turn on/off red debug borders
 * @return new JPanel
 */
public static JPanel addBorderedPanel(Container container, double tableSize[][], String name, boolean debug) {
    JPanel panel = new JPanel();
    panel.setOpaque(false);

    TableLayout layout = new TableLayout(tableSize);
    panel.setLayout(layout);
    panel.setBorder(BorderFactory.createTitledBorder(name));

    if (debug == true)
        panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                panel.getBorder()));

    return panel;
}

From source file:LayeredPaneDemo.java

private JLabel createColoredLabel(String text, Color color, Point origin) {
    JLabel label = new JLabel(text);
    label.setVerticalAlignment(JLabel.TOP);
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setOpaque(true);/* w  w w . j a va  2s  . co  m*/
    label.setBackground(color);
    label.setForeground(Color.black);
    label.setBorder(BorderFactory.createLineBorder(Color.black));
    label.setBounds(origin.x, origin.y, 140, 140);
    return label;
}

From source file:org.jdal.swing.form.SimpleBoxFormBuilder.java

/**
 * Gets current column pointed to cursor, create one if none.
 * @return a new or existent column Box.
 *//*from   w w w .  j  a  v a 2 s .c  o m*/
private Box getColumn() {
    Box column = null;
    if (index < columns.size()) {
        column = (Box) columns.get(index);
    } else {
        if (!columns.isEmpty())
            container.add(Box.createHorizontalStrut(defaultSpace));

        column = Box.createVerticalBox();
        columns.add(column);
        container.add(column);
        columnsWidth.add(0);

        if (debug) {
            column.setBorder(BorderFactory.createLineBorder(Color.RED));
        }
    }
    return column;
}

From source file:UI.MainViewPanel.java

public JProgressBar getPanel7(Metric7 m7) {

    JProgressBar openPortBar = new JProgressBar(0, 100);
    openPortBar.setValue(m7.totalCriticalCount);
    openPortBar.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    UIDefaults defaults = new UIDefaults();

    Painter foregroundPainter = new MyPainter(new Color(230, 219, 27));
    Painter backgroundPainter = new MyPainter(chartBackgroundColor);
    defaults.put("ProgressBar[Enabled].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled].backgroundPainter", backgroundPainter);

    openPortBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
    openPortBar.putClientProperty("Nimbus.Overrides", defaults);

    openPortBar.setString("" + m7.totalCriticalCount);
    openPortBar.setStringPainted(true);/*from   w ww .  ja v  a  2 s.  c  om*/

    return openPortBar;
}

From source file:SwingMouseMotionEventDemo.java

public BlankArea(Color color) {
    setBackground(color);
    setOpaque(true);
    setBorder(BorderFactory.createLineBorder(Color.black));
}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    // No file selected before, popup a dialog and query the user which file to open.
    if (file == null) {
        String path = System.getProperty("user.home");
        if (AppContext.getLastSelectedFolder() != null) {
            path = AppContext.getLastSelectedFolder();
        }//from   w  ww  .ja  va2  s.  co  m
        JFileChooser fc = new JFileChooser(path);
        fc.setDialogTitle(resources.getResourceByKey("OpenBoardCommand.name"));
        fc.setFileFilter(new FefaultFileFilter());
        int result = fc.showOpenDialog(win);
        if (result == JFileChooser.APPROVE_OPTION) {
            if (fc.getSelectedFile() == null)
                return;
            file = fc.getSelectedFile();
            AppContext.setLastSelectedFolder(file.getParentFile().getAbsolutePath());
        } else {
            return;
        }
    }

    final JWindow topWindow = new JWindow();
    topWindow.setSize(390, 50);
    topWindow.setLayout(new BorderLayout());
    topWindow.setBackground(Color.WHITE);

    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    content.setBackground(Color.WHITE);
    final JLabel infoLabel = new JLabel(
            resources.getResourceByKey("OpenBoardCommand.waitMsg") + " " + file.getName());
    infoLabel.setVerticalAlignment(SwingConstants.CENTER);
    content.add(infoLabel, BorderLayout.SOUTH);

    final JBusyComponent<JPanel> busyPanel = new JBusyComponent<JPanel>(content);
    busyPanel.setBusy(true);

    topWindow.getContentPane().add(busyPanel, BorderLayout.CENTER);
    topWindow.setLocationRelativeTo(null);
    topWindow.add(busyPanel, BorderLayout.CENTER);

    final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {

        @Override
        protected Boolean doInBackground() {
            topWindow.setVisible(true);
            doOpen();
            return Boolean.valueOf(true);
        }

        @Override
        protected void done() {
            topWindow.setVisible(false);
            topWindow.dispose();
            for (Runnable r : postConfigurators) {
                SwingUtilities.invokeLater(r);
            }
        }
    };

    worker.execute();

}

From source file:thv.th.view.AnimationPanel.java

protected void show(int start) throws IOException {
    panel.removeAll();/* w  w  w.j ava  2 s . c  om*/

    loadPalette();
    Vector<THAnimation> anims = loadAnimations(start);

    timer.stop();

    for (ActionListener al : timer.getActionListeners())
        timer.removeActionListener(al);

    for (THAnimation anim : anims) {
        timer.addActionListener(anim);
        panel.add(anim);
        anim.setBorder(BorderFactory.createLineBorder(Color.RED));

        StringBuilder sb = new StringBuilder();
        sb.append("<html>index: ");
        sb.append(anim.getAnimIndex());
        sb.append("<br>width: ");
        sb.append(anim.getFrameWidth());
        sb.append("<br>height: ");
        sb.append(anim.getFrameHeight());
        sb.append("<br>Frames");

        for (THFrame f : anim.getFrames()) {
            sb.append("<br>" + f.getIndex());
        }

        anim.setToolTipText(sb.toString());
    }

    timer.start();

    panel.revalidate();
    panel.repaint();
}