So I came up today with an idea of having a java program that runs in the background on my PC and periodically checks the system time, and when I notice a change in the seasons ( Winter, Fall, Summer, Spring), I would change all the colors of the IDE (the keywords and comments and background) to fit with the colors of the season. Unfortunately, I can't find where this information is stored on file. Does anyone have any idea where it could be or if this is possible? Thanks!
1 Answers
Yes it is possible !!!
- Run time options
- Using configuration file
- Using netbeans libraries
1. Run time options
If you like to have 'MetalLookAndFeel & fontsize 14, run below command
netbeans --laf javax.swing.plaf.metal.MetalLookAndFeel --fontsize 14
You can install list of themes from this link → Netbeans themes. You can launch a different theme programmatically based upon your choice.
2. Using configuration file
This can be achieved by updating the netbeans.conf
file located in below location ${nb-install}/etc/netbeans.conf
for ex:
C:\Program Files\NetBeans 8.1\etc\netbeans.conf
Update the conf file with desired theme & font size programmatically. for ex:
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"
You can update multiple look and feel options
- Windows - com.sun.java.swing.plaf.windows.WindowsLookAndFeel
- Metal - javax.swing.plaf.metal.MetalLookAndFeel
- GTK - com.sun.java.swing.plaf.gtk.GTKLookAndFeel
- Aqua - apple.laf.AquaLookAndFeel
Additionally, you can configure other parameters as well. All startup parameters listed here → Startup Parameters
3. Using netbeans libraries
You might be more interested in this. Full netbeans API → netbeans Api Corresponding Jar files → jar files
`org.netbeans.api.editor.settings.FontColorSettings` will be used to change the font settings which include keywords, syntax, background, foreground etc.
One small example for your reference
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,902
- 8
- 34
- 57
-
Thank you for this! I tried importing the package for the Netbeans API that you suggested but it clearly isn't there by default. I checked online for a download but couldn't find it. Any idea how I add it? Is it in Netbeans somewhere? Thanks! – Tim Feb 27 '16 at 23:10
-
2Jar files download link → http://www.java2s.com/Code/Jar/o/Downloadorgnetbeansmoduleseditorsettingsjar.htm , I have updated my answer as well for future reference. – Raju Feb 27 '16 at 23:24