List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:com.mirth.connect.connectors.file.FileReader.java
public FileReader() { this.parent = PlatformUI.MIRTH_FRAME; setBackground(UIConstants.BACKGROUND_COLOR); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); setLayout(new MigLayout("novisualpadding, hidemode 3, insets 0")); initComponents();/* w w w. ja v a2s . com*/ initLayout(); afterProcessingActionComboBox.setModel( new DefaultComboBoxModel(new FileAction[] { FileAction.NONE, FileAction.MOVE, FileAction.DELETE })); errorReadingActionComboBox.setModel( new DefaultComboBoxModel(new FileAction[] { FileAction.NONE, FileAction.MOVE, FileAction.DELETE })); errorResponseActionComboBox.setModel(new DefaultComboBoxModel( new FileAction[] { FileAction.AFTER_PROCESSING, FileAction.MOVE, FileAction.DELETE })); fileAgeField.setDocument(new MirthFieldConstraints(0, false, false, true)); fileSizeMinimumField.setDocument(new MirthFieldConstraints(0, false, false, true)); fileSizeMaximumField.setDocument(new MirthFieldConstraints(0, false, false, true)); parent.setupCharsetEncodingForConnector(charsetEncodingComboBox); }
From source file:ProgressBarDemo.java
public ProgressBarDemo() { super(new BorderLayout()); task = new LongTask(); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); progressBar = new JProgressBar(0, task.getLengthOfTask()); progressBar.setValue(0);/*from www . j a v a 2s .com*/ progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); taskOutput.setCursor(null); //inherit the panel's cursor //see bug 4851758 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)); //Create a timer. timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { progressBar.setValue(task.getCurrent()); String s = task.getMessage(); if (s != null) { taskOutput.append(s + newline); taskOutput.setCaretPosition(taskOutput.getDocument().getLength()); } if (task.isDone()) { Toolkit.getDefaultToolkit().beep(); timer.stop(); startButton.setEnabled(true); setCursor(null); //turn off the wait cursor progressBar.setValue(progressBar.getMinimum()); } } }); }
From source file:EditorPaneExample7.java
public EditorPaneExample7() { super("JEditorPane Example 7"); pane = new JEditorPane(); pane.setEditable(false); // Start read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/*from w w w .j av a 2 s.c o m*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; c.gridwidth = 2; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); getContentPane().add(panel, "South"); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); saveButton = new JButton("Save"); plain = new JCheckBox("Plain Text"); html = new JCheckBox("HTML"); rtf = new JCheckBox("RTF"); panel.add(plain); panel.add(html); panel.add(rtf); ButtonGroup group = new ButtonGroup(); group.add(plain); group.add(html); group.add(rtf); plain.setSelected(true); panel.add(Box.createVerticalStrut(10)); panel.add(saveButton); panel.add(Box.createVerticalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); getContentPane().add(panel, "East"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String fileName = textField.getText().trim(); file = new File(fileName); absolutePath = file.getAbsolutePath(); String url = "file:///" + absolutePath; try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); saveButton.setEnabled(false); saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); pane.setEditable(false); pane.setPage(url); loadedType.setText(pane.getContentType()); } catch (Exception e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadingState.setText("Page loaded."); textField.setEnabled(true); // Allow entry of new file name textField.requestFocus(); setCursor(Cursor.getDefaultCursor()); // Allow editing and saving if appropriate pane.setEditable(file.canWrite()); saveButton.setEnabled(file.canWrite()); } } }); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Writer w = null; OutputStream os = System.out; String contentType; if (plain.isSelected()) { contentType = "text/plain"; w = new OutputStreamWriter(os); } else if (html.isSelected()) { contentType = "text/html"; w = new OutputStreamWriter(os); } else { contentType = "text/rtf"; } EditorKit kit = pane.getEditorKitForContentType(contentType); try { if (w != null) { kit.write(w, pane.getDocument(), 0, pane.getDocument().getLength()); w.flush(); } else { kit.write(os, pane.getDocument(), 0, pane.getDocument().getLength()); os.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); }
From source file:DragColorTextFieldDemo.java
public DragColorTextFieldDemo() { super(new BorderLayout()); JTextField textField;// w w w .j a va 2 s. co m setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); JColorChooser chooser = new JColorChooser(); chooser.setDragEnabled(true); add(chooser, BorderLayout.PAGE_START); //Create the color transfer handler. colorHandler = new ColorAndTextTransferHandler(); //Create some text fields. JPanel buttonPanel = new JPanel(new GridLayout(3, 1)); textField = new JTextField("I can accept color/text and drag text."); textField.setTransferHandler(colorHandler); textField.setDragEnabled(true); buttonPanel.add(textField); textField = new JTextField("Me too!"); textField.setTransferHandler(colorHandler); textField.setDragEnabled(true); buttonPanel.add(textField); textField = new JTextField("Me three!"); textField.setTransferHandler(colorHandler); textField.setDragEnabled(true); buttonPanel.add(textField); add(buttonPanel, BorderLayout.CENTER); }
From source file:components.SliderDemo2.java
public SliderDemo2() { super(new BorderLayout()); delay = 1000 / FPS_INIT;/*from ww w . j av a 2 s. c om*/ //Create the slider. JSlider framesPerSecond = new JSlider(JSlider.VERTICAL, FPS_MIN, FPS_MAX, FPS_INIT); framesPerSecond.addChangeListener(this); framesPerSecond.setMajorTickSpacing(10); framesPerSecond.setPaintTicks(true); //Create the label table. Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); //PENDING: could use images, but we don't have any good ones. labelTable.put(new Integer(0), new JLabel("Stop")); //new JLabel(createImageIcon("images/stop.gif")) ); labelTable.put(new Integer(FPS_MAX / 10), new JLabel("Slow")); //new JLabel(createImageIcon("images/slow.gif")) ); labelTable.put(new Integer(FPS_MAX), new JLabel("Fast")); //new JLabel(createImageIcon("images/fast.gif")) ); framesPerSecond.setLabelTable(labelTable); framesPerSecond.setPaintLabels(true); framesPerSecond.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); //Create the label that displays the animation. picture = new JLabel(); picture.setHorizontalAlignment(JLabel.CENTER); picture.setAlignmentX(Component.CENTER_ALIGNMENT); picture.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(10, 10, 10, 10))); updatePicture(0); //display first frame //Put everything together. add(framesPerSecond, BorderLayout.LINE_START); add(picture, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //Set up a timer that calls this object's action handler. timer = new Timer(delay, this); timer.setInitialDelay(delay * 7); //We pause animation twice per cycle //by restarting the timer timer.setCoalesce(true); }
From source file:net.pandoragames.far.ui.swing.FileListPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BorderLayout()); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); tableModel = componentRepository.getTableModel(); componentRepository.getResetDispatcher().addResetable(tableModel); componentRepository.getSearchBaseListener().addResetable(tableModel); componentRepository.getUndoListener().setTableModel(tableModel); JTable fileListTable = componentRepository.getFileSetTable(); int totalWidth = fileListTable.getPreferredSize().width; fileListTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); fileListTable.setColumnSelectionAllowed(true); fileListTable.getTableHeader().addMouseListener(new TableHeaderMouseListener()); fileListTable.getTableHeader().getColumnModel().getColumn(0) .setHeaderRenderer(new TableHeaderCheckBoxColumnRenderer()); fileListPopupMenu = new FileListPopupMenu(fileListTable, tableModel, componentRepository, config); fileListTable.setComponentPopupMenu(fileListPopupMenu); fileListTable.addMouseListener(new FileViewOpener(fileListTable, componentRepository.getRootWindow(), config, componentRepository)); fileListTable.getColumnModel().getColumn(0).setPreferredWidth(20); fileListTable.getColumnModel().getColumn(0).setMaxWidth(20); fileListTable.getColumnModel().getColumn(1).setCellRenderer(new TargetFileListTableCellRenderer()); fileListTable.getColumnModel().getColumn(1).setPreferredWidth(2 * totalWidth / 5); fileListTable.getColumnModel().getColumn(2).setCellRenderer(new PathColumnRenderer()); fileListTable.getColumnModel().getColumn(3).setCellRenderer(new InfoColumnRenderer(config)); JScrollPane scrollPane = new JScrollPane(fileListTable); this.add(scrollPane, BorderLayout.CENTER); SelectCounter fileCounter = new SelectCounter(); fileCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); fileCounter.setForeground(Color.GRAY); ErrorCounter errorCounter = new ErrorCounter(); errorCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); JPanel counterLine = new JPanel(); counterLine.setLayout(new BorderLayout()); counterLine.add(fileCounter, BorderLayout.WEST); counterLine.add(errorCounter, BorderLayout.EAST); JProgressBar progressBar = new JProgressBar(); progressBar.setEnabled(false);/*from ww w . j a v a2 s. c om*/ progressBar.setMaximumSize(new Dimension(100, 20)); progressBar.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); componentRepository.getProgressBarUpdater().setProgressBar(progressBar); JPanel progressBarPanel = new JPanel(); progressBarPanel.add(progressBar); counterLine.add(progressBarPanel, BorderLayout.CENTER); counterLine.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); this.add(counterLine, BorderLayout.SOUTH); tableModel.addTableModelListener(new ColumnCountListener(fileCounter)); tableModel.addTableModelListener(errorCounter); componentRepository.getResetDispatcher().addResetable(fileCounter); componentRepository.getSearchBaseListener().addResetable(fileCounter); componentRepository.getOperationCallBackListener().addComponentStartReseted(fileCounter, OperationType.FIND); componentRepository.getResetDispatcher().addResetable(errorCounter); componentRepository.getSearchBaseListener().addResetable(errorCounter); viewAction = new ActionView(componentRepository, config); }
From source file:com.igormaznitsa.mindmap.plugins.exporters.PNGImageExporter.java
@Override @Nullable/*from w w w . j a v a 2 s .c om*/ public JComponent makeOptions() { final JPanel panel = UI_FACTORY.makePanel(); final JCheckBox checkBoxExpandAll = UI_FACTORY.makeCheckBox(); checkBoxExpandAll.setSelected(flagExpandAllNodes); checkBoxExpandAll.setText(Texts.getString("PNGImageExporter.optionUnfoldAll")); checkBoxExpandAll.setActionCommand("unfold"); final JCheckBox checkSaveBackground = UI_FACTORY.makeCheckBox(); checkSaveBackground.setSelected(flagSaveBackground); checkSaveBackground.setText(Texts.getString("PNGImageExporter.optionDrawBackground")); checkSaveBackground.setActionCommand("back"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(checkBoxExpandAll); panel.add(checkSaveBackground); panel.setBorder(BorderFactory.createEmptyBorder(16, 32, 16, 32)); return panel; }
From source file:components.CrayonPanel.java
protected void buildChooser() { setLayout(new GridLayout(0, 1)); ButtonGroup boxOfCrayons = new ButtonGroup(); Border border = BorderFactory.createEmptyBorder(4, 4, 4, 4); redCrayon = createCrayon("red", border); boxOfCrayons.add(redCrayon);//from ww w . j a v a 2 s .c om add(redCrayon); yellowCrayon = createCrayon("yellow", border); boxOfCrayons.add(yellowCrayon); add(yellowCrayon); greenCrayon = createCrayon("green", border); boxOfCrayons.add(greenCrayon); add(greenCrayon); blueCrayon = createCrayon("blue", border); boxOfCrayons.add(blueCrayon); add(blueCrayon); }
From source file:livecanvas.mesheditor.MeshEditor.java
public MeshEditor() { super("Mesh Editor", new ImageIcon(clazz.getResource("res/mesh_editor.png")), new BorderLayout()); setPreferredSize(new Dimension(1024, 600)); setBackground(Color.darkGray); tools = createTools();/*from w w w . j a v a 2s . co m*/ add(tools, BorderLayout.WEST); selectedColor = Color.black; JPanel east = new JPanel(new BorderLayout()); east.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); Layer rootLayer = new Layer("ROOT"); rootLayer.addSubLayer(new Layer("Layer1")); layersView = new LayersView(rootLayer); chain(layersView); layersView.addListener(this); east.add(layersView, BorderLayout.NORTH); propertiesPanel = new JPanel(new BorderLayout()); east.add(propertiesPanel); viewpointsView = new ViewpointsView(layersView.getSelectedLayer()); viewpointsView.addListener(this); east.add(viewpointsView, BorderLayout.SOUTH); add(east, BorderLayout.EAST); JPanel center = new JPanel(new BorderLayout()); center.setBackground(Color.lightGray); canvas = new CanvasMesh(800, 600); canvas.setCurrLayer(getRootLayer()); pointerHandler = new AffineTransformPointerHandler(canvas); canvas.setPointerHandler(pointerHandler); canvasContainer = new CanvasContainer(canvas); rootLayer.setCanvas(canvas); center.add(canvasContainer); renderImageSettings = new RenderImageSettings(); settings = new MeshEditorSettings(canvas.getSettings(), layersView.getSettings(), renderImageSettings); add(center); layersView.layersList.setSelectedIndex(1); setSelectedToolType(TOOLS_BRUSH); }
From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java
/** * Constructor// ww w . ja va 2 s . c o m * * @param compactLayout * if false, there will be message type selectors in the panel */ public VOCTAdditionalInfoPanel(boolean compactLayout) { super(new BorderLayout()); EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this); // Prepare the title header titleHeader.setBackground(getBackground().darker()); titleHeader.setOpaque(true); titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); titleHeader.setHorizontalAlignment(SwingConstants.CENTER); add(titleHeader, BorderLayout.NORTH); // Add messages panel scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); messagesPanel.setBackground(UIManager.getColor("List.background")); messagesPanel.setOpaque(false); messagesPanel.setLayout(new GridBagLayout()); messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(scrollPane, BorderLayout.CENTER); JPanel sendPanel = new JPanel(new GridBagLayout()); add(sendPanel, BorderLayout.SOUTH); Insets insets = new Insets(2, 2, 2, 2); // Add text area // if (false) { // messageText = new JTextField(); // ((JTextField) messageText).addActionListener(this); // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // // } else { messageText = new JTextArea(); JScrollPane scrollPane2 = new JScrollPane(messageText); scrollPane2.setPreferredSize(new Dimension(100, 50)); scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // } // Add buttons // ButtonGroup group = new ButtonGroup(); if (!compactLayout) { JToolBar msgTypePanel = new JToolBar(); msgTypePanel.setBorderPainted(false); msgTypePanel.setOpaque(true); msgTypePanel.setFloatable(false); sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } if (compactLayout) { addBtn = new JButton("Add to Log"); sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } // addBtn.setEnabled(false); // messageText.setEditable(false); addBtn.addActionListener(this); }