所以我今天想到了一个想法,让一个java程序在我的PC后台运行并定期检查系统时间,当我注意到季节变化(冬季,秋季,夏季, Spring )时,我会更改 IDE 的所有颜色(关键字、评论和背景)以适应季节的颜色。不幸的是,我找不到此信息存储在文件中的位置。有谁知道它可能在哪里或者这是否可能?谢谢!
最佳答案
是的,这是可能的!!!
- 运行时选项
- 使用配置文件
- 使用 netbeans 库
1。运行时选项
如果您喜欢“MetalLookAndFeel & fontsize 14”,请运行以下命令
netbeans --laf javax.swing.plaf.metal.MetalLookAndFeel --fontsize 14
您可以从此链接安装主题列表 → Netbeans themes 。您可以根据您的选择以编程方式启动不同的主题。
2。使用配置文件
这可以通过更新位于以下位置的 netbeans.conf
文件来实现:${nb-install}/etc/netbeans.conf
例如:
C:\Program Files\NetBeans 8.1\etc\netbeans.conf
以编程方式使用所需的主题和字体大小更新conf文件。 例如:
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true"
您可以更新多个外观选项
- Windows - com.sun.java.swing.plaf.windows.WindowsLookAndFeel
- 金属 - javax.swing.plaf.metal.MetalLookAndFeel
- GTK - com.sun.java.swing.plaf.gtk.GTKLookAndFeel
- Aqua - apple.laf.AquaLookAndFeel
此外,您还可以配置其他参数。 此处列出的所有启动参数 → Startup Parameters
3。使用 netbeans 库
您可能对此更感兴趣。 完整的 netbeans API → netbeans Api 对应的Jar文件→jar files
`org.netbeans.api.editor.settings.FontColorSettings` will be used to change the font settings which include keywords, syntax, background, foreground etc.
一个小例子供大家引用
public void updateColors() {
EditorUI editorUI = Utilities.getEditorUI(textComponent);
if (editorUI == null) {
return;
}
String mimeType = NbEditorUtilities.getMimeType(textComponent);
FontColorSettings fontColorSettings = MimeLookup.getLookup(MimePath.get(mimeType)).lookup(FontColorSettings.class);
Coloring lineColoring = Coloring.fromAttributeSet(fontColorSettings.getFontColors(FontColorNames.LINE_NUMBER_COLORING));
Coloring defaultColoring = Coloring.fromAttributeSet(fontColorSettings.getFontColors(FontColorNames.DEFAULT_COLORING));
if (lineColoring == null) {
return;
}
// use the same color as GlyphGutter
final Color backColor = lineColoring.getBackColor();
// set to white by o.n.swing.plaf/src/org/netbeans/swing/plaf/aqua/AquaLFCustoms
if (org.openide.util.Utilities.isMac()) {
backgroundColor = backColor;
} else {
backgroundColor = UIManager.getColor("NbEditorGlyphGutter.background"); //NOI18N
}
if (null == backgroundColor) {
if (backColor != null) {
backgroundColor = backColor;
} else {
backgroundColor = defaultColoring.getBackColor();
}
}
}
关于netbeans - 以编程方式更改 Netbeans 内部的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35592494/