Java Code Examples for javax.swing.border.TitledBorder#setTitleColor()
The following examples show how to use
javax.swing.border.TitledBorder#setTitleColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private static Component makeTitledPanel(String title, Container cmp, Color bgc) { JPanel p = new JPanel(new BorderLayout()); if (cmp.getLayout() instanceof BoxLayout) { p.add(cmp, BorderLayout.NORTH); } else { p.add(cmp); } if (Objects.nonNull(title)) { TitledBorder b = BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), title); if (Objects.nonNull(bgc)) { b.setTitleColor(new Color(~bgc.getRGB())); } p.setBorder(b); } if (Objects.nonNull(bgc)) { p.setOpaque(true); p.setBackground(bgc); } return p; }
Example 2
Source File: YoloUI.java From Java-Machine-Learning-for-Computer-Vision with MIT License | 6 votes |
@NotNull private JComboBox<Speed> speedChooser() { JPanel panel = new JPanel(); TitledBorder speed = BorderFactory.createTitledBorder("Speed"); speed.setTitleFont(FONT_ITALIC); speed.setTitleColor(Color.BLUE.darker()); panel.setBorder(speed); mainPanel.add(panel); JComboBox<Speed> choose = new JComboBox<>(); choose.setBackground(Color.BLUE.darker()); choose.setForeground(Color.BLUE.darker()); choose.addItem(Speed.FAST); choose.addItem(Speed.MEDIUM); choose.addItem(Speed.SLOW); choose.setSelectedIndex(1); panel.add(choose); return choose; }
Example 3
Source File: UIRes.java From RipplePower with Apache License 2.0 | 6 votes |
public static void addStyle(JTextField textField, String labelName, boolean bottom) { textField.setHorizontalAlignment(SwingConstants.RIGHT); Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY); TitledBorder titled = BorderFactory.createTitledBorder(line, labelName); titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13)); titled.setTitleColor(fontColorTitle); Border empty = null; if (bottom) { empty = new EmptyBorder(5, 8, 5, 8); } else { empty = new EmptyBorder(5, 8, 0, 8); } CompoundBorder border = new CompoundBorder(titled, empty); textField.setBorder(border); textField.setForeground(fontColor); textField.setFont(GraphicsUtils.getFont("Monospaced", 0, 13)); }
Example 4
Source File: UIRes.java From RipplePower with Apache License 2.0 | 6 votes |
public static void addStyle(JScrollPane jScrollPane, String labelName, boolean bottom) { Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY); TitledBorder titled = BorderFactory.createTitledBorder(line, labelName); titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13)); titled.setTitleColor(fontColorTitle); Border empty = null; if (bottom) { empty = new EmptyBorder(5, 8, 5, 8); } else { empty = new EmptyBorder(5, 8, 0, 8); } CompoundBorder border = new CompoundBorder(titled, empty); jScrollPane.setBorder(border); jScrollPane.setForeground(fontColor); jScrollPane.setBackground(Color.WHITE); jScrollPane.setFont(GraphicsUtils.getFont("Monospaced", 0, 13)); jScrollPane.setHorizontalScrollBar(null); }
Example 5
Source File: WizardManager.java From ghidra with Apache License 2.0 | 5 votes |
private void updateScrollPaneBorder(JPanel panel) { if (panel == null) { return; } scrollPane.setBackground(panel.getBackground()); if (scrollPane.getVerticalScrollBar().isShowing()) { TitledBorder titledBorder = new TitledBorder(BorderFactory.createEmptyBorder(), "(scroll for more options)"); Font font = titledBorder.getTitleFont(); if (font == null) { // workaround for bug on Java 7 font = titleLabel.getFont(); } titledBorder.setTitleFont(font.deriveFont(10f)); titledBorder.setTitleColor(Color.BLUE); titledBorder.setTitlePosition(TitledBorder.BOTTOM); titledBorder.setTitleJustification(TitledBorder.TRAILING); scrollPane.setBorder(titledBorder); } else { scrollPane.setBorder(BorderFactory.createEmptyBorder()); } }
Example 6
Source File: UIRes.java From RipplePower with Apache License 2.0 | 5 votes |
public static void addStyle(JTextArea textArea, String labelName, boolean isBorder) { Border border = null; if (isBorder) { Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY); TitledBorder titled = BorderFactory.createTitledBorder(line, labelName); titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13)); titled.setTitleColor(fontColorTitle); } textArea.setBorder(border); textArea.setForeground(fontColor); textArea.setFont(GraphicsUtils.getFont("Monospaced", 0, 13)); }
Example 7
Source File: Test7022041.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Check behaviour of method TitledBorder.getTitleColor() */ private static void checkTitleColor() { TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1)); Color defaultColor = UIManager.getLookAndFeelDefaults().getColor("TitledBorder.titleColor"); Color titledBorderColor = titledBorder.getTitleColor(); // check default configuration if (defaultColor == null) { if (titledBorderColor == null) { return; } else { throw new RuntimeException("TitledBorder default color should be null"); } } if (!defaultColor.equals(titledBorderColor)) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } // title color is explicitly specified Color color = Color.green; titledBorder.setTitleColor(color); if (!color.equals(titledBorder.getTitleColor())) { throw new RuntimeException("TitledBorder color should be " + color.toString()); } // title color is unspecified titledBorder.setTitleColor(null); if (!defaultColor.equals(titledBorder.getTitleColor())) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } }
Example 8
Source File: StopwatchProfilingPoint.java From netbeans with Apache License 2.0 | 5 votes |
private void initComponents() { setLayout(new BorderLayout()); JPanel contentsPanel = new JPanel(new BorderLayout()); contentsPanel.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.setOpaque(true); contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground())); headerArea = new HTMLTextArea() { protected void showURL(URL url) { String urlString = url.toString(); if (START_LOCATION_URLMASK.equals(urlString)) { Utils.openLocation(StopwatchProfilingPoint.this.getStartLocation()); } else if (StopwatchProfilingPoint.this.usesEndLocation()) { Utils.openLocation(StopwatchProfilingPoint.this.getEndLocation()); } } }; JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground())); headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH); dataArea = new HTMLTextArea(); JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); TitledBorder tb = new TitledBorder(Bundle.StopwatchProfilingPoint_DataString()); tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD)); tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N dataAreaScrollPane.setBorder(tb); dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER); add(contentsPanel, BorderLayout.CENTER); }
Example 9
Source File: Test7022041.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Check behaviour of method TitledBorder.getTitleColor() */ private static void checkTitleColor() { TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1)); Color defaultColor = UIManager.getLookAndFeelDefaults().getColor("TitledBorder.titleColor"); Color titledBorderColor = titledBorder.getTitleColor(); // check default configuration if (defaultColor == null) { if (titledBorderColor == null) { return; } else { throw new RuntimeException("TitledBorder default color should be null"); } } if (!defaultColor.equals(titledBorderColor)) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } // title color is explicitly specified Color color = Color.green; titledBorder.setTitleColor(color); if (!color.equals(titledBorder.getTitleColor())) { throw new RuntimeException("TitledBorder color should be " + color.toString()); } // title color is unspecified titledBorder.setTitleColor(null); if (!defaultColor.equals(titledBorder.getTitleColor())) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } }
Example 10
Source File: UIRes.java From RipplePower with Apache License 2.0 | 5 votes |
public static void addStyle(JComboBox<Object> textField, String labelName) { Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY); TitledBorder titled = BorderFactory.createTitledBorder(line, labelName); titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13)); titled.setTitleColor(fontColorTitle); Border empty = new EmptyBorder(0, 8, 0, 8); CompoundBorder border = new CompoundBorder(titled, empty); textField.setBorder(border); textField.setForeground(fontColor); textField.setFont(GraphicsUtils.getFont("Monospaced", 0, 13)); }
Example 11
Source File: Test7022041.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Check behaviour of method TitledBorder.getTitleColor() */ private static void checkTitleColor() { TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1)); Color defaultColor = UIManager.getLookAndFeelDefaults().getColor("TitledBorder.titleColor"); Color titledBorderColor = titledBorder.getTitleColor(); // check default configuration if (defaultColor == null) { if (titledBorderColor == null) { return; } else { throw new RuntimeException("TitledBorder default color should be null"); } } if (!defaultColor.equals(titledBorderColor)) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } // title color is explicitly specified Color color = Color.green; titledBorder.setTitleColor(color); if (!color.equals(titledBorder.getTitleColor())) { throw new RuntimeException("TitledBorder color should be " + color.toString()); } // title color is unspecified titledBorder.setTitleColor(null); if (!defaultColor.equals(titledBorder.getTitleColor())) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } }
Example 12
Source File: LoadGenProfilingPoint.java From netbeans with Apache License 2.0 | 5 votes |
private void initComponents() { setLayout(new BorderLayout()); JPanel contentsPanel = new JPanel(new BorderLayout()); contentsPanel.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.setOpaque(true); contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground())); headerArea = new HTMLTextArea() { protected void showURL(URL url) { String urlString = url.toString(); if (START_LOCATION_URLMASK.equals(urlString)) { Utils.openLocation(LoadGenProfilingPoint.this.getStartLocation()); } else if (LoadGenProfilingPoint.this.usesEndLocation()) { Utils.openLocation(LoadGenProfilingPoint.this.getEndLocation()); } } }; JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground())); headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH); dataArea = new HTMLTextArea(); JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); TitledBorder tb = new TitledBorder(Bundle.LoadGenProfilingPoint_DataString()); tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD)); tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N dataAreaScrollPane.setBorder(tb); dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER); add(contentsPanel, BorderLayout.CENTER); }
Example 13
Source File: GUIUtils.java From ethereumj with MIT License | 5 votes |
public static void addStyle(JTextArea textArea, String labelName, boolean isBorder) { Border border = null; if (isBorder) { Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY); TitledBorder titled = BorderFactory.createTitledBorder(line, labelName); titled.setTitleFont(new Font("Verdana", 0, 13)); titled.setTitleColor(new Color(213, 225, 185)); Border empty = new EmptyBorder(5, 8, 5, 8); CompoundBorder cBorder = new CompoundBorder(titled, empty); } textArea.setBorder(border); textArea.setForeground(new Color(143, 170, 220)); textArea.setFont(new Font("Monospaced", 0, 13)); }
Example 14
Source File: Test7022041.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Check behaviour of method TitledBorder.getTitleColor() */ private static void checkTitleColor() { TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1)); Color defaultColor = UIManager.getLookAndFeelDefaults().getColor("TitledBorder.titleColor"); Color titledBorderColor = titledBorder.getTitleColor(); // check default configuration if (defaultColor == null) { if (titledBorderColor == null) { return; } else { throw new RuntimeException("TitledBorder default color should be null"); } } if (!defaultColor.equals(titledBorderColor)) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } // title color is explicitly specified Color color = Color.green; titledBorder.setTitleColor(color); if (!color.equals(titledBorder.getTitleColor())) { throw new RuntimeException("TitledBorder color should be " + color.toString()); } // title color is unspecified titledBorder.setTitleColor(null); if (!defaultColor.equals(titledBorder.getTitleColor())) { throw new RuntimeException("L&F default color " + defaultColor.toString() + " differs from TitledBorder color " + titledBorderColor.toString()); } }
Example 15
Source File: GUIUtils.java From ethereumj with MIT License | 5 votes |
public static void addStyle(JTextField textField, String labelName) { textField.setHorizontalAlignment(SwingConstants.RIGHT); Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY); TitledBorder titled = BorderFactory.createTitledBorder(line, labelName); titled.setTitleFont(new Font("Verdana", 0, 13)); titled.setTitleColor(new Color(213, 225, 185)); Border empty = new EmptyBorder(5, 8, 5, 8); CompoundBorder border = new CompoundBorder(titled, empty); textField.setBorder(border); textField.setForeground(new Color(143, 170, 220)); textField.setFont(new Font("Monospaced", 0, 13)); }
Example 16
Source File: StructureVerifyDialog.java From workcraft with MIT License | 4 votes |
protected TitledBorder createTitileBorder(String title) { TitledBorder titledBorder = new TitledBorder(title); titledBorder.setTitleColor(Color.BLUE.darker()); return titledBorder; }
Example 17
Source File: UIConsts.java From Astrosoft with GNU General Public License v2.0 | 4 votes |
public static Border getTitleBorder(String title){ TitledBorder border = new TitledBorder(new EtchedBorder(), title); border.setTitleColor(UIConsts.DARK_GREEN); return border; }
Example 18
Source File: TakeSnapshotProfilingPoint.java From netbeans with Apache License 2.0 | 4 votes |
private void initComponents() { setLayout(new BorderLayout()); JPanel contentsPanel = new JPanel(new BorderLayout()); contentsPanel.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.setOpaque(true); contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground())); headerArea = new HTMLTextArea() { protected void showURL(URL url) { Utils.openLocation(TakeSnapshotProfilingPoint.this.getLocation()); } }; JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground())); headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH); dataArea = new HTMLTextArea() { protected void showURL(URL url) { File resolvedFile = null; try { resolvedFile = new File(url.toURI()); } catch (URISyntaxException ex) { ex.printStackTrace(); } final File snapshotFile = resolvedFile; if ((snapshotFile != null) && snapshotFile.exists()) { String type = TakeSnapshotProfilingPoint.this.getSnapshotType(); if (type.equals(TYPE_PROFDATA_KEY) || type.equals(TYPE_HEAPDUMP_KEY)) { ResultsManager.getDefault().openSnapshot(snapshotFile); } } else { ProfilerDialogs.displayWarning( Bundle.TakeSnapshotProfilingPoint_SnapshotNotAvailableMsg()); } } }; JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); TitledBorder tb = new TitledBorder(Bundle.TakeSnapshotProfilingPoint_DataString()); tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD)); tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N dataAreaScrollPane.setBorder(tb); dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER); add(contentsPanel, BorderLayout.CENTER); }
Example 19
Source File: TimedTakeSnapshotProfilingPoint.java From netbeans with Apache License 2.0 | 4 votes |
private void initComponents() { setLayout(new BorderLayout()); JPanel contentsPanel = new JPanel(new BorderLayout()); contentsPanel.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.setOpaque(true); contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground())); headerArea = new HTMLTextArea(); JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground())); headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH); dataArea = new HTMLTextArea() { protected void showURL(URL url) { File resolvedFile = null; try { resolvedFile = new File(url.toURI()); } catch (URISyntaxException ex) { ex.printStackTrace(); } final File snapshotFile = resolvedFile; if ((snapshotFile != null) && snapshotFile.exists()) { String type = TimedTakeSnapshotProfilingPoint.this.getSnapshotType(); if (type.equals(TYPE_PROFDATA_KEY) || type.equals(TYPE_HEAPDUMP_KEY)) { ResultsManager.getDefault().openSnapshot(snapshotFile); } } else { ProfilerDialogs.displayWarning( Bundle.TimedTakeSnapshotProfilingPoint_SnapshotNotAvailableMsg()); } } }; JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); TitledBorder tb = new TitledBorder(Bundle.TimedTakeSnapshotProfilingPoint_DataString()); tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD)); tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N dataAreaScrollPane.setBorder(tb); dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground()); contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER); add(contentsPanel, BorderLayout.CENTER); }
Example 20
Source File: JPanelFactory.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
private static TitledBorder createBorder(String title) { TitledBorder border = BorderFactory.createTitledBorder(title); border.setTitleColor(ColorPalette.FOREGROUND_COLOR); border.setTitleFont(Fonts.FONT); return border; }