when i mouse-over it, it loses the color that i have set for it. This is because MetalTheme of MetalLookAndFeel ignores BasicLookAndFeel color settings as follows. /* @see javax/swing/plaf/metal/MetalIconFactory.java */ class MenuArrowIcon implements Icon {...
  • April 8, 2022
  • 0 Comments
To draw a rectangle in Swing you should: First of all, never draw directly in the JFrame or other top-level window. Instead draw in a JPanel, JComponent or other...
  • April 7, 2022
  • 0 Comments
If you have an java.awt.Image, rezising it doesn’t require any additional libraries. Just do: Image newImage = yourImage.getScaledInstance(newWidth, newHeight, Image.SCALE_DEFAULT); Ovbiously, replace newWidth and newHeight with the dimensions of the specified image.Notice the last parameter: it tells...
  • April 6, 2022
  • 0 Comments
You should actually take the result from the option pane: dialogButton = JOptionPane.showConfirmDialog (null, "Are you sure?","WARNING", dialogButton); Otherwise, it remains set to JOptionPane.YES_NO_OPTION. Cleaner would be: if (JOptionPane.showConfirmDialog(null,...
  • April 5, 2022
  • 0 Comments