首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过编程更改Netbeans内部的颜色?

通过编程更改Netbeans内部的颜色?
EN

Stack Overflow用户
提问于 2016-02-24 03:08:27
回答 1查看 336关注 0票数 2

因此,我今天想出了一个想法,让java程序在我的PC上运行,并定期检查系统时间。当我注意到季节(冬、秋、夏、春)发生了变化时,我会改变IDE的所有颜色(关键字、注释和背景),以适应季节的颜色。不幸的是,我找不到这些信息存储在文件中的位置。有没有人知道它可能在哪里,或者这是否有可能?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-27 00:50:18

是的,这是可能的!

  1. 运行时选项
  2. 使用配置文件
  3. 使用netbeans库

1.运行时选项

如果您想拥有“MetalLookAndFeel& fontsize 14”,请运行以下命令

代码语言:javascript
运行
复制
netbeans --laf javax.swing.plaf.metal.MetalLookAndFeel --fontsize 14

您可以从这个链接Netbeans主题安装主题列表。您可以根据您的选择以编程方式启动不同的主题。

2.使用配置文件

这可以通过更新位于下面位置的netbeans.conf文件${nb-install}/etc/netbeans.conf来实现,以便执行如下操作:

C:\程序文件\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.notter=true-J-Dsun.java2d.dpi华=true-J-Dsun.zip.disableMemorymap=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

此外,还可以配置其他参数。这里列出的所有启动参数都是启动参数

3.使用netbeans库

你可能对此更感兴趣。完整netbeans API netbeans Api对应的Jar文件→jar文件

代码语言:javascript
运行
复制
`org.netbeans.api.editor.settings.FontColorSettings` will be used to change the font settings which include keywords, syntax, background, foreground etc.

一个供你参考的小例子

代码语言:javascript
运行
复制
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();
        }
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35592494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档