I have used the UIManager
to style my application UI so far. All is well except in my printing dialog, created using ServiceUI.printDialog
. I see it has inherited much of my UI style e.g. the dark background and white text, but the problem is the color of the labels for the groups have not changed. I've circled these in the image below.
The code used to create the print dialog is as follows:
PrintService[] availableServices = PrintServiceLookup
.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(new Copies(1));
attributes.add(MediaSizeName.ISO_A4);
attributes.add(new JobName(MainFrame.this.survey.jobName + "-Summary", null));
Dimension centre = ETools.getCentredWindowDim(new Dimension(300, 300));
PrintService service = ServiceUI.printDialog(null,
centre.width, centre.height, availableServices,
defaultService, null, attributes);
My UIManager
code is as follows:
private void styleUserInterface() {
UIManager.put("Panel.background", Color.decode(Colors.BG));
UIManager.put("TextField.background", Color.decode(Colors.TEXT_BG));
UIManager.put("TextField.foreground", Color.decode(Colors.FONT_GRAY));
UIManager.put("TextField.border", BorderFactory.createLineBorder(Color.decode(Colors.LIGHT_GRAY), 1));
UIManager.put("Label.foreground", Color.decode(Colors.FONT_WHITE));
UIManager.put("Button.background", Color.decode(Colors.BUTTON_BG));
UIManager.put("Button.foreground", Color.decode(Colors.FONT_WHITE));
UIManager.put("Button.border", BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.decode(Colors.LIGHT_GRAY), 1),
BorderFactory.createEmptyBorder(GAP_STANDARD,
GAP_STANDARD,
GAP_STANDARD,
GAP_STANDARD)));
UIManager.put("ComboBox.background", Color.decode(Colors.TEXT_BG));
UIManager.put("ComboBox.foreground", Color.decode(Colors.FONT_GRAY));
UIManager.put("ComboBox.border", BorderFactory.createLineBorder(Color.decode(Colors.LIGHT_GRAY), 1));
UIManager.put("RadioButton.background", Color.decode(Colors.BG));
UIManager.put("RadioButton.foreground", Color.decode(Colors.FONT_WHITE));
UIManager.put("CheckBox.background", Color.decode(Colors.BG));
UIManager.put("CheckBox.foreground", Color.decode(Colors.FONT_WHITE));
UIManager.put("CheckBox.disabledText", Color.decode(Colors.FONT_DISABLED));
}
The border around my panel is also not filled with my dark background color. Any help on this is much appreciated! Thanks.
I figured out how to change the color of these labels using the `UIManager' using the following:
UIManager.put("TitledBorder.titleColor", Color.WHITE));