Example usage for javax.swing BorderFactory createTitledBorder

List of usage examples for javax.swing BorderFactory createTitledBorder

Introduction

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

Prototype

public static TitledBorder createTitledBorder(Border border) 

Source Link

Document

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Usage

From source file:com.xilinx.ultrascale.gui.BarCharts.java

License:asdf

public ChartPanel getChart(String title) {
    ChartPanel chartpanel = new ChartPanel(chart);
    chartpanel.setRangeZoomable(false);/* w ww  . ja  va2  s . c o m*/
    chartpanel.setDomainZoomable(false);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title),
            BorderFactory.createRaisedBevelBorder()));
    return chartpanel;
}

From source file:DropDemo.java

private JPanel createArea() {
    String text = "Drag from or drop into this area.\nThe default action is MOVE;\nhold the Control key to COPY.";

    JTextArea area = new JTextArea();
    area.setText(text);/*  ww  w  .ja  v a  2 s  .  co m*/
    area.setDragEnabled(true);
    JScrollPane scrollPane = new JScrollPane(area);
    scrollPane.setPreferredSize(new Dimension(400, 100));
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setBorder(BorderFactory.createTitledBorder("Text Area"));
    return panel;
}

From source file:HtmlDemo.java

public HtmlDemo() {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    String initialText = "<html>\n" + "Color and font test:\n" + "<ul>\n" + "<li><font color=red>red</font>\n"
            + "<li><font color=blue>blue</font>\n" + "<li><font color=green>green</font>\n"
            + "<li><font size=-2>small</font>\n" + "<li><font size=+2>large</font>\n" + "<li><i>italic</i>\n"
            + "<li><b>bold</b>\n" + "</ul>\n";

    htmlTextArea = new JTextArea(10, 20);
    htmlTextArea.setText(initialText);//  ww  w  . j  a va 2 s  .  co  m
    JScrollPane scrollPane = new JScrollPane(htmlTextArea);

    JButton changeTheLabel = new JButton("Change the label");
    changeTheLabel.setMnemonic(KeyEvent.VK_C);
    changeTheLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
    changeTheLabel.addActionListener(this);

    theLabel = new JLabel(initialText) {
        public Dimension getPreferredSize() {
            return new Dimension(200, 200);
        }

        public Dimension getMinimumSize() {
            return new Dimension(200, 200);
        }

        public Dimension getMaximumSize() {
            return new Dimension(200, 200);
        }
    };
    theLabel.setVerticalAlignment(SwingConstants.CENTER);
    theLabel.setHorizontalAlignment(SwingConstants.CENTER);

    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    leftPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Edit the HTML, then click the button"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    leftPanel.add(scrollPane);
    leftPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    leftPanel.add(changeTheLabel);

    JPanel rightPanel = new JPanel();
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));
    rightPanel
            .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("A label with HTML"),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    rightPanel.add(theLabel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(leftPanel);
    add(Box.createRigidArea(new Dimension(10, 0)));
    add(rightPanel);
}

From source file:edu.cuny.cat.ui.SpecialistView.java

private void setupShoutPlots() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "Time", "Price", dataset, true, true,
            false);/* www . j a v a  2  s.  c  o m*/
    chart.setAntiAlias(true);
    chart.setBackgroundPaint(getContentPane().getBackground());
    xyplot = (XYPlot) chart.getPlot();
    xyplot.setNoDataMessage("NO DATA");
    xyplot.setRenderer(new XYLineAndShapeRenderer());
    final NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis();
    numberaxis1.setTickMarkInsideLength(2.0F);
    numberaxis1.setTickMarkOutsideLength(0.0F);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);

    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 5, 5, 20),
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Shouts"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5))));

    getContentPane().add(chartPanel, BorderLayout.CENTER);

    pack();
}

From source file:SimpleHelp.java

