How to clear the cache in NetBeans

Close NetBeans before deleting the cache. NetBeans 7.2+, Windows 7 Cache is located in C:\Users\<username>\AppData\Local\NetBeans\Cache\. Clear the cache using the %USERPROFILE% Windows variable: del /s /q %USERPROFILE%\AppData\Local\NetBeans\Cache\ If it is set, you can also use the environment variable %LOCALAPPDATA%: del /s /q %LOCALAPPDATA%\NetBeans\Cache\ NetBeans 7.2+, Linux Cache is at: ~/.cache/netbeans/${netbeans_version}/index/ Mac OS X Cache is … Read more

Centering a JLabel on a JPanel

Here are four ways to center a component: import java.awt.*; import javax.swing.*; import javax.swing.border.*; class CenterComponent { public static JLabel getLabel(String text) { return getLabel(text, SwingConstants.LEFT); } public static JLabel getLabel(String text, int alignment) { JLabel l = new JLabel(text, alignment); l.setBorder(new LineBorder(Color.RED, 2)); return l; } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() … Read more

Java Swing button colors [duplicate]

Here is a question and several answers related to flashing a component. Addendum: You can learn more in the article How to Use Buttons. In particular, you can use setForeground() to change the color of a button’s text, but the corresponding setBackground() doesn’t read well on some platforms. Using a Border is one alternative; a … Read more

Netbeans GUI editor generating its own incomprehensible code

You may have inadvertently selected Java Desktop Application Creates a skeleton of a desktop application based on the Swing Application Framework (JSR 296). This template provides basic application infrastructure such as a menu bar, persisting of window state, and status bar. With this template, you can also generate code to create a GUI interface for … Read more