Skip to content

Commit 2659875

Browse files
Set foreground color on board/library titles in managers
In commit 93581b0 (Set foreground color in library/board manager), the foreground color was set in addition to the background color, to make sure that the library and board manager would remain readable even with a non-standard color scheme (e.g. a dark theme). When that commit was created, this worked properly. However, between creating that commit and merging it as part of #9272, the title rendering was changed from being part of the description (which had its color set up properly) to being part of the title border (which used default colors) in #9262. This commit fixes this again by applying the foreground color also to the TitledBorder component. In ContributedPlatformTableCellJPanel this also moves the creation of the TitledBorder into the constructor, and for ContributedLibraryTableCellJPanel upwards in the constructor (where it is run unconditionally), so the property can be final.
1 parent 42336ac commit 2659875

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Diff for: app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
3434
final JPanel inactiveButtonsPanel;
3535
final JLabel statusLabel;
3636
final JTextPane description;
37+
final TitledBorder titledBorder;
3738
private final String moreInfoLbl = tr("More info");
3839

3940
public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
4041
boolean isSelected) {
4142
super();
4243
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
4344

45+
// Actual title set below
46+
titledBorder = BorderFactory.createTitledBorder("");
47+
titledBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
48+
setBorder(titledBorder);
49+
4450
moreInfoButton = new JButton(moreInfoLbl);
4551
moreInfoButton.setVisible(false);
4652
installButton = new JButton(tr("Install"));
@@ -120,9 +126,7 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
120126
return;
121127

122128
ContributedLibrary selected = releases.getSelected();
123-
TitledBorder titledBorder = BorderFactory.createTitledBorder(selected.getName());
124-
titledBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
125-
setBorder(titledBorder);
129+
titledBorder.setTitle(selected.getName());
126130
Optional<ContributedLibrary> mayInstalled = releases.getInstalled();
127131

128132
boolean installable, upgradable;
@@ -271,5 +275,7 @@ public void setForeground(Color c) {
271275
// The description is not opaque, so copy our foreground color to it.
272276
if (description != null)
273277
description.setForeground(c);
278+
if (titledBorder != null)
279+
titledBorder.setTitleColor(c);
274280
}
275281
}

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,19 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
6767
final JPanel inactiveButtonsPanel;
6868
final JLabel statusLabel;
6969
final JTextPane description;
70+
final TitledBorder titledBorder;
7071
private final String moreInfoLbl = tr("More Info");
7172
private final String onlineHelpLbl = tr("Online Help");
7273

7374
public ContributedPlatformTableCellJPanel() {
7475
super();
7576
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
7677

78+
// Actual title set by update()
79+
titledBorder = BorderFactory.createTitledBorder("");
80+
titledBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
81+
setBorder(titledBorder);
82+
7783
{
7884
installButton = new JButton(tr("Install"));
7985
moreInfoButton = new JButton(moreInfoLbl);
@@ -186,9 +192,7 @@ void update(JTable parentTable, Object value, boolean hasBuiltInRelease) {
186192
}
187193

188194
ContributedPlatform selected = releases.getSelected();
189-
TitledBorder titledBorder = BorderFactory.createTitledBorder(selected.getName());
190-
titledBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
191-
setBorder(titledBorder);
195+
titledBorder.setTitle(selected.getName());
192196
ContributedPlatform installed = releases.getInstalled();
193197

194198
boolean removable, installable, upgradable;
@@ -311,5 +315,7 @@ public void setForeground(Color c) {
311315
// The description is not opaque, so copy our foreground color to it.
312316
if (description != null)
313317
description.setForeground(c);
318+
if (titledBorder != null)
319+
titledBorder.setTitleColor(c);
314320
}
315321
}

0 commit comments

Comments
 (0)