public SimpleHelp(String windowName, String helpIndexFileName) {
    super(windowName + " Help Window");
    cp = getContentPane();//  www. jav  a2s . c o m
    getAccessibleContext().setAccessibleName(windowName + " Help Window");
    getAccessibleContext().setAccessibleDescription(
            "A window for viewing the help for " + windowName + ", which is somewhat hyperlinked.");

    try {
        URL url = new File(helpIndexFileName).toURL();
        // Only create the window once.
        if (help == null) {
            // System.out.println("Creat-ing help window for " + url);
            help = new JEditorPane(url);
            // System.out.println("Done!");
            help.setEditable(false);
            help.addHyperlinkListener(this);
            JScrollPane scroller = new JScrollPane();
            scroller.setBorder(BorderFactory.createTitledBorder(windowName + " Help"));
            scroller.getViewport().add(help);
            cp.add(BorderLayout.CENTER, scroller);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    SimpleHelp.this.setVisible(false);
                    SimpleHelp.this.dispose();
                }
            });
            setSize(500, 400);
        } else {
            System.out.println("Re-using help window!");
        }
    } catch (MalformedURLException e) {
        System.out.println("Malformed URL: " + e);
    } catch (IOException e) {
        System.out.println("IOException: " + e);
    }
}

From source file:medsavant.enrichment.app.RegionListAggregatePanel.java

public RegionListAggregatePanel(String page) {
    super(page);/*from w ww . ja  v  a2  s  . c  o  m*/
    setLayout(new BorderLayout());

    variantCounts = new TreeMap<GenomicRegion, Integer>();
    patientCounts = new TreeMap<GenomicRegion, Integer>();

    regionSetCombo = new JComboBox();

    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    progress = new JProgressBar();
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new BoxLayout(banner, BoxLayout.X_AXIS));

    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Region List"));

    banner.add(regionSetCombo);
    banner.add(ViewUtil.getMediumSeparator());
    banner.add(Box.createHorizontalGlue());
    banner.add(progress);

    add(banner, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);

    createSearchableTable();

    regionSetCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            fetchRegions((RegionSet) regionSetCombo.getSelectedItem());
        }
    });

    new MedSavantWorker<List<RegionSet>>(pageName) {
        @Override
        protected List<RegionSet> doInBackground() throws Exception {
            return RegionController.getInstance().getRegionSets();
        }

        @Override
        protected void showProgress(double fraction) {
        }

        @Override
        protected void showSuccess(List<RegionSet> result) {
            if (!result.isEmpty()) {
                updateRegionSetCombo(result);
            }
        }
    }.execute();
}

From source file:BoxAlignmentDemo.java

protected JPanel createButtonRow(boolean changeAlignment) {
    JButton button1 = new JButton("A JButton", createImageIcon("images/middle.gif"));
    button1.setVerticalTextPosition(AbstractButton.BOTTOM);
    button1.setHorizontalTextPosition(AbstractButton.CENTER);

    JButton button2 = new JButton("Another JButton", createImageIcon("images/geek-cght.gif"));
    button2.setVerticalTextPosition(AbstractButton.BOTTOM);
    button2.setHorizontalTextPosition(AbstractButton.CENTER);

    String title;/* w ww . ja v a  2  s  .c  o m*/
    if (changeAlignment) {
        title = "Desired";
        button1.setAlignmentY(BOTTOM_ALIGNMENT);
        button2.setAlignmentY(BOTTOM_ALIGNMENT);
    } else {
        title = "Default";
    }

    JPanel pane = new JPanel();
    pane.setBorder(BorderFactory.createTitledBorder(title));
    pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
    pane.add(button1);
    pane.add(button2);
    return pane;
}

From source file:de.codesourcery.eve.skills.ui.components.ListEditingComponent.java

@Override
protected final JPanel createPanel() {

    final JPanel result = new JPanel();

    result.setLayout(new BorderLayout());

    final JScrollPane scrollPane = new JScrollPane(list);

    if (!StringUtils.isBlank(getTitle())) {
        scrollPane.setBorder(BorderFactory.createTitledBorder(getTitle()));
    }//from   w w w .j ava  2s.  c  o  m

    scrollPane.setPreferredSize(new Dimension(150, 400));
    result.add(scrollPane, BorderLayout.NORTH);

    final JPanel buttonPanel = new JPanel();

    populateButtonPanel(buttonPanel);

    result.add(buttonPanel, BorderLayout.SOUTH);

    createPanelHook(result);

    return result;
}

From source file:tl.lib.dataCollection.gui.MultipleChartsPanel.java

