UIManager color at a JFileChooser

JFileChooser is compound JComponent, you can extract JButtons, JToggleButtons and JScrollPane with JViewPort that contains JList, please download Darryl’s Swing Utils , read descriptions, then run (Darryl’s) code, result is selection for JList or JTable (I voting for that) import java.awt.Color; import java.awt.Graphics; import javax.swing.*; import javax.swing.plaf.metal.MetalButtonUI; public class CrazyFileChooser { public static void main(String[] … Read more

JFormattedTextField issues

On Mac OS, the default behavior of the UI delegate, com.apple.laf.AquaTextFieldF, is similar to CaretPositionListener: Tab or Shift–Tab: place the caret at the beginning of the field. Click: briefly place the caret at the beginning of the field and then move it to the click point. IMO, the CaretPositionListener does the latter much more smoothly. … Read more

How to create a notification in swing

You might need a translucent frame without decorations. Quick demo OSX ] You can take advantage JLabel displays simple HTML import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.*; import java.util.Date; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; /** * Simple demo on how a translucent window * looks like when is used to display the system clock. * … Read more

I need to launch a JFrame from another JFrame and have that run like independent applications, help?

You might be able to adapt this Swing based Launcher that uses ProcessBuilder to run programs in a separate JVM. package gui; import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; /** * @see http://stackoverflow.com/a/5696404/230513 */ public class Launcher extends … Read more

Drag a painted Shape

One approach might be to convert each Shape to a GeneralPath as the Shape is added to the panel. Now the dragging logic only needs to support a single class that implements the Shape interface: import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.util.*; import javax.swing.*; public class ShapePanel extends JPanel { private ArrayList<ColoredShape> coloredShapes = … Read more

MouseListener Help Java

Any Component can have a MouseListener. JLabel is nice for a colored rectangle, as long as you make it opaque. Addendum: Having recommended MouseAdapter elsewhere, I should mention that one instance is enough. Addendum: This update adds the mouse listener in the ColorLabel constructor. import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import … Read more