Draw « Layout « Java Swing Q&A





1. How to draw on JPanel on fixed position?    stackoverflow.com

I have JPanel wrapped in JScrollPane and I want the rectangle to be drawn always on the same position = moving with scrollbars wont affect the visibility of the rectangle. I tried ...

2. Java: getting the absolute position of the mouse in a JPanel given the coordinate the user clicked on    stackoverflow.com

For example, suppose I have a drawing in a JPanel subclass with JScrollPanes, and I want to capture the points the user clicks on. Suppose, for example, the drawing area inside ...

3. Group.layout() not displaying newly added fields in modified group? (SWT Newbie!)    stackoverflow.com

I am new to SWT development and am trying to build an extremely simple GUI window (going by the online tutorials and examples). My little GUI takes a string and ...

4. Adding drawing area to null layout GUI    stackoverflow.com

I have been working on a GUI for some time, I am required to plot my results in a scatter diagram, the problem is is that I need to create a ...

5. Setting Layout to GridBag makes a drawing on JPanel disappear.    forums.oracle.com

import java.awt.* import javax.swing.* import java.awt.geom.* import javax.swing.border.* public class Transforms { main ... thread safe code createAndShowGUI ... JFrame jf = new JFrame(); jf.setTitle("Transforms"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setLayout(new GridBagLayout()); jf.add(new DisplayContents(); jf.pack(); jf.setVisible(true); } class DisplayContents extends JPanel { paintComponent(Graphics g) { int x = 10; int y = 10; Rectangle rectangle = this.getBounds(); int height = rectangle.height; int width = rectangle.width; ...