0
我已經使用UIManager
來設置我的應用程序UI。除了在我的打印對話框中使用ServiceUI.printDialog
創建的所有內容都很好。我發現它已經繼承了我的很多UI風格,例如黑色的背景和白色的文字,但問題是組的標籤顏色沒有改變。我在下面的圖片中圈出了這些。Java Swing打印對話框GroupLayout標籤顏色
用於創建打印對話框中的代碼如下:
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);
我UIManager
代碼如下:
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));
}
在我的面板邊框還沒有充滿了我深色的背景色。任何幫助,這是非常感謝!謝謝。