List of usage examples for javax.swing BorderFactory createCompoundBorder
public static CompoundBorder createCompoundBorder(Border outsideBorder, Border insideBorder)
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a bordered 'sub-panel' with title to a container * //from w ww .ja va2 s . co m * @param container - parent container * @param tableSize - TableLayout table array * @param name - panel name * @param debug - turn on/off red debug borders * @return new JPanel */ public static JPanel addBorderedPanel(Container container, double tableSize[][], String name, boolean debug) { JPanel panel = new JPanel(); panel.setOpaque(false); TableLayout layout = new TableLayout(tableSize); panel.setLayout(layout); panel.setBorder(BorderFactory.createTitledBorder(name)); if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); return panel; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a plane sub-panel to an existing container * //from ww w .j a va 2 s .c o m * @param container - parent container * @param tableSize - TableLayout table array * @param debug - turn on/off red debug borders * @return new JPanel */ public static JPanel addPlanePanel(Container container, double tableSize[][], boolean debug) { JPanel panel = new JPanel(); panel.setOpaque(false); TableLayout layout = new TableLayout(tableSize); panel.setLayout(layout); panel.setBorder(BorderFactory.createEmptyBorder()); if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); return panel; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a text pane to the parent container * /* ww w . j av a2s.c o m*/ * @param container - parent container * @param text - text for new Text Pane * @param placement - TableLayout placement within the parent container * @param debug - turn on/off red debug borders * @return new JTextPane */ public static synchronized JTextPane addTextPane(Container container, String text, String placement, boolean debug) { StyleContext context = new StyleContext(); StyledDocument document = new DefaultStyledDocument(context); Style style = context.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT); try { document.insertString(document.getLength(), text, null); } catch (BadLocationException e) { log.error("BadLocationException inserting text to document."); } JTextPane textPane = new JTextPane(document); textPane.setOpaque(false); textPane.setEditable(false); textPane.setFocusable(false); container.add(textPane, placement); if (debug == true) textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), textPane.getBorder())); return textPane; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * A version of addTextPane that lets you add a style and context * /* ww w.java2s. c o m*/ * @param container - parent container * @param text - text for new Text Pane * @param placement - TableLayout placement within the parent container * @param context - context for new text pane * @param style - style to apply to new text pane * @param debug - turn on/off red debug borders * @return new JTextPane */ public static synchronized JTextPane addTextPane(Container container, String text, String placement, StyleContext context, Style style, boolean debug) { StyledDocument document = new DefaultStyledDocument(context); try { document.insertString(document.getLength(), text, style); } catch (BadLocationException e) { log.error("BadLocationException inserting text to document."); } JTextPane textPane = new JTextPane(document); textPane.setOpaque(false); textPane.setEditable(false); textPane.setFocusable(false); container.add(textPane, placement); if (debug == true) textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), textPane.getBorder())); return textPane; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a new Text Field/* w ww . ja v a2s. c o m*/ * * @param container - parent container * @param name - name of text field * @param initialValue - initial value of text field * @param mnemonic - mnemonic key * @param tooltip - tool tip for field * @param suffix - suffix text for field * @param labelWidth - label width * @param placement - TableLayout placement * @param debug - turn on/off red debug borders * @return JTextField */ public static JTextField addTextField(Container container, String name, String initialValue, int mnemonic, String tooltip, String suffix, double labelWidth, String placement, boolean debug) { double[][] size = null; JPanel panel = new JPanel(); panel.setOpaque(false); if (suffix.equals("")) size = new double[][] { { labelWidth, TableLayout.FILL }, { 30 } }; else size = new double[][] { { labelWidth, TableLayout.FILL, TableLayout.PREFERRED }, { 30 } }; TableLayout layout = new TableLayout(size); panel.setLayout(layout); JLabel label = new JLabel(name); label.setDisplayedMnemonic(mnemonic); JTextField result = new JTextField(20); label.setLabelFor(result); label.setOpaque(false); result.setToolTipText(tooltip); if (initialValue != null) result.setText(initialValue); panel.add(label, "0, 0, r, c"); panel.add(result, "1, 0, f, c"); if (suffix.length() != 0) { JLabel suffixLabel = new JLabel(" " + suffix); panel.add(suffixLabel, "2,0, l, c"); } if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); container.add(panel, placement); return result; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a new Password Text Field//from www .jav a2 s . c o m * * @param container - parent container * @param name - name of text field * @param initialValue - initial value of text field * @param mnemonic - mnemonic key * @param tooltip - tool tip for field * @param suffix - suffix text for field * @param labelWidth - label width * @param placement - TableLayout placement * @param debug - turn on/off red debug borders * @return JPasswordField */ public static JPasswordField addPasswordField(Container container, String name, String initialValue, int mnemonic, String tooltip, String suffix, double labelWidth, String placement, boolean debug) { double[][] size = null; JPanel panel = new JPanel(); panel.setOpaque(false); if (suffix.equals("")) size = new double[][] { { labelWidth, TableLayout.FILL }, { 30 } }; else size = new double[][] { { labelWidth, TableLayout.FILL, TableLayout.PREFERRED }, { 30 } }; TableLayout layout = new TableLayout(size); panel.setLayout(layout); JLabel label = new JLabel(name); label.setDisplayedMnemonic(mnemonic); JPasswordField result = new JPasswordField(20); label.setLabelFor(result); label.setOpaque(false); result.setToolTipText(tooltip); if (initialValue != null) result.setText(initialValue); panel.add(label, "0, 0, r, c"); panel.add(result, "1, 0, f, c"); if (suffix.length() != 0) { JLabel suffixLabel = new JLabel(" " + suffix); panel.add(suffixLabel, "2,0, l, c"); } if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); container.add(panel, placement); return result; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a TextArea that has scrolling functionality * /* www . j a v a2 s . c o m*/ * @param container - parent container * @param name - name of text area * @param text - text to put in text area * @param mnemonic - mnemonic key * @param placement - TableLayout placement in parent container * @param debug - turn on/off red debug borders * @return JTextArea */ public static JTextArea addScrollingTextArea(Container container, String name, String text, int mnemonic, String placement, boolean debug) { JPanel panel = new JPanel(); panel.setOpaque(false); double size[][] = { { TableLayout.FILL }, { 20, TableLayout.FILL } }; TableLayout layout = new TableLayout(size); panel.setLayout(layout); JTextArea textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setOpaque(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); if (!name.equals("")) { JLabel label = new JLabel(name); label.setOpaque(false); label.setDisplayedMnemonic(mnemonic); panel.add(label, "0, 0, l, c"); panel.add(areaScrollPane, "0, 1, f, f"); } else { panel.add(areaScrollPane, "0, 0, 0, 1"); } container.add(panel, placement); return textArea; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a button/* w ww . j a v a 2s .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/*from w w w . ja va 2 s . c o m*/ * * @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; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add an image panel to the parent container * //from w w w . j ava 2 s . com * @param container - parent container * @param imageString - string to use for imgURL * @param placement - TableLayout placement of panel within parent * @param debug - turn on/off red debug borders * @return image JPanel */ public static JPanel addImagePanel(JPanel container, String imageString, String placement, boolean debug) { ImageIcon icon = null; java.net.URL imgURL = GuiImporter.class.getResource(imageString); if (imgURL != null) { icon = new ImageIcon(imgURL); } JPanel panel = new ImagePanel(icon); if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); else panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.gray), panel.getBorder())); container.add(panel, placement); return panel; }