Component « Graphics « Java Swing Q&A





1. Swing: why wont my custom component repaint?    stackoverflow.com

Item is a simple model class. ItemComponent is a view for an Item which just draws simple rectangles in a given spot. A bunch of ItemComponent instances are put into a ...

2. How can I repaint efficiently when using big custom component in Swing?    stackoverflow.com

I have made a custom component (derived from JComponent) which represents a draggable Bezier-curve.
(looks like a hanging cable, someone might know it from Bender or Cubase) My problem is: The curve may become ...

3. When is a Swing component 'displayable'?    stackoverflow.com

Is there a way (e.g., via an event?) to determine when a Swing component becomes 'displayable' -- as per the Javadocs for Component.getGraphics? The reason I'm trying to do this ...

4. Swing: How can I prevent flickering and "vibrating" of a component, when restricting its movement?    stackoverflow.com

I need to restrict movement of a component (JInternalFrame) inside a JPanel.
More exact: a component should only move along one axis when dragged by the user. I tried to do it ...

5. Flipping a gui Component in the x-z plane    stackoverflow.com

I would like to know the respective graphics transformations ..in creating a flipping effect of a ui component about the x-z plane. It needs to be done only using ...

6. Custom swing component: Problem with repaint()    stackoverflow.com

I'm building a custom swing component (more as a practical thought experiment than anything else). I'm having problems with repainting. My component has a jtree, a jtable, and then a part that ...

7. java paint problem - black components    stackoverflow.com