public void addChart(int chartIndex, _ChartPanel chart) {
    if (charts.containsKey(new Integer(chartIndex))) {
        remove((ChartPanel) charts.get(new Integer(chartIndex)));
    }/* w w  w  .  j av a  2s  .  co m*/
    charts.remove(new Integer(chartIndex));
    charts.put(new Integer(chartIndex), chart);
    grid.gridx = 0;
    grid.gridy = chartIndex - 1;
    grid.gridwidth = 1;
    ((ChartPanel) chart).setBorder(BorderFactory.createTitledBorder(chart.label()));
    add((ChartPanel) chart, grid);
}

From source file:io.github.jeremgamer.editor.panels.GeneralSettings.java

public GeneralSettings() {
    this.setBorder(BorderFactory.createTitledBorder(""));

    JPanel namePanel = new JPanel();
    JLabel nameLabel = new JLabel("Nom :");
    namePanel.add(nameLabel);/*w  ww .jav a 2  s . c  o  m*/
    name.setPreferredSize(new Dimension(220, 30));
    namePanel.add(name);
    CaretListener caretUpdateName = new CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent e) {
            JTextField text = (JTextField) e.getSource();
            gs.set("name", text.getText());
        }
    };
    name.addCaretListener(caretUpdateName);
    this.add(namePanel);

    adress.setEditable(false);
    CaretListener caretUpdateAdress = new CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent e) {
            JTextField text = (JTextField) e.getSource();
            gs.set("adress", text.getText());
        }
    };
    adress.addCaretListener(caretUpdateAdress);
    JPanel subTypePanel = new JPanel();
    JLabel typeLabel = new JLabel("Type :");
    subTypePanel.add(typeLabel);
    type.setPreferredSize(new Dimension(220, 30));
    type.addItem("Minecraft classique");
    type.addItem("Minecraft personnalis");
    if (new File("projects/" + Editor.getProjectName() + "/data.zip").exists()) {
        type.setSelectedIndex(1);
        browse.setEnabled(true);
        browse.setText("Supprimer l'import");
    } else {
        browse.setEnabled(false);
    }
    type.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            if (combo.getSelectedIndex() == 1) {
                browse.setEnabled(true);
                adress.setEnabled(true);
                adress.setEditable(true);
            } else {
                browse.setEnabled(false);
                adress.setEnabled(false);
                adress.setEditable(false);
            }
            gs.set("type", combo.getSelectedIndex());
        }

    });
    subTypePanel.add(type);
    JPanel typePanel = new JPanel();
    typePanel.setLayout(new BoxLayout(typePanel, BoxLayout.PAGE_AXIS));

    typePanel.add(subTypePanel);
    JPanel browsePanel = new JPanel();
    browsePanel.add(browse);
    JPanel adressPanel = new JPanel();
    adressPanel.setLayout(new BoxLayout(adressPanel, BoxLayout.PAGE_AXIS));
    JLabel adressLabel = new JLabel("Adresse de tlchargement :");
    adressPanel.setPreferredSize(new Dimension(0, 47));
    adress.setPreferredSize(new Dimension(0, 30));
    adressPanel.add(adressLabel);
    adressPanel.add(adress);
    typePanel.add(adressPanel);

    this.add(typePanel);
    closeOnStart.setSelected(true);
    closeOnStart.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (closeOnStart.isSelected()) {
                gs.set("close", true);
            } else {
                gs.set("close", false);
            }
        }

    });
    this.add(closeOnStart);

    JPanel look = new JPanel();
    look.setBorder(BorderFactory.createTitledBorder("Apparence"));
    look.setPreferredSize(new Dimension(290, 340));
    JPanel colors = new JPanel();
    cDark.setSelected(true);
    bg.add(cLight);
    bg.add(cDark);
    colors.add(cLight);
    colors.add(cDark);
    cLight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            gs.set("color", 0);
        }

    });
    cDark.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            gs.set("color", 1);
        }

    });
    look.add(colors);
    JPanel checks = new JPanel();
    checks.setLayout(new BoxLayout(checks, BoxLayout.PAGE_AXIS));
    borders.setSelected(true);
    borders.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (borders.isSelected()) {
                gs.set("borders", true);
            } else {
                gs.set("borders", false);
            }
        }

    });
    resize.setSelected(true);
    resize.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (resize.isSelected()) {
                gs.set("resizable", true);
            } else {
                gs.set("resizable", false);
            }
        }

    });
    alwaysOnTop.setSelected(false);
    alwaysOnTop.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (alwaysOnTop.isSelected()) {
                gs.set("top", true);
            } else {
                gs.set("top", false);
            }
        }

    });
    checks.add(borders);
    checks.add(resize);
    checks.add(alwaysOnTop);
    checks.setPreferredSize(new Dimension(270, 60));

    JPanel size = new JPanel();
    width.setPreferredSize(new Dimension(57, 30));
    widthMin.setPreferredSize(new Dimension(57, 30));
    widthMax.setPreferredSize(new Dimension(57, 30));
    height.setPreferredSize(new Dimension(57, 30));
    heightMin.setPreferredSize(new Dimension(57, 30));
    heightMax.setPreferredSize(new Dimension(57, 30));
    JPanel widthPanel = new JPanel();
    widthPanel.setPreferredSize(new Dimension(130, 150));
    widthPanel.setBorder(BorderFactory.createTitledBorder("Largeur"));
    widthPanel.setLayout(new BoxLayout(widthPanel, BoxLayout.PAGE_AXIS));
    JPanel widthPanelBase = new JPanel();
    widthPanelBase.add(new JLabel("Base :"));
    widthPanelBase.add(width);
    JPanel widthPanelMin = new JPanel();
    widthPanelMin.add(new JLabel("Min :"));
    widthPanelMin.add(Box.createRigidArea(new Dimension(5, 1)));
    widthPanelMin.add(widthMin);
    JPanel widthPanelMax = new JPanel();
    widthPanelMax.add(new JLabel("Max :"));
    widthPanelMax.add(Box.createRigidArea(new Dimension(3, 1)));
    widthPanelMax.add(widthMax);
    widthPanel.add(widthPanelBase);
    widthPanel.add(widthPanelMin);
    widthPanel.add(widthPanelMax);

    JPanel heightPanel = new JPanel();
    heightPanel.setPreferredSize(new Dimension(130, 150));
    heightPanel.setBorder(BorderFactory.createTitledBorder("Hauteur"));
    heightPanel.setLayout(new BoxLayout(heightPanel, BoxLayout.PAGE_AXIS));
    JPanel heightPanelBase = new JPanel();
    heightPanelBase.add(new JLabel("Base :"));
    heightPanelBase.add(height);
    JPanel heightPanelMin = new JPanel();
    heightPanelMin.add(new JLabel("Min :"));
    heightPanelMin.add(Box.createRigidArea(new Dimension(5, 1)));
    heightPanelMin.add(heightMin);
    JPanel heightPanelMax = new JPanel();
    heightPanelMax.add(new JLabel("Max :"));
    heightPanelMax.add(Box.createRigidArea(new Dimension(3, 1)));
    heightPanelMax.add(heightMax);
    heightPanel.add(heightPanelBase);
    heightPanel.add(heightPanelMin);
    heightPanel.add(heightPanelMax);
    size.add(widthPanel);
    size.add(heightPanel);

    width.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            gs.set("width", spinner.getValue());
        }
    });
    widthMin.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            gs.set("widthMin", spinner.getValue());
        }
    });
    widthMax.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            ;
            gs.set("widthMax", spinner.getValue());
        }
    });
    height.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            gs.set("height", spinner.getValue());
        }
    });
    heightMin.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            gs.set("heightMin", spinner.getValue());
        }
    });
    heightMax.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            ;
            gs.set("heightMax", spinner.getValue());
        }
    });

    look.add(checks);
    look.add(size);

    JPanel bottom = new JPanel();
    bottom.setLayout(new BoxLayout(bottom, BoxLayout.LINE_AXIS));
    JButton music = new JButton("Ajouter de la musique");
    music.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new MusicFrame((JFrame) SwingUtilities.windowForComponent(adress), gs);
        }

    });
    bottom.add(music);
    JButton icons = new JButton("Icnes");
    icons.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new IconFrame((JFrame) SwingUtilities.windowForComponent(adress));
        }

    });
    bottom.add(icons);

    look.add(bottom);

    this.add(look);

    load();
}