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:org.jfree.chart.demo.selection.SelectionDemo2.java
/** * A demonstration application showing a scatter plot. * * @param title the frame title.//from ww w . j av a 2 s . c o m */ public SelectionDemo2(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (XYSeriesCollection) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); tcm.getColumn(2).setCellRenderer(new NumberCellRenderer()); tcm.getColumn(3).setCellRenderer(new NumberCellRenderer()); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:BorderDemo.java
void addCompForBorder(Border border, String description, Container container) { JPanel comp = new JPanel(new GridLayout(1, 1), false); JLabel label = new JLabel(description, JLabel.CENTER); comp.add(label);/* w w w . ja v a 2 s. c o m*/ comp.setBorder(border); container.add(Box.createRigidArea(new Dimension(0, 10))); container.add(comp); }
From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java
JPanel getPanel(JTable table, String title) { JScrollPane pane = new JScrollPane(); pane.getViewport().add(table);//from w ww.j a v a 2 s . c om pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 10, 5, 5), BorderFactory.createLoweredBevelBorder())); JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(title)); panel.add(pane, BorderLayout.CENTER); return panel; }
From source file:InternalFrameListenerDemo.java
public InternalFrameListenerDemo() { setTitle("Animated InternalFrameListener"); m_count = m_tencount = 0;//from w w w . jav a 2s .c o m JPanel innerListenerPanel = new JPanel(new GridLayout(7, 1)); JPanel listenerPanel = new JPanel(new BorderLayout()); m_ifEventCanvas = new IFEventCanvas(); m_lOpened = new JLabel("internalFrameOpened"); m_lClosing = new JLabel("internalFrameClosing"); m_lClosed = new JLabel("internalFrameClosed"); m_lIconified = new JLabel("internalFrameIconified"); m_lDeiconified = new JLabel("internalFrameDeiconified"); m_lActivated = new JLabel("internalFrameActivated"); m_lDeactivated = new JLabel("internalFrameDeactivated"); innerListenerPanel.add(m_lOpened); innerListenerPanel.add(m_lClosing); innerListenerPanel.add(m_lClosed); innerListenerPanel.add(m_lIconified); innerListenerPanel.add(m_lDeiconified); innerListenerPanel.add(m_lActivated); innerListenerPanel.add(m_lDeactivated); listenerPanel.add("Center", m_ifEventCanvas); listenerPanel.add("West", innerListenerPanel); listenerPanel.setOpaque(true); listenerPanel.setBackground(Color.white); m_desktop = new JDesktopPane(); m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); m_newFrame = new JButton("New Frame"); m_newFrame.addActionListener(this); m_infos = UIManager.getInstalledLookAndFeels(); String[] LAFNames = new String[m_infos.length]; for (int i = 0; i < m_infos.length; i++) { LAFNames[i] = m_infos[i].getName(); } m_UIBox = new JComboBox(LAFNames); m_UIBox.addActionListener(this); JPanel topPanel = new JPanel(true); topPanel.setLayout(new FlowLayout()); topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED)))); getContentPane().setLayout(new BorderLayout()); getContentPane().add("North", topPanel); getContentPane().add("Center", m_desktop); getContentPane().add("South", listenerPanel); ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED)))); topPanel.add(m_newFrame); topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT)); topPanel.add(m_UIBox); setSize(645, 500); Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); m_eventTimer = new Timer(1000, this); m_eventTimer.setRepeats(true); m_eventTimer.start(); }
From source file:com.aw.swing.mvp.view.ViewManager.java
/** * Setting some default colors to the screens *//*from w ww. j a va 2 s . com*/ private void prepareView() { if (!(presenter instanceof FindPresenter)) { JPanel pnlToolBar = getIpView().getPnlToolBar(); if (pnlToolBar != null) { pnlToolBar.setBackground(new Color(223, 232, 246)); pnlToolBar.setBorder(BorderFactory.createLineBorder(new Color(131, 172, 219), 1)); } } }
From source file:gui.TraitViewerDialog.java
private JPanel createButtons() { bClose = new JButton("Close"); bClose.addActionListener(this); JPanel p1 = new JPanel(new GridLayout(1, 1, 5, 5)); p1.add(bClose);/*from www. ja v a 2 s. c o m*/ JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); p2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); p2.add(p1); return p2; }
From source file:LookAndFeelDemo.java
public Component createComponents() { JButton button = new JButton("I'm a Swing button!"); button.setMnemonic(KeyEvent.VK_I); button.addActionListener(this); label.setLabelFor(button);//from w w w . j a v a 2s .co 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(new GridLayout(0, 1)); pane.add(button); pane.add(label); pane.setBorder(BorderFactory.createEmptyBorder(30, // top 30, // left 10, // bottom 30) // right ); return pane; }
From source file:org.jfree.chart.demo.selection.SelectionDemo3.java
/** * A demonstration application showing a scatter plot. * * @param title the frame title.// w w w .j a v a 2 s.com */ public SelectionDemo3(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (XYSeriesCollection) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); tcm.getColumn(2).setCellRenderer(new NumberCellRenderer()); tcm.getColumn(3).setCellRenderer(new NumberCellRenderer()); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java
private void start() throws Exception { SwingUtilities.invokeLater(() -> { jd = new ViewerParameterDialog("Launch Android App"); JPanel jpParameters = new JPanel(); jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS)); jd.setParameterPanel(jpParameters); {// w w w . j a v a 2 s .co m JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("Devices")); jp.add(jcbDevices); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("App Package Name")); jp.add(jtfApp); if (StringUtils.isNotEmpty(appPackageName)) { jtfApp.setText(appPackageName); } jtfApp.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { jbLaunch.doClick(); } } }); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("Interaction time (minute)")); jsDebugMinutes.getEditor().setEnabled(false); jp.add(jsDebugMinutes); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(Box.createRigidArea(new Dimension(518, 2))); } JPanel jpAction = new JPanel(); jd.setActionPanel(jpAction); jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD)); jbLaunch.setBorder(BorderFactory.createEtchedBorder()); jbLaunch.setEnabled(false); jpAction.add(jbLaunch); jbLaunch.addActionListener(event -> { new Thread() { @Override public void run() { launchApp(); } }.start(); }); jd.showDialog(); new Thread() { @Override public void run() { try { detectDevices(); } catch (Exception ex) { throw new RuntimeException(ex); } } }.start(); }); }
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPDefaultsGui.java
private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder());// w ww. ja v a 2 s . c o m add(makeTitlePanel(), BorderLayout.NORTH); urlConfig = new UPMPUrlConfigGui(false, true, false); add(urlConfig, BorderLayout.CENTER); // OPTIONAL TASKS final JPanel optionalTasksPanel = new VerticalPanel(); optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("optional_tasks"))); // $NON-NLS-1$ final JPanel checkBoxPanel = new HorizontalPanel(); imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$ checkBoxPanel.add(imageParser); imageParser.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); } else { enableConcurrentDwn(false); } } }); // Concurrent resources download concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$ concurrentDwn.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (imageParser.isSelected() && e.getStateChange() == ItemEvent.SELECTED) { concurrentPool.setEnabled(true); } else { concurrentPool.setEnabled(false); } } }); concurrentPool = new JTextField(2); // 2 columns size concurrentPool.setMaximumSize(new Dimension(30, 20)); checkBoxPanel.add(concurrentDwn); checkBoxPanel.add(concurrentPool); optionalTasksPanel.add(checkBoxPanel); // Embedded URL match regex embeddedRE = new JLabeledTextField(JMeterUtils.getResString("web_testing_embedded_url_pattern"), 30); // $NON-NLS-1$ optionalTasksPanel.add(embeddedRE); add(optionalTasksPanel, BorderLayout.SOUTH); }