JComponent « Graphics « Java Swing Q&A





1. Can findComponentAt() work before a JComponent is painted?    stackoverflow.com

I am working on a GUI where the JComponents are "stamped" on the screen. In other words, the actual components aren't displayed, but images of the components. This is ...

2. How to wait until JComponent is fully painted?    stackoverflow.com

I need a way to wait until a (Swing) JComponent is fully painted. This actual problem arises from an openmap application: The task is to draw a map (mapBean) with a ...

3. Using Java's JComponent repaint()    stackoverflow.com

I'm writing a simple Game of Life program in Java and am having a bit of trouble getting it to animate. I've got a JComponent class LifeDraw, which displays a grid ...

4. JComponent is not visible, anyone knows why?    stackoverflow.com

Here's my JFrame code:

public static void main(String[] args) {
    JFrame jf = new JFrame();
    jf.setSize(600,600);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MyCustomWidget widget = ...

5. painting JComponents    coderanch.com

6. Second Posting JComponent Paint    coderanch.com

7. painting a custom JComponent    coderanch.com

Howdy, I searched through the forum archives and I couldnt find the answer to my question so I figured i'd post this in hopes that someone can help me. I want to eventually create an canvas where i can click and draw rectangles and interact with them(e.g. move them around- have borders on them etc). I figured that having a JComponent ...

8. Adding JComponent in Paint    coderanch.com

Hi Vijay, You might want to rethink your design. The paint method gets called a lot (expose, first time, resize, etc) and you should not be adding any components in it because you will end up with many components when you only want one! You should only use the paint method for drawing your lines. Regards, Manfred.

9. Graphics.drawChars() and JComponent    coderanch.com





10. painting custom components without extending jcomponent    coderanch.com

Hi, I am not understanding how to draw my custom components onto a panel. My teacher is asking for an abstract class, Shape, which cannot extend or implement anything. Then I have two subclasses, Circle and Square, that extend Shape (so they cannot extend anything else like JComponent). Finally I have a class, Draw, that creates a main window and adds ...

11. Painting with a custom JComponent    coderanch.com

I'm trying to do some custom drawing via a JComponent. I can get the frame to show, but unfortunately I can't seem to get the graphics to appear. Here is a minimal version of my code. import javax.swing.*; import java.awt.*; public class SwingTest { public static void main(String[] args) { final int WIDTH = 50; final int HEIGHT = 50; final ...

12. Can't paint a JComponent    coderanch.com

I am using graphics to draw ovals and then I want to display the ovals, but It is not working. My code is private void drawTheTree() { graphics.setColor(new Color(153, 255, 255)); for (GraphNode nextGraphNode : nodesList) { int x = nextGraphNode.i * SEPARATION + DIAMETER / 2; int y = nextGraphNode.j * SEPARATION + DIAMETER / 2; graphics.drawOval(x, y, DIAMETER, DIAMETER); ...

13. How to repaint a JComponent?    coderanch.com

Hello , every JAVA lovers. I am a newer.How to repaint AlphaCompositeShow ,when I slide?Here is a part of source. package chapter5; import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JSlider; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class AlphaCompositeShow extends JComponent ...

14. How do you consistently repaint a JComponent?    forums.oracle.com