KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(“focusOwner”, new PropertyChangeListener() { Color FOCUS_COLOR = Color.CYAN; Component last; Color background = null; public void propertyChange(PropertyChangeEvent evt) { Component current = (Component)evt.getOldValue(); Component future = (Component)evt.getNewValue(); if(current==last && current != null) { current.setBackground(background); } last = future; if(last!=null) { background = last.getBackground(); last.setBackground(FOCUS_COLOR); } } }); ….and voila! you get EVERY component that can [...]
Archive for July, 2003
July 24, 2003
3
Best 20 lines of Swing KeyboardFocusManager code I’ve ever written ;)
By Max in Java
July 10, 2003
8
Java Printing on Unix is flakey, even on 1.4.2!
By Max in JavaGeez – I was just starting to be so happy for the Java Printing Service API. It works like a charm under Windows. The following code list all printers available AND which trays that are available. Works fine on Windows, but NOT on Solaris or even Linux ;( // Get a list of printservices. PrintService[] [...]