List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:de.unidue.inf.is.ezdl.gframedl.components.checkboxlist.CheckBoxListCellRenderer.java
private void initialize() { panel = new JPanel(); panel.setLayout(new BorderLayout()); choicePanel = new JPanel(new BorderLayout()); choice = new JCheckBox(); choicePanel.add(choice, BorderLayout.CENTER); choicePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); choicePanel.setPreferredSize(new Dimension(150, 48)); description = new JTextArea(); description.setOpaque(true);// w ww . j ava2 s . co m description.setEditable(false); description.setLineWrap(true); description.setWrapStyleWord(true); description.setSize(400, 30); description.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); iconLabel = new JLabel(); iconLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); choicePanel.add(iconLabel, BorderLayout.EAST); panel.add(choicePanel, BorderLayout.WEST); panel.add(description, BorderLayout.CENTER); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.revalidate(); panel.repaint(); }
From source file:unusedClasses.MemoryUsageDemo.java
public MemoryUsageDemo(int paramInt) { super(new BorderLayout()); this.total.setMaximumItemAge(paramInt); this.free = new TimeSeries("Free Memory"); this.free.setMaximumItemAge(paramInt); TimeSeriesCollection localTimeSeriesCollection = new TimeSeriesCollection(); localTimeSeriesCollection.addSeries(this.total); localTimeSeriesCollection.addSeries(this.free); DateAxis localDateAxis = new DateAxis("Time"); NumberAxis localNumberAxis = new NumberAxis("Memory"); localDateAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); localNumberAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); localDateAxis.setLabelFont(new Font("SansSerif", 0, 14)); localNumberAxis.setLabelFont(new Font("SansSerif", 0, 14)); XYLineAndShapeRenderer localXYLineAndShapeRenderer = new XYLineAndShapeRenderer(true, false); localXYLineAndShapeRenderer.setSeriesPaint(0, Color.red); localXYLineAndShapeRenderer.setSeriesPaint(1, Color.green); localXYLineAndShapeRenderer.setSeriesStroke(0, new BasicStroke(3.0F, 0, 2)); localXYLineAndShapeRenderer.setSeriesStroke(1, new BasicStroke(3.0F, 0, 2)); XYPlot localXYPlot = new XYPlot(localTimeSeriesCollection, localDateAxis, localNumberAxis, localXYLineAndShapeRenderer); localDateAxis.setAutoRange(true);/* ww w.ja v a 2s.c om*/ localDateAxis.setLowerMargin(0.0D); localDateAxis.setUpperMargin(0.0D); localDateAxis.setTickLabelsVisible(true); localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart localJFreeChart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), localXYPlot, true); ChartUtilities.applyCurrentTheme(localJFreeChart); ChartPanel localChartPanel = new ChartPanel(localJFreeChart, true); localChartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); add(localChartPanel); }
From source file:LabelDnD2.java
public LabelDnD2() { super(new BorderLayout()); JColorChooser chooser = new JColorChooser(); chooser.setDragEnabled(true);// w w w . j a v a 2s . c o m label = new JLabel("I'm a Label and I accept color!", SwingConstants.LEADING); label.setTransferHandler(new TransferHandler("foreground")); MouseListener listener = new DragMouseAdapter(); label.addMouseListener(listener); JPanel lpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drop color onto the label"); lpanel.add(label); lpanel.setBorder(t2); add(chooser, BorderLayout.CENTER); add(lpanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:LabelDnD.java
public LabelDnD() { super(new GridLayout(2, 1)); textField = new JTextField(40); textField.setDragEnabled(true);/*from w w w.j a v a2 s . c o m*/ JPanel tfpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t1 = BorderFactory.createTitledBorder("JTextField: drag and drop is enabled"); tfpanel.add(textField); tfpanel.setBorder(t1); label = new JLabel("I'm a Label!", SwingConstants.LEADING); label.setTransferHandler(new TransferHandler("text")); MouseListener listener = new DragMouseAdapter(); label.addMouseListener(listener); JPanel lpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drag from or drop to this label"); lpanel.add(label); lpanel.setBorder(t2); add(tfpanel); add(lpanel); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:com.haulmont.cuba.desktop.sys.MenuBuilder.java
private void createMenuBarItem(JMenuBar menuBar, MenuItem item) { String caption = menuConfig.getItemCaption(item.getId()); if (!item.getChildren().isEmpty() || item.isMenu()) { final JMenu jMenu = new JMenu(caption); jMenu.addMenuListener(new MenuListener() { @Override/*w w w . j a v a 2 s.co m*/ public void menuSelected(MenuEvent e) { jMenu.requestFocus(); } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); jMenu.setName(item.getId()); menuBar.add(jMenu); createSubMenu(jMenu, item); } else { JMenuItem jMenuItem = new JMenuItem(caption); jMenuItem.setName(item.getId()); //todo remove hardcoded border jMenuItem.setBorder(BorderFactory.createEmptyBorder(1, 4, 2, 4)); assignShortcut(jMenuItem, item); jMenuItem.setMaximumSize( new Dimension(jMenuItem.getPreferredSize().width, jMenuItem.getMaximumSize().height)); assignCommand(jMenuItem, item); menuBar.add(jMenuItem); } }
From source file:misc.FocusTraversalDemo.java
public FocusTraversalDemo() { super(new BorderLayout()); JTextField tf1 = new JTextField("Field 1"); JTextField tf2 = new JTextField("A Bigger Field 2"); JTextField tf3 = new JTextField("Field 3"); JTextField tf4 = new JTextField("A Bigger Field 4"); JTextField tf5 = new JTextField("Field 5"); JTextField tf6 = new JTextField("A Bigger Field 6"); JTable table = new JTable(4, 3); togglePolicy = new JCheckBox("Custom FocusTraversalPolicy"); togglePolicy.setActionCommand("toggle"); togglePolicy.addActionListener(this); togglePolicy.setFocusable(false); //Remove it from the focus cycle. //Note that HTML is allowed and will break this run of text //across two lines. label = new JLabel( "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>"); JPanel leftTextPanel = new JPanel(new GridLayout(3, 2)); leftTextPanel.add(tf1, BorderLayout.PAGE_START); leftTextPanel.add(tf3, BorderLayout.CENTER); leftTextPanel.add(tf5, BorderLayout.PAGE_END); leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel rightTextPanel = new JPanel(new GridLayout(3, 2)); rightTextPanel.add(tf2, BorderLayout.PAGE_START); rightTextPanel.add(tf4, BorderLayout.CENTER); rightTextPanel.add(tf6, BorderLayout.PAGE_END); rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel tablePanel = new JPanel(new GridLayout(0, 1)); tablePanel.add(table, BorderLayout.CENTER); tablePanel.setBorder(BorderFactory.createEtchedBorder()); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(togglePolicy, BorderLayout.PAGE_START); bottomPanel.add(label, BorderLayout.PAGE_END); add(leftTextPanel, BorderLayout.LINE_START); add(rightTextPanel, BorderLayout.CENTER); add(tablePanel, BorderLayout.LINE_END); add(bottomPanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); Vector<Component> order = new Vector<Component>(7); order.add(tf1);/* w ww. j a va2 s . c o m*/ order.add(tf2); order.add(tf3); order.add(tf4); order.add(tf5); order.add(tf6); order.add(table); newPolicy = new MyOwnFocusTraversalPolicy(order); }
From source file:FocusEventDemo.java
public void addComponentsToPane(final Container pane) { GridBagLayout gridbag = new GridBagLayout(); pane.setLayout(gridbag);/*from ww w .j av a 2 s . c o m*/ GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; // Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField); c.weightx = 0.1; // Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector<String> vector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector<String> listVector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); // It's easier to see the focus change // if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; // Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; // Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); // The setRequestFocusEnabled method prevents a // component from being clickable, but it can still // get the focus through the keyboard - this ensures // user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:ComboBoxDemo2.java
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // 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:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true);/*from w ww . j a v a 2s. c o m*/ patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == // LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:com.floreantpos.ui.forms.QuickCustomerForm.java
private void createCustomerForm() { setLayout(new BorderLayout(10, 10)); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setOpaque(true);/* ww w .j ava 2 s . c o m*/ JPanel inputPanel = new JPanel(); inputPanel.setLayout(new MigLayout("insets 10 10 10 10", "[][][][]", "[][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ inputPanel.setBorder(BorderFactory.createTitledBorder("Enter Customer Information")); JLabel lblAddress = new JLabel(Messages.getString("CustomerForm.18")); //$NON-NLS-1$ tfAddress = new JTextArea(new FixedLengthDocument(220)); JScrollPane scrlDescription = new JScrollPane(tfAddress); scrlDescription.setPreferredSize(PosUIManager.getSize(338, 52)); JLabel lblZip = new JLabel(Messages.getString("CustomerForm.21")); //$NON-NLS-1$ tfZip = new FixedLengthTextField(30); JLabel lblCitytown = new JLabel(Messages.getString("CustomerForm.24")); //$NON-NLS-1$ tfCity = new FixedLengthTextField(); JLabel lblState = new JLabel(Messages.getString("QuickCustomerForm.0")); //$NON-NLS-1$ tfState = new JTextField(30); JLabel lblCellPhone = new JLabel(Messages.getString("CustomerForm.32")); //$NON-NLS-1$ inputPanel.add(lblCellPhone, "cell 0 1,alignx right"); //$NON-NLS-1$ tfCellPhone = new JTextField(30); inputPanel.add(tfCellPhone, "cell 1 1"); //$NON-NLS-1$ //setPreferredSize(PosUIManager.getSize(800, 350)); JLabel lblFirstName = new JLabel(Messages.getString("CustomerForm.3")); //$NON-NLS-1$ //inputPanel.add(lblFirstName, "cell 0 2,alignx right"); //$NON-NLS-1$ tfFirstName = new FixedLengthTextField(); //inputPanel.add(tfFirstName, "cell 1 2"); //$NON-NLS-1$ JLabel lblLastName = new JLabel(Messages.getString("CustomerForm.11")); //$NON-NLS-1$ //inputPanel.add(lblLastName, "cell 0 3,alignx right"); //$NON-NLS-1$ tfLastName = new FixedLengthTextField(); //inputPanel.add(tfLastName, "cell 1 3"); //$NON-NLS-1$ JLabel lblName = new JLabel("Name"); //$NON-NLS-1$ inputPanel.add(lblName, "cell 0 3,alignx right"); //$NON-NLS-1$ tfName = new FixedLengthTextField(); tfName.setLength(120); inputPanel.add(tfName, "cell 1 3"); //$NON-NLS-1$ inputPanel.add(lblZip, "cell 0 4,right"); //$NON-NLS-1$ inputPanel.add(tfZip, "cell 1 4"); //$NON-NLS-1$ inputPanel.add(lblCitytown, "cell 0 5,right"); //$NON-NLS-1$ inputPanel.add(tfCity, "cell 1 5"); //$NON-NLS-1$ inputPanel.add(lblState, "cell 0 6,right"); //$NON-NLS-1$ inputPanel.add(tfState, "cell 1 6"); //$NON-NLS-1$ inputPanel.add(lblAddress, "cell 2 1 1 6,right"); //$NON-NLS-1$ inputPanel.add(scrlDescription, "grow, cell 3 1 1 6"); //$NON-NLS-1$ qwertyKeyPad = new QwertyKeyPad(); add(inputPanel, BorderLayout.CENTER); if (isKeypad) { add(qwertyKeyPad, BorderLayout.SOUTH); //$NON-NLS-1$ } tfZip.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getStateAndCityByZipCode(); } }); tfZip.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { getStateAndCityByZipCode(); } @Override public void focusGained(FocusEvent e) { } }); enableCustomerFields(false); callOrderController(); }
From source file:components.ProgressMonitorDemo.java
public ProgressMonitorDemo() { super(new BorderLayout()); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false);//w ww .ja v a2 s . co m add(startButton, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }