List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:ShowDocument.java
public URLWindow(AppletContext appletContext) { super("Show a Document!"); this.appletContext = appletContext; JPanel contentPane = new JPanel(new GridBagLayout()); setContentPane(contentPane);//from ww w.j a v a 2s .c om contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; JLabel label1 = new JLabel("URL of document to show: ", JLabel.TRAILING); add(label1, c); urlField = new JTextField("http://java.sun.com/", 20); label1.setLabelFor(urlField); urlField.addActionListener(this); c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; add(urlField, c); JLabel label2 = new JLabel("Window/frame to show it in: ", JLabel.TRAILING); c.gridwidth = 1; c.weightx = 0.0; add(label2, c); String[] strings = { "(browser's choice)", //don't specify "My Personal Window", //a window named "My Personal Window" "_blank", //a new, unnamed window "_self", "_parent", "_top" //the Frame that contained this applet }; choice = new JComboBox(strings); label2.setLabelFor(choice); c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.REMAINDER; c.insets = new Insets(5, 0, 0, 0); c.anchor = GridBagConstraints.LINE_START; add(choice, c); JButton button = new JButton("Show document"); button.addActionListener(this); c.weighty = 1.0; c.ipadx = 10; c.ipady = 10; c.insets = new Insets(10, 0, 0, 0); c.anchor = GridBagConstraints.PAGE_END; add(button, c); }
From source file:SwingMouseMotionEventDemo.java
public SwingMouseMotionEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;/*from w w w . ja va2s.c o m*/ c.weighty = 1.0; c.insets = new Insets(1, 1, 1, 1); blankArea = new BlankArea(new Color(0.98f, 0.97f, 0.85f)); gridbag.setConstraints(blankArea, c); add(blankArea); c.insets = new Insets(0, 0, 0, 0); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setPreferredSize(new Dimension(200, 75)); gridbag.setConstraints(scrollPane, c); add(scrollPane); //Register for mouse events on blankArea and panel. blankArea.addMouseMotionListener(this); addMouseMotionListener(this); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:net.pandoragames.far.ui.swing.dialog.SaveFormDialog.java
private void init(SwingConfig config) { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel basePanel = new JPanel(); basePanel.setBorder(BorderFactory.createEmptyBorder(SwingConfig.PADDING * 2, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); basePanel.setLayout(new BorderLayout()); registerCloseWindowKeyListener(basePanel); this.add(basePanel); MessageLabel errorLabel = new MessageLabel(); basePanel.add(errorLabel, BorderLayout.NORTH); messageBox = errorLabel;/*from w ww . ja va2 s .c o m*/ JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS)); JLabel titleLabel = new JLabel(localizer.localize("label.name")); titleLabel.setAlignmentX(0); centerPanel.add(titleLabel); textbox = new JTextField(); textbox.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight())); textbox.setAlignmentX(0); registerEnterKeyListener(textbox, saveAction); centerPanel.add(textbox); basePanel.add(centerPanel, BorderLayout.CENTER); JPanel buttonPannel = new JPanel(); buttonPannel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(localizer.localize("button.save")); okButton.addActionListener(saveAction); JButton cancelButton = new JButton(localizer.localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent eve) { SaveFormDialog.this.dispose(); } }); buttonPannel.add(okButton); buttonPannel.add(cancelButton); registerCloseWindowKeyListener(buttonPannel); this.add(buttonPannel, BorderLayout.SOUTH); }
From source file:org.ietr.preesm.mapper.ui.stats.PerformancePlotter.java
/** * Constructs a new demonstration application. * //from ww w. j a v a 2s . c o m * @param title * the frame title. */ public PerformancePlotter(final String title) { super(title); JFreeChart chart = createChart(title); final JPanel content = new JPanel(new BorderLayout()); chartPanel = new ChartPanel(chart); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); }
From source file:net.sf.jabref.openoffice.CitationManager.java
public CitationManager(final JabRefFrame frame, OOBibBase ooBase) throws NoSuchElementException, WrappedTargetException, UnknownPropertyException { diag = new JDialog(frame, Localization.lang("Manage citations"), true); this.ooBase = ooBase; list = new BasicEventList<>(); XNameAccess nameAccess = ooBase.getReferenceMarks(); java.util.List<String> names = ooBase.getJabRefReferenceMarks(nameAccess); for (String name : names) { list.add(new CitEntry(name, "<html>..." + ooBase.getCitationContext(nameAccess, name, 30, 30, true) + "...</html>", ooBase.getCustomProperty(name))); }//from w w w. j ava 2s . c om tableModel = new DefaultEventTableModel<>(list, new CitEntryFormat()); table = new JTable(tableModel); diag.add(new JScrollPane(table), BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); JButton ok = new JButton(Localization.lang("OK")); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setSize(700, 400); ok.addActionListener(e -> { try { storeSettings(); } catch (UnknownPropertyException | NotRemoveableException | PropertyExistException | IllegalTypeException | IllegalArgumentException ex) { LOGGER.warn("Problem modifying citation", ex); JOptionPane.showMessageDialog(frame, Localization.lang("Problem modifying citation")); } diag.dispose(); }); Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { diag.dispose(); } }; cancel.addActionListener(cancelAction); bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); bb.getPanel().getActionMap().put("close", cancelAction); table.getColumnModel().getColumn(0).setPreferredWidth(600); table.getColumnModel().getColumn(1).setPreferredWidth(90); table.setPreferredScrollableViewportSize(new Dimension(700, 500)); table.addMouseListener(new TableClickListener()); }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
public WebServiceExportDialog(JuxtaAuthorFrame frame, WebServiceClient wsClient) { super(frame); this.juxtaFrame = frame; if (wsClient == null) { this.wsClient = new WebServiceClient(frame.getWebServiceUrl()); } else {//from ww w. j a va2 s . c o m this.wsClient = wsClient; } // size and title the main dialog body setTitle("Juxta Web Export"); setResizable(false); setSize(495, 345); setLocationRelativeTo(getParent()); ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); getContentPane().setLayout(new BorderLayout(15, 15)); getContentPane().setBackground(Color.white); // add the logo to the top left JPanel logoPnl = new JPanel(); logoPnl.setBackground(Color.white); logoPnl.setLayout(new BoxLayout(logoPnl, BoxLayout.Y_AXIS)); logoPnl.add(new JLabel(JuxtaUserInterfaceStyle.JUXTA_LOGO)); logoPnl.add(Box.createVerticalGlue()); getContentPane().add(logoPnl, BorderLayout.WEST); createSetupPane(); createStatusPane(); getContentPane().add(this.setupPanel, BorderLayout.CENTER); getContentPane().add(createButtonBar(), BorderLayout.SOUTH); // create a single scheduled executor to periodically // check for export status. There can only be one at any // give time, so a pool seemed unnecessary this.scheduler = Executors.newSingleThreadScheduledExecutor(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); }
From source file: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.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);/*from w ww. j a va 2s.co 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:dnd.ChooseDropActionDemo.java
public ChooseDropActionDemo() { super("ChooseDropActionDemo"); for (int i = 15; i >= 0; i--) { from.add(0, "Source item " + i); }/*ww w. j av a 2 s .co m*/ for (int i = 2; i >= 0; i--) { copy.add(0, "Target item " + i); move.add(0, "Target item " + i); } JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); dragFrom = new JList(from); dragFrom.setTransferHandler(new FromTransferHandler()); dragFrom.setPrototypeCellValue("List Item WWWWWW"); dragFrom.setDragEnabled(true); dragFrom.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JLabel label = new JLabel("Drag from here:"); label.setAlignmentX(0f); p.add(label); JScrollPane sp = new JScrollPane(dragFrom); sp.setAlignmentX(0f); p.add(sp); add(p, BorderLayout.WEST); JList moveTo = new JList(move); moveTo.setTransferHandler(new ToTransferHandler(TransferHandler.COPY)); moveTo.setDropMode(DropMode.INSERT); JList copyTo = new JList(copy); copyTo.setTransferHandler(new ToTransferHandler(TransferHandler.MOVE)); copyTo.setDropMode(DropMode.INSERT); p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); label = new JLabel("Drop to COPY to here:"); label.setAlignmentX(0f); p.add(label); sp = new JScrollPane(moveTo); sp.setAlignmentX(0f); p.add(sp); label = new JLabel("Drop to MOVE to here:"); label.setAlignmentX(0f); p.add(label); sp = new JScrollPane(copyTo); sp.setAlignmentX(0f); p.add(sp); p.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); add(p, BorderLayout.CENTER); ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); getContentPane().setPreferredSize(new Dimension(320, 315)); }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java
private JPanel getBorderedThrobber(final ThrobberBarWithText throbber) { final JPanel borderedThrobber = new JPanel(new BorderLayout()); borderedThrobber.add(throbber, BorderLayout.CENTER); borderedThrobber.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); return borderedThrobber; }
From source file:components.ProgressBarDemo.java
public ProgressBarDemo() { super(new BorderLayout()); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); progressBar = new JProgressBar(0, 100); progressBar.setValue(0);// w ww .j ava2 s. c o m progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); JPanel panel = new JPanel(); panel.add(startButton); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }