List of usage examples for javax.swing.border LineBorder LineBorder
public LineBorder(Color color)
From source file:Main.java
/** * Set the button to have simplified UI. * /* www. ja va 2 s . c o m*/ * @param button * button to be modified * @param <T> * type of button * @return button */ public static <T extends AbstractButton> T decoratedToSimpleButton(final T button) { button.setForeground(Color.BLACK); button.setBackground(Color.LIGHT_GRAY); button.setBorderPainted(true); button.setFocusPainted(true); button.setContentAreaFilled(false); button.setOpaque(true); if (button instanceof JToggleButton) { ((JToggleButton) button).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (button.isSelected()) { button.setBackground(Color.WHITE); } } }); } button.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { super.mouseEntered(e); button.setBackground(Color.WHITE); } @Override public void mouseExited(MouseEvent e) { super.mouseExited(e); if (!button.isSelected()) { button.setBackground(Color.LIGHT_GRAY); } } }); button.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (!button.isSelected()) { button.setBackground(Color.LIGHT_GRAY); } } }); Border line = new LineBorder(Color.BLACK); Border margin = new EmptyBorder(5, 15, 5, 15); Border compound = new CompoundBorder(line, margin); button.setBorder(compound); return button; }
From source file:com.mgmtp.perfload.loadprofiles.ui.component.DoubleCellEditor.java
@Override public boolean stopCellEditing() { String s = (String) super.getCellEditorValue(); JTextField textField = (JTextField) getComponent(); if (isBlank(s)) { textField.setBorder(new LineBorder(Color.red)); return false; }/* ww w . ja va2s . c om*/ try { value = Double.valueOf(s); } catch (NumberFormatException ex2) { try { Number n = FORMAT.parse(s); value = n.doubleValue(); } catch (ParseException ex1) { textField.setBorder(new LineBorder(Color.red)); textField.selectAll(); return false; } } return super.stopCellEditing(); }
From source file:com.mgmtp.perfload.loadprofiles.ui.component.StringCellEditor.java
@Override public Component getTableCellEditorComponent(final JTable tbl, final Object value, final boolean isSelected, final int row, final int column) { editorComponent.setBorder(new LineBorder(Color.black)); return super.getTableCellEditorComponent(table, value, isSelected, row, column); }
From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java
private RestoreFileWindow(final PReg registry) { super();// www.j a v a 2 s. com setLayout(null); final JTextField searchField = new JTextField(); searchField.setLayout(null); searchField.setBounds(2, 2, 301, 26); searchField.setBorder(new LineBorder(Color.lightGray)); searchField.setFont(Constants.FONT); add(searchField); final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>" + "<font color=\"gray\">If you think there is a problem with the<br>" + "backup system, please create an issue here:<br>" + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>"); noBackupFilesLabel.setLayout(null); noBackupFilesLabel.setBounds(20, 50, 300, 300); noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f)); noBackupFilesLabel.addMouseListener((OnMouseClick) e -> { String urlPath = "https://github.com/com.edduarte/protbox/issues"; try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI(urlPath)); } else { if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath); } else { java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari", "mozilla", "chrome"); for (String browser : browsers) { if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) { Runtime.getRuntime().exec(new String[] { browser, urlPath }); break; } } } } } catch (Exception ex) { ex.printStackTrace(); } }); DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree(); final JTree tree = new JTree(rootTreeNode); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); if (rootTreeNode.getChildCount() == 0) { searchField.setEnabled(false); add(noBackupFilesLabel); } expandTree(tree); tree.setLayout(null); tree.setRootVisible(false); tree.setEditable(false); tree.setCellRenderer(new SearchableTreeCellRenderer(searchField)); searchField.addKeyListener((OnKeyReleased) e -> { // update and expand tree DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.nodeStructureChanged((TreeNode) model.getRoot()); expandTree(tree); }); final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setBorder(new DropShadowBorder()); scroll.setBorder(new LineBorder(Color.lightGray)); scroll.setBounds(2, 30, 334, 360); add(scroll); JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png"))); close.setLayout(null); close.setBounds(312, 7, 18, 18); close.setFont(Constants.FONT); close.setForeground(Color.gray); close.addMouseListener((OnMouseClick) e -> dispose()); add(close); final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png"))); permanentDeleteButton.setLayout(null); permanentDeleteButton.setBounds(91, 390, 40, 39); permanentDeleteButton.setBackground(Color.black); permanentDeleteButton.setEnabled(false); permanentDeleteButton.addMouseListener((OnMouseClick) e -> { if (permanentDeleteButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (JOptionPane.showConfirmDialog(null, "Are you sure you wish to permanently delete '" + entry.realName() + "'?\nThis file and its " + "backup copies will be deleted immediately. You cannot undo this action.", "Confirm Cancel", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { registry.permanentDelete(entry); dispose(); RestoreFileWindow.getInstance(registry); } else { setVisible(true); } } }); add(permanentDeleteButton); final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png"))); configBackupsButton.setLayout(null); configBackupsButton.setBounds(134, 390, 40, 39); configBackupsButton.setBackground(Color.black); configBackupsButton.setEnabled(false); configBackupsButton.addMouseListener((OnMouseClick) e -> { if (configBackupsButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; JFrame frame = new JFrame("Choose backup policy"); Object option = JOptionPane.showInputDialog(frame, "Choose below the backup policy for this file:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(), pbxFile.getBackupPolicy()); if (option == null) { setVisible(true); return; } PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString()); pbxFile.setBackupPolicy(pickedPolicy); } setVisible(true); } }); add(configBackupsButton); final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png"))); restoreBackupButton.setLayout(null); restoreBackupButton.setBounds(3, 390, 85, 39); restoreBackupButton.setBackground(Color.black); restoreBackupButton.setEnabled(false); restoreBackupButton.addMouseListener((OnMouseClick) e -> { if (restoreBackupButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFolder) { registry.restoreFolderFromEntry((PbxFolder) entry); } else if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; java.util.List<String> snapshots = pbxFile.snapshotsToString(); if (snapshots.isEmpty()) { setVisible(true); return; } JFrame frame = new JFrame("Choose backup"); Object option = JOptionPane.showInputDialog(frame, "Choose below what backup snapshot would you like restore:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0)); if (option == null) { setVisible(true); return; } int pickedIndex = snapshots.indexOf(option.toString()); registry.restoreFileFromEntry((PbxFile) entry, pickedIndex); } dispose(); } }); add(restoreBackupButton); tree.addMouseListener((OnMouseClick) e -> { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { PbxEntry entry = (PbxEntry) node.getUserObject(); if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(false); } else if (entry instanceof PbxFile) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(true); } else { permanentDeleteButton.setEnabled(false); restoreBackupButton.setEnabled(false); configBackupsButton.setEnabled(false); } } }); final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png"))); cancel.setLayout(null); cancel.setBounds(229, 390, 122, 39); cancel.setBackground(Color.black); cancel.addMouseListener((OnMouseClick) e -> dispose()); add(cancel); addWindowFocusListener(new WindowFocusListener() { private boolean gained = false; @Override public void windowGainedFocus(WindowEvent e) { gained = true; } @Override public void windowLostFocus(WindowEvent e) { if (gained) { dispose(); } } }); setSize(340, 432); setUndecorated(true); getContentPane().setBackground(Color.white); setResizable(false); getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100))); Utils.setComponentLocationOnCenter(this); setVisible(true); }
From source file:com.emr.schemas.ButtonColumn.java
/** * Create the ButtonColumn to be used as a renderer and editor. The * renderer and editor will automatically be installed on the TableColumn * of the specified column.//from w ww . j av a 2 s .com * * @param table the table containing the button renderer/editor * @param action the Action to be invoked when the button is invoked * @param column the column to which the button renderer/editor is added */ public ButtonColumn(JTable table, Action action, int column, String btnText) { this.table = table; this.action = action; this.btnText = btnText; renderButton = new JButton(); editButton = new JButton(); editButton.setFocusPainted(false); editButton.addActionListener(this); originalBorder = editButton.getBorder(); setFocusBorder(new LineBorder(Color.BLUE)); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(column).setCellRenderer(this); columnModel.getColumn(column).setCellEditor(this); table.addMouseListener(this); }
From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java
private JPanel initCell(String color, int x, int y) { JPanel cell = new JPanel(); cell.setSize(50, 50);// ww w .j a va 2 s. c o m cell.setBackground(Color.decode(color)); cell.setOpaque(true); cell.setLocation(x, y); cell.setBorder(new LineBorder(Color.WHITE)); return cell; }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java
private JPanel initCell(String color, int x, int y) { JPanel cell = new JPanel(); cell.setSize(50, 50);/* w w w . j av a 2s. c o m*/ Color c; if (color.contains("#")) { c = Color.decode(color); } else if (color.toLowerCase().contains("rgb")) { String rgb = color.toLowerCase().replace("rgb", "").replace("(", "").replace(")", "").replace(" ", ""); String[] stringRGBArr = rgb.split(","); c = new Color(Integer.valueOf(stringRGBArr[0]), Integer.valueOf(stringRGBArr[1]), Integer.valueOf(stringRGBArr[2])); } else { c = Color.RED; } cell.setBackground(c); cell.setOpaque(true); cell.setLocation(x, y); cell.setBorder(new LineBorder(Color.WHITE)); return cell; }
From source file:UI.SecurityDashboard.java
/** * Creates new form Main// w ww .ja v a 2s . co m */ public SecurityDashboard() { //this.setUndecorated(true); //this.setAlwaysOnTop(true); this.setVisible(true); initComponents(); MainViewPanel mvp = new MainViewPanel(); performMetric1(mvp); performMetric2(mvp); performMetric3(mvp); performMetric4(mvp); performMetric5(mvp); performMetric6(mvp); performMetric7(mvp); performMetric8(mvp); performMetric9(); // Metric6Panel.setVisible(false); // Metric7Panel.setVisible(false); // Metric8Panel.setVisible(false); // Metric9Panel.setVisible(false); Toolkit tk; tk = Toolkit.getDefaultToolkit(); this.setSize((int) tk.getScreenSize().getWidth(), (int) tk.getScreenSize().getHeight()); this.setTitle("Security Dashboard"); sourceFolder.setBorder(new LineBorder(Color.BLACK)); sourceFolder.setBorderPainted(true); }
From source file:BoxAlignmentDemo.java
protected JPanel createLabelAndComponent(boolean doItRight) { JPanel pane = new JPanel(); JComponent component = new JPanel(); Dimension size = new Dimension(150, 100); component.setMaximumSize(size);/* w w w .ja va2 s .c o m*/ component.setPreferredSize(size); component.setMinimumSize(size); TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER, TitledBorder.BELOW_TOP); border.setTitleColor(Color.black); component.setBorder(border); JLabel label = new JLabel("This is a JLabel"); String title; if (doItRight) { title = "Matched"; label.setAlignmentX(CENTER_ALIGNMENT); } else { title = "Mismatched"; } pane.setBorder(BorderFactory.createTitledBorder(title)); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); pane.add(label); pane.add(component); return pane; }
From source file:de.interactive_instruments.ShapeChange.UI.DefaultDialog.java
private Component createTab1() { final JPanel mdlPanel = new JPanel(); mdlField = new JTextField(40); String s = options.parameter("inputFile"); if (s == null) s = "";//from w w w . j a v a 2s .c om mdlField.setText(s); mdlPanel.add(mdlField); mdlPanel.add(mdlButton = new JButton("Select File")); mdlButton.setActionCommand("MDL"); mdlButton.addActionListener(this); mdlPanel.setBorder( new TitledBorder(new LineBorder(Color.black), "Model file", TitledBorder.LEFT, TitledBorder.TOP)); final JPanel outPanel = new JPanel(); outField = new JTextField(40); s = options.parameter("outputDirectory"); if (s == null) s = "."; outField.setText(s); outPanel.add(outField); outPanel.add(outButton = new JButton("Select File")); outButton.setActionCommand("OUT"); outButton.addActionListener(this); outPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Output directory", TitledBorder.LEFT, TitledBorder.TOP)); final JPanel asPanel = new JPanel(); asField = new JTextField(49); s = options.parameter("appSchemaName"); if (s == null) s = ""; asField.setText(s); asPanel.add(asField); asPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Application schema name (optional)", TitledBorder.LEFT, TitledBorder.TOP)); final JPanel startPanel = new JPanel(); startButton = new JButton("Process Model"); startButton.setActionCommand("START"); startButton.addActionListener(this); startPanel.add(startButton); logButton = new JButton("View Log"); logButton.setActionCommand("LOG"); logButton.addActionListener(this); logButton.setEnabled(false); startPanel.add(logButton); exitButton = new JButton("Exit"); exitButton.setActionCommand("EXIT"); exitButton.addActionListener(this); exitButton.setEnabled(true); startPanel.add(exitButton); Box fileBox = Box.createVerticalBox(); fileBox.add(mdlPanel); fileBox.add(asPanel); fileBox.add(outPanel); fileBox.add(startPanel); JPanel panel = new JPanel(new BorderLayout()); panel.add(fileBox, BorderLayout.CENTER); return panel; }