I am having a weird java problem - For some reason quite often when I open a dialog it becomes black. When I force a repaint (for example, draging it out ...

8. Visual Library - Embedded Swing components paint problem    forums.netbeans.org

You can see this problem in one of the Visual Library demos: test.component.ComponentTest Drag a component on top of another component and you will see the that the swing components "bleed ...

9. issue while painting awt/swing components with the visual library    forums.netbeans.org

vicould Joined: 15 Jul 2010 Posts: 3 Posted: Tue Aug 03, 2010 1:55 pm Post subject: issue while painting awt/swing components with the visual library Hello readers ! ...





10. paint specific component    coderanch.com

Hi, Say that I have 3 diff. JPanels . I want to draw in 1 Panel only (that mean the paint won't touch other 2 ) . How can I do that . I tried paintComponent(Graphics g) but nothing happen . But when I tried paint(Graphics g) then the whole program is messing up . I have also read the tutorial ...

11. Paint specific component ? (Repost1)    coderanch.com

Hi Anh, here is the modified program that works correctly.just compile and run it. import javax.swing.*; import java.awt.event.*; import java.awt.*; public class PaintOnePanelOnly extends JFrame{ private int xVal1=-1,yVal1=-1,xVal2=-1,yVal2=-1; public PaintOnePanelOnly(){ super("Test paint specific Panel"); Container c = getContentPane(); JPanel panel1 = new JPanel(); JLabel label1 = new JLabel("Panel 1", SwingConstants.LEFT); panel1.add(label1); c.add(panel1,BorderLayout.WEST); [B] final JPanel panel2 = new JPanel(){ public void ...

12. handling component paint    coderanch.com

13. Problem painting component    coderanch.com

Hello, I made a component called GradientLegend but I am having trouble to properly display it on a JFrame. The component is painted and immediately after disappears, leaving the frame empty (at least that's what happens when I compile and run the code below with java 1.4.1 for linux). By the tutorials I've been through the code seems to be right, ...

14. Painting to a specific component.    coderanch.com

15. Swing Components and Graphics Objects    coderanch.com

I'm trying to learn a little about Swing before I make my first attempt at programming a GUI. I had a couple of questions: When is a graphics object passed to a Swing Component for painting? Does this only happen with custom components, or all components? What does the graphics object help the compnent do? How is it involved in the ...

16. Incremental Painting on lightweight Components    coderanch.com

I guess you are talking about Painting in AWT and Swing Maybe some things have changed since the release of the article. For instance, literally: It's worth noting that the default implementation of Container.update() does not use recursion to invoke update() or paint() on lightweight descendents. However the API for Container.update says Updates the container. This forwards the update to any ...





17. Repainting Swing Components    coderanch.com

You should call "repaint()", and put custom painting code in the "paintComponent()". "repaint()" is a final method that is implemented somewhere deep down in the AWT API that does all the system specific stuff, like creating real graphics contexts, scheduling repaints, etc. "repaint()" at some point calls "update()", which calls "paint()", which calls "paintComponent()". In AWT you would override "paint()" to ...

18. graphics "components"    coderanch.com

I'm trying to draw a red square and a blue square but treat them as though they are individual components. Code below shows only the red square, but when the line frame.getContentPane().add(redAy) is commented out the blue square appears. Can anyone tell me what is going on and how to make both squares appear? Thanks! import javax.swing.*; import java.awt.*; //-------------------------- blue ...

19. Repaint component through functioncall    coderanch.com

Hi, I want to update the color of a Graphics object through a function call. How can I do that? My program consists of a main function. This function generates a Window object. Which finally displays my Window and starts an endless threat, basically never comes back to the main function. I want to update the graphic object through a function ...

20. repaint entire component    coderanch.com

Hello! I'm having some problems with paintings. I have a painting area which extends JPanel. On this area I add different objects that also extends JPanel. I have overridden the paintComponent in both classes and so far everything is working fine. I can move around the added object without problems. When I try to write a line from (0,0) to the ...

21. repaint paints the wrong component    coderanch.com

Hi, I am new to Swing and have been trying for 2 days to get a simple interface to work. It is supposed to have a drawing space on top and a button below which (for the moment) causes an orange square to appear in the drawing space. To make the drawing panel, I made a subclass of JPanel and overrode ...

22. How to force the repainting of a component    coderanch.com

import java.awt.*; import java.awt.font.*; import javax.swing.*; public class DrawingText extends JPanel { Font font; String text; public DrawingText() { font = new Font("lucida bright regular", Font.PLAIN, 24); text = "centered text"; } protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = getWidth(); int h = getHeight(); g2.setFont(font); FontRenderContext frc = g2.getFontRenderContext(); float width = (float)font.getStringBounds(text, ...

23. scrollable paint component    coderanch.com

24. When are components actually painted?    coderanch.com

Kind of a follow up to my modality question, but seemed different enough to warrant a new thread... So, I've been playing around a little with JFrames, specifically when their components get painted. for instance, if I have somthing that looks like this, ConnectFrame connect = new ConnectFrame(); connect.repaint(); while( true ); the frame itself will be appear, but none of ...

25. Blinking of components when using repaint()    coderanch.com

Originally posted by Murali Jaya Rao: ..and created those components in this method. Why are you doing it inside the paint method? That is the wrong way to do it. What other stuff are you doing it in paint? Usually you should : 1)Have a method to initialize all the components you need to add on the panel 2)Have a second ...

26. Swing Components and Graphics Objects    coderanch.com

I'm trying to learn a little about Swing before I make my first attempt at programming a GUI. I had a couple of questions: When is a graphics object passed to a Swing Component for painting? Does this only happen with custom components, or all components? What does the graphics object help the compnent do? How is it involved in the ...

27. getting paint notifications for offscreen components    coderanch.com

Hi everyone, I'm creating a scrollpane that displays it's view using OpenGL, for ultra-smooth scrolling. To do that, it paints a large area of it's view onto an image and displays the portion that it needs. When you scroll close to the edge it paints some more, asynchronously. The scrollpane's paint() method paints to an image, and there is a separate ...

28. Basic problem with painting of component    coderanch.com

This will be boring for most of you but I simply don't get it: I want to paint a JComponent of my own so I did this from what I understood: public class ExpFrame extends JFrame { private static String WINDOW_TITLE = "Mal-Versuche"; private JPanel view; public ExpFrame (Dimension dim) { super (); setLayout(new BorderLayout()); setSize(dim); Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); setLocation( ...

29. How can I trigger the repainting of the components?    coderanch.com

Hello everyone! Guys, I have been googling a lot about my problem and found a number of similar issues, but they have not helped me What I want is to refresh my components when something on which my components depend occures. I have created a special class called MyLabel and overridden a repaint() and setText(..) methods there. Also I have overridden ...

30. problem: lightweight component still being painted after remove    java-forums.org

problem: lightweight component still being painted after remove Hi! I'm pretty new to swing and started writing an applet few weeks ago, so far everything worked fine but now I've run into a problem I can't find a solution for, or even find out what causes this behavior. I've written a menu extending from JPanel with a BoxLayout that ...

31. Need help with using graphics in swing components    forums.oracle.com

Hi. I'm new to Java and trying to learn it while also developing an application for class this semester. I've been following online tutorials for about 2 months now, though, and so I'm not sure my question counts as a "new to Java" question any more as the code is quite long. Here is the basic problem. I started coding the ...