List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:BorderTest.java
public BorderTest() { JPanel p = new JPanel(); Border[] border = new Border[] { BorderFactory.createEtchedBorder(), BorderFactory.createTitledBorder("Border types"), BorderFactory.createLoweredBevelBorder(), BorderFactory.createRaisedBevelBorder(), BorderFactory.createEtchedBorder(), BorderFactory.createLineBorder(Color.blue), BorderFactory.createMatteBorder(10, 10, 10, 10, Color.blue), BorderFactory.createEmptyBorder() };//w w w .ja va2 s.co m p.setLayout(new GridLayout(border.length, 0, 3, 3)); for (int i = 0; i < border.length; i++) { JPanel borderPanel = new JPanel(); borderPanel.setBorder(border[i]); p.add(borderPanel); } getContentPane().add(p, "Center"); setTitle("BorderTest"); setSize(600, 400); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
From source file:Main.java
public Main() { Container content = getContentPane(); content.setBackground(Color.white); JSlider slider1 = new JSlider(); slider1.setBorder(BorderFactory.createTitledBorder("JSlider without Tick Marks")); content.add(slider1, BorderLayout.NORTH); JSlider slider2 = new JSlider(); slider2.setBorder(BorderFactory.createTitledBorder("JSlider with Tick Marks")); slider2.setMajorTickSpacing(20);//from w ww . j a v a 2 s . co m slider2.setMinorTickSpacing(5); slider2.setPaintTicks(true); content.add(slider2, BorderLayout.CENTER); JSlider slider3 = new JSlider(); slider3.setBorder(BorderFactory.createTitledBorder("JSlider with Tick Marks & Labels")); slider3.setMajorTickSpacing(20); slider3.setMinorTickSpacing(5); slider3.setPaintTicks(true); slider3.setPaintLabels(true); content.add(slider3, BorderLayout.SOUTH); setSize(300, 300); setVisible(true); }
From source file:Main.java
public Main() { getContentPane().setLayout(new FlowLayout()); JLabel labelTwo = new JLabel("www.java2s.com"); labelTwo.setBorder(BorderFactory.createEtchedBorder()); add(labelTwo);/*w w w . ja v a 2s . c o m*/ JLabel labelFour = new JLabel("TitledBorder"); labelFour.setBorder( BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink))); add(labelFour); }
From source file:Main.java
/** * Sets a title for the given component by surrounding it with a CompoundBorder * /* w ww . j ava 2s.c o m*/ * @param component the component * @param title the title of the component */ public static void setTitle(JComponent component, String title) { component.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title), BorderFactory.createEmptyBorder(5, 5, 5, 5))); }
From source file:Main.java
public static JPanel createPainelContainer(String title, LayoutManager layout, Component... components) { final JPanel container = new JPanel(); container.setBorder(BorderFactory.createTitledBorder(title)); if (layout != null) container.setLayout(layout);//from ww w .ja va 2 s.com for (Component c : components) { container.add(c); } return container; }
From source file:Main.java
public JPanelOfInterest() { setBorder(BorderFactory.createTitledBorder("Title")); }
From source file:fuel.gui.stats.PieChartPanel.java
public PieChartPanel(DefaultPieDataset pieDataset, String message) { JFreeChart pieChart = ChartFactory.createPieChart3D("", pieDataset, true, true, false); PiePlot3D plot1 = (PiePlot3D) pieChart.getPlot(); plot1.setForegroundAlpha(0.6f);/*from w w w .j a v a 2s . com*/ //plot3.setCircular(true); ChartPanel barChartPanel = new ChartPanel(pieChart); barChartPanel.getChartRenderingInfo().setEntityCollection(null); barChartPanel.setBorder(BorderFactory.createTitledBorder(message)); barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240)); barChartPanel.setLayout(new BorderLayout()); setLayout(new BorderLayout()); add(barChartPanel); }
From source file:edu.pdi2.visual.extradialogs.SignatureDialog.java
private void initGUI() { try {//from w w w. j av a 2s. co m { getContentPane().setLayout(null); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { thisWindowClosing(evt); } }); { chartpanel = new ChartPanel(signatureG); getContentPane().add(chartpanel); chartpanel.setBorder(BorderFactory.createTitledBorder("")); chartpanel.setBounds(6, 5, 386, 211); } } this.setSize(410, 254); } catch (Exception e) { e.printStackTrace(); } }
From source file:fr.duminy.jbackup.swing.ProgressPanel.java
public ProgressPanel(String title) { super(new BorderLayout()); setBorder(BorderFactory.createTitledBorder(title)); progressBar.setName("progress"); progressBar.setIndeterminate(true);//from w w w.j a va 2 s . co m progressBar.setStringPainted(true); progressBar.setString("Not started"); add(progressBar, BorderLayout.CENTER); }
From source file:PizzaGridBagLayout.java
public PizzaGridBagLayout() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel1 = new JPanel(); panel1.setLayout(new GridBagLayout()); addItem(panel1, new JLabel("Name:"), 0, 0, 1, 1, GridBagConstraints.EAST); addItem(panel1, new JLabel("Phone:"), 0, 1, 1, 1, GridBagConstraints.EAST); addItem(panel1, new JLabel("Address:"), 0, 2, 1, 1, GridBagConstraints.EAST); addItem(panel1, name, 1, 0, 2, 1, GridBagConstraints.WEST); addItem(panel1, phone, 1, 1, 1, 1, GridBagConstraints.WEST); addItem(panel1, address, 1, 2, 2, 1, GridBagConstraints.WEST); Box sizeBox = Box.createVerticalBox(); ButtonGroup sizeGroup = new ButtonGroup(); sizeGroup.add(small);/*from w w w . j ava 2 s . c o m*/ sizeGroup.add(medium); sizeGroup.add(large); sizeBox.add(small); sizeBox.add(medium); sizeBox.add(large); sizeBox.setBorder(BorderFactory.createTitledBorder("Size")); addItem(panel1, sizeBox, 0, 3, 1, 1, GridBagConstraints.NORTH); Box styleBox = Box.createVerticalBox(); ButtonGroup styleGroup = new ButtonGroup(); styleGroup.add(thin); styleGroup.add(thick); styleBox.add(thin); styleBox.add(thick); styleBox.setBorder(BorderFactory. createTitledBorder("Style")); addItem(panel1, styleBox, 1, 3, 1, 1, GridBagConstraints.NORTH); Box topBox = Box.createVerticalBox(); ButtonGroup topGroup = new ButtonGroup(); topGroup.add(pepperoni); topGroup.add(mushrooms); topGroup.add(anchovies); topBox.add(pepperoni); topBox.add(mushrooms); topBox.add(anchovies); topBox.setBorder(BorderFactory.createTitledBorder("Toppings")); addItem(panel1, topBox, 2, 3, 1, 1, GridBagConstraints.NORTH); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(okButton); buttonBox.add(Box.createHorizontalStrut(20)); buttonBox.add(closeButton); addItem(panel1, buttonBox, 2, 4, 1, 1, GridBagConstraints.NORTH); this.add(panel1); this.pack(); this.setVisible(true); }