How to put a component on top of others?
There’s a JLayeredPane example here, but OverlayLayout, seen here, may be of interest. It’s not included in the conventional gallery. Also consider this example that paints on the scroll pane’s JViewport.
There’s a JLayeredPane example here, but OverlayLayout, seen here, may be of interest. It’s not included in the conventional gallery. Also consider this example that paints on the scroll pane’s JViewport.
since I search for different suggestion I closed this question with my original knowledges about Graphics based on code import java.awt.*; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; //import java.awt.image.ColorModel; // I don’t know how to use that //import java.awt.image.SampleModel;// I don’t know how to use that import javax.swing.*; import javax.swing.RepaintManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.TableModel; public … Read more
The example below creates MAX ornaments for your tree. It uses a ComponentListener to relocate any outlying ornaments. package merrychristmas; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.util.LinkedList; import java.util.Queue; import java.util.Random; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.Timer; public … Read more