List of usage examples for javax.swing JButton getBorder
public Border getBorder()
null
if no border is currently set. From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java
/** * Build frame.//w w w . j a v a2s. c o m */ private void build() { setTitle("Proprits de l'objet " + objetSchema.getId()); setSize(700, 400); setResizable(false); setLocationRelativeTo(mainFrame); if (mainFrame != null) setIconImage(mainFrame.getIconImage()); // - Panel bouton du bas - JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); boutonsPanel.add(boutonOk); boutonsPanel.add(boutonAnnuler); // - Description - JTextArea textAreaValues = new JTextArea("Vous pouvez apporter des modifications sur les paramtres" + " de cet objet d'identifiant " + objetSchema.getId() + ". Les" + " modifications apportes des paramtres non-cochs ne" + " seront pas prises en compte."); textAreaValues.setEditable(false); textAreaValues.setLineWrap(true); textAreaValues.setWrapStyleWord(true); textAreaValues.setFont((new JLabel()).getFont()); textAreaValues.setBorder(BorderFactory.createEmptyBorder(7, 8, 7, 8)); textAreaValues.setBackground((new JLabel()).getBackground()); // - La table des valeurs - // Correction : Tri alphabtique des valeurs Enumeration<String> k = values.keys(); String[] keys = new String[values.size()]; for (int i = 0; i < keys.length; i++) keys[i] = k.nextElement(); Arrays.sort(keys); JPanel colonne1 = new JPanel(new GridLayout(keys.length, 1)); JPanel colonne2 = new JPanel(new GridLayout(keys.length, 1)); // Enumeration<JComponent> l = labels.elements(); // Enumeration<JComponent> v = values.elements(); // Enumeration<String> k = values.keys(); // JPanel colonne1 = new JPanel( new GridLayout( values.size(), 1 ) ); // JPanel colonne2 = new JPanel( new GridLayout( values.size(), 1 ) ); for (int i = 0; keys != null && i < keys.length; i++) { // while( l.hasMoreElements() && v.hasMoreElements() && k.hasMoreElements() ) { String key = keys[i]; JComponent label = labels.get(key); JComponent value = values.get(key); JCheckBox checkbox = valuesPresent.get(key); // String key = k.nextElement(); // JComponent label = l.nextElement(); // JComponent value = v.nextElement(); // JCheckBox checkbox = valuesPresent.get( key ); if (!value.isEnabled() && value instanceof JTextField) { //value.setEnabled( true ); JButton b = new JButton("..."); b.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 5, 0, 0, Color.white), b.getBorder())); b.addActionListener(new SchemaValueEditorLauncher(b, (JTextField) value, objetSchema, key)); JPanel tmp = new JPanel(new BorderLayout()); tmp.add(value, BorderLayout.CENTER); tmp.add(b, BorderLayout.EAST); tmp.setOpaque(false); value = tmp; } JPanel panelTmp1 = new JPanel(new BorderLayout()); panelTmp1.add(checkbox, BorderLayout.WEST); panelTmp1.add(label, BorderLayout.CENTER); panelTmp1.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 3)); colonne1.add(panelTmp1); JPanel panelTmp2 = new JPanel(new BorderLayout()); panelTmp2.add(value, BorderLayout.CENTER); panelTmp2.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); colonne2.add(panelTmp2); checkbox.setOpaque(false); label.setOpaque(false); value.setOpaque(false); panelTmp1.setOpaque(false); panelTmp2.setOpaque(false); } JPanel tablePanel = new JPanel(new BorderLayout()); tablePanel.add(colonne1, BorderLayout.WEST); tablePanel.add(colonne2, BorderLayout.EAST); tablePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); colonne1.setOpaque(false); colonne2.setOpaque(false); tablePanel.setOpaque(false); JPanel tablePanelContainer = new JPanel(new BorderLayout()); tablePanelContainer.add(tablePanel, BorderLayout.NORTH); tablePanelContainer.setBackground(Color.white); JList tmpForBorderList = new JList(); JScrollPane tmpForBorderScroller = new JScrollPane(tmpForBorderList); JScrollPane tableScroller = new JScrollPane(tablePanelContainer); //tableScroller.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); tableScroller.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 6, 1, 6), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Listes des paramtres "), BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5), tmpForBorderScroller.getBorder())))); // - Organisation gnrale - JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(textAreaValues, BorderLayout.NORTH); mainPanel.add(tableScroller, BorderLayout.CENTER); JPanel mainPanelContainer = new JPanel(new BorderLayout()); mainPanelContainer.add(mainPanel, BorderLayout.CENTER); mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH); mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1)); getContentPane().add(mainPanelContainer); // - Listeners - addWindowListener(this); boutonOk.addActionListener(this); boutonAnnuler.addActionListener(this); }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a button// w w w.j a v a 2 s . c o m * * @param container - parent container * @param label - button label * @param mnemonic - button mnemonic * @param tooltip - button tool tip * @param placement - TableLayout placement in parent container * @param debug - turn on/off red debug borders * @return JButton */ public static JButton addButton(Container container, String label, int mnemonic, String tooltip, String placement, boolean debug) { JButton button = new JButton(label); button.setMnemonic(mnemonic); button.setToolTipText(tooltip); button.setOpaque(!getIsMac()); container.add(button, placement); if (debug == true) button.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), button.getBorder())); return button; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a button with an icon in it/*ww w. ja v a 2 s .c om*/ * * @param container - parent container * @param label - button label * @param image - button image * @param width - button width * @param height - button height * @param mnemonic - button mnemonic * @param tooltip - tool tip for button * @param placement - TableLayout placement in parent container * @param debug - turn on/off red debug borders * @return JButton with image */ public static JButton addIconButton(Container container, String label, String image, Integer width, Integer height, Integer mnemonic, String tooltip, String placement, boolean debug) { JButton button = null; if (image == null) { button = new JButton(label); } else { java.net.URL imgURL = GuiImporter.class.getResource(image); if (imgURL != null && label.length() > 0) { button = new JButton(label, new ImageIcon(imgURL)); } else if (imgURL != null) { button = new JButton(null, new ImageIcon(imgURL)); } else { button = new JButton(label); log.error("Couldn't find icon: " + image); } } if (width != null && height != null && width > 0 && height > 0) { button.setMaximumSize(new Dimension(width, height)); button.setPreferredSize(new Dimension(width, height)); button.setMinimumSize(new Dimension(width, height)); button.setSize(new Dimension(width, height)); } if (mnemonic != null) button.setMnemonic(mnemonic); button.setOpaque(!getIsMac()); button.setToolTipText(tooltip); container.add(button, placement); if (isMotif() == true) { Border b = BorderFactory.createLineBorder(Color.gray); button.setMargin(new Insets(0, 0, 0, 0)); button.setBorder(b); } if (debug == true) button.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), button.getBorder())); return button; }