List of usage examples for javax.swing JPanel setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:de.ipk_gatersleben.ag_pbi.mmd.visualisations.gradient.GradientDataChartComponent.java
public static JPanel prettifyChart(org.graffiti.graph.GraphElement ge, ChartOptions co, JFreeChart jfChart, int idx) { if (jfChart.getTitle() != null) { jfChart.getTitle().setFont(NodeTools.getChartTitleFont(ge)); jfChart.getTitle().setPaint(NodeTools.getChartTitleColor(ge)); }// w ww. j ava 2s .com ChartPanel jfreechartPanel = new ChartPanel(jfChart, false); JPanel chartPanel = jfreechartPanel; Color cbc = NodeTools.getChartBackgroundColor(ge, idx); if (cbc != null) { chartPanel.setOpaque(true); chartPanel.setBackground(cbc); } else { chartPanel.setOpaque(false); chartPanel.setBackground(null); } if (chartPanel instanceof ChartPanel) { ChartPanel cp = (ChartPanel) chartPanel; cp.setMinimumDrawHeight(300); cp.setMinimumDrawWidth(330); } if (co.borderHor > 0) chartPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 3, 0)); return chartPanel; }
From source file:SampleButton.java
public SampleButton() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JButton b = new JButton("Test"); b.setHorizontalTextPosition(SwingConstants.LEFT); b.setIcon(new ImageIcon("r.gif")); b.setRolloverIcon(new ImageIcon("b.gif")); b.setRolloverEnabled(true);/* w w w. j a v a 2s. c o m*/ b.setMnemonic('t'); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Button pressed"); } }); p.add(b); getContentPane().add(p); pack(); }
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 ww . jav a 2 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 SplashScreen() { Container container = getContentPane(); JPanel panel = new JPanel(); panel.setBorder(new EtchedBorder()); container.add(panel, BorderLayout.CENTER); JLabel label = new JLabel("Hello World!"); label.setFont(new Font("Verdana", Font.BOLD, 14)); panel.add(label);//from w w w .ja v a 2s . c o m progressBar.setMaximum(PROGBAR_MAX); container.add(progressBar, BorderLayout.SOUTH); pack(); setVisible(true); startProgressBar(); }
From source file:Main.java
public Main() { JPanel borderLayoutPanel = new JPanel(new BorderLayout()); borderLayoutPanel.setBorder(BorderFactory.createTitledBorder("BorderLayout Panel")); borderLayoutPanel.add(createGridPanel(), BorderLayout.CENTER); JPanel flowLayoutPanel = new JPanel(new FlowLayout()); flowLayoutPanel.setBorder(BorderFactory.createTitledBorder("FlowLayout Panel")); flowLayoutPanel.add(createGridPanel()); setBorder(BorderFactory.createEmptyBorder(GAP, GAP, GAP, GAP)); setLayout(new GridLayout(1, 0, GAP, 0)); add(borderLayoutPanel);//from w w w. j ava 2 s . c o m add(flowLayoutPanel); }
From source file:QandE.Test1.java
public Component createComponents() { final JLabel label = new JLabel(labelText); /*//from ww w.jav a 2 s .c o m * An easy way to put space between a top-level container * and its contents is to put the contents in a JPanel * that has an "empty" border. */ JPanel pane = new JPanel(); pane.setBorder(BorderFactory.createEmptyBorder(30, //top 30, //left 10, //bottom 30) //right ); pane.setLayout(new GridLayout(0, 1)); pane.add(label); return pane; }
From source file:Main.java
public Main() { getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); JPanel panel1 = new JPanel(); Border eBorder = BorderFactory.createEtchedBorder(); panel1.setBorder(BorderFactory.createTitledBorder(eBorder, "70pct")); gbc.gridx = gbc.gridy = 0;//from w w w . j a va 2s . c om gbc.gridwidth = gbc.gridheight = 1; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = gbc.weighty = 70; getContentPane().add(panel1, gbc); JPanel panel2 = new JPanel(); panel2.setBorder(BorderFactory.createTitledBorder(eBorder, "30pct")); gbc.gridy = 1; gbc.weightx = 30; gbc.weighty = 30; gbc.insets = new Insets(2, 2, 2, 2); getContentPane().add(panel2, gbc); pack(); }
From source file:Main.java
public Main() { this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTH; gbc.weighty = 0.0;/*w w w .j av a 2 s .c o m*/ JPanel one = new JPanel(); one.setPreferredSize(new Dimension(200, 200)); one.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JPanel two = new JPanel(); two.setPreferredSize(new Dimension(200, 200)); two.setBorder(BorderFactory.createLineBorder(Color.BLACK)); this.add(one, gbc); gbc.gridy = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.VERTICAL; this.add(two, gbc); this.pack(); this.setVisible(true); }
From source file:Main.java
public JPanel createUI() { intro.setLabelFor(name);/*from w ww . j a va 2s .c om*/ final JButton button = new JButton("Pick a new name..."); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); intro.setAlignmentX(JComponent.CENTER_ALIGNMENT); name.setAlignmentX(JComponent.CENTER_ALIGNMENT); button.setAlignmentX(JComponent.CENTER_ALIGNMENT); panel.add(intro); panel.add(Box.createVerticalStrut(5)); panel.add(name); panel.add(Box.createRigidArea(new Dimension(150, 10))); panel.add(button); return panel; }
From source file:Main.java
public ConfirmDialog(Frame parent) { super(parent, true); JPanel gui = new JPanel(new BorderLayout(3, 3)); gui.setBorder(new EmptyBorder(5, 5, 5, 5)); content = new JPanel(new BorderLayout()); gui.add(content, BorderLayout.CENTER); JPanel buttons = new JPanel(new FlowLayout(4)); gui.add(buttons, BorderLayout.SOUTH); JButton ok = new JButton("OK"); buttons.add(ok);/*from ww w .ja v a 2s . co m*/ ok.addActionListener(e -> { result = OK_OPTION; setVisible(false); }); JButton cancel = new JButton("Cancel"); buttons.add(cancel); cancel.addActionListener(e -> { result = CANCEL_OPTION; setVisible(false); }); setContentPane(gui); }