Paint « Graphics « Java Swing Q&A





1. Problem with Painting in Java Swing App in Java 1.6    stackoverflow.com

I'm working on a Swing application (currently running on Java 1.6 update 11) which has some intermittent paint refresh problems (e.g. there are artifacts etc.). This only happens to some users ...

2. paint a property pane from xml schema    stackoverflow.com

We need to build a swing component to let users enter property values in a property sheet. These properties are defined in a XSD file. For example:

 <xs:complexType name="email">
  <xs:sequence>
 ...

3. Can't use repaint()?    stackoverflow.com

//I want to paint a ball in a animation
//I can't seem to find a way to repaint the ball
// Any help or tips on how to use repaint here?
//

   ...

4. Java sick GUI that does not pertain to look and feel?    stackoverflow.com

I wanted to know how people make these sick GUI's in java? I know how to make the standard crappy one with a nice background, but that is it. Basically what I am ...

5. painting on the gui    forums.netbeans.org

I am trying to create a java application which performs a calculation on each pixel then either fills it in or leaves it blank. To do this, I need to mark ...

6. swing layer painting    coderanch.com

7. painting problems    coderanch.com

Whenever i iconify and deiconify my Jframe containing a canvas component i lose my previously drawn information on the canvas. the canvas is erased. How can i prevent it ? i tried using buffer. but when i call repaint() the painting is done on the canvas but afterwards the frame repaints and i lose my previous painting. can anyone help me ...

8. Paint in swing    coderanch.com

9. Paint in Swing    coderanch.com





10. Please help me with swing and paint...    coderanch.com

11. Painting    coderanch.com

12. java swings paint    coderanch.com

hai i am doveloping an editor for indian languages this is the problem that i am facing. i am using a panel ,added to a frame, to display the text. i have a menu bar attached to the frame whenever the menu from the bar is pulled down the text behind the pulled down menu is getting erased and not getting ...

13. Urgent Pls Help - Painting    coderanch.com

14. HELP ! Best Architecture for Swing Paint Tools    coderanch.com

I would really, really appreciate any help you can offer. I have been working on this problem for several saturdays and sundays and still don't have a good solution. Imagine a Swing application that emulates a football (or any other sport) coaches "paint" program. Using the football metaphor... The basic application extends a JFrame and has a Border Layout. There is ...

15. java paint application    coderanch.com

16. Painting mechanism in swing    coderanch.com





17. How to made a "paint" ?    coderanch.com

18. Some painting problem    coderanch.com

I was trying to make a bar chart from a given data. I used an extension JLabel (mentioned as inner class Leonardo) inside a scrollpane for the custom painting of the bars (rectangles). The problem I am facing is the component is not visible when I open the screen. If I drag the scrool bar then the next area is painted ...

19. Paint() Problem    coderanch.com

Hi all, I am using a jpanel, which is added to a scroll pane which in turn added to jDialog. In the jpanel i am drawing some 441 squares and some texts. Everything is fine. But the scrolling is extreamly slow. Is there any way to make the scrolling normal. Please help me soon. It is very urgent. Thanking all.

20. repaint and Paint    coderanch.com

Repaint() makes calls to the background painting routines hidden away somewhere in the JVM. Basically, it's just a request for a repaint. repaint() doesn't do an actual repaint for each time it is called because that would actually make painting slower. This would happen if repaint() was called faster than the screen could refresh or that calculations needed for the paint ...

21. Paint not being called    coderanch.com

I've got a custom component that I'm trying to draw on the screen. However, my paint()/painComponent() method is not being called. My component inherits from JPanel and overrides paintComponent(Graphics g) (although it has also overridden paint(Graphics g) at various points in its history as I've tried to make this thing work.) I place this JPanel in another JPanel and that in ...

22. (paint) autoCall??    coderanch.com

It happens because components repaint for lots of reasons... when they first become visible, when something partially covers them, when their model updates, etc. It would be a lot more of a pain if you had to manually tell components when they could repaint. What is the problem that is caused when you add the canvas to the frame? And what ...

23. problem with paint()    coderanch.com

im trying to make a blackjack game with graphics. I have a text based version running and I have a problem with the GUI. I am using KeyEvents to listen to what the user wants to do (i.e. hit, stay, etc). My paint method calls a play() method which asks for bet, displays cards etc. Then it is supposed to wait ...

24. Swing re-paint issue    coderanch.com

I have a Jtree which allows me to select different nodes. Based on the level of the selected node, I display a different panel on the right of the tree. This works except for one thing. When I switch back and forth it stops painting the panel correctly. It doesn't show up until you move the mouse over some of the ...

25. help! I cant get this to paint    coderanch.com

I need help getting this circle to appear when my circle button is pressed... I need the class headers to remain the same (unless adding extends or implements) because this is actually a piece of an assignment. I've been trying for hours and hours, but I cant get anything to appear! drawMain.java import javax.swing.*; public class drawMain { public drawMain() { ...

26. NEED HELP! JRE 1.5 Paint Issue    coderanch.com

This is driving me crazy. I have an applet that works fine in JRE 1.4 but in JRE 1.5 my validate and repaint commands don't seem to be doing anything. If I minimize the application and then restore it, a repaint happens and I can see what I just did. I am using Swing componants like nested JPanels and such. Does ...

27. paint() problems    coderanch.com

hello, i am interest in Swing, following is a part of code copied from a website which discuss paintImmediately(). 1public void actionPerformed(ActionEvent e) { 2if (e.getActionCommand().equals("repaint")) jpl.repaint(); 3else jpl.paintImmediately(50 , 50 , 100 , 100); 4 5try { Thread.sleep(3000); } 6catch(Exception err) {} 7} 8 9class JPanelEx extends JPanel { 10int backColor = 0xFF; //0xFF color blue 11 12public void paint(Graphics ...

28. Painting Issues    coderanch.com

29. Gradient paint issue    coderanch.com

You probably want to use new Color(10, 255, 10, 0), where 10-255-10 is your shade of green, instead of new Color(0, 0, 0, 0), unless you want the gradient to go to a transparent black/grey instead of to green. The point is that the final 0 means fully transparent. (A final 255 would mean fully opaque.)

30. painting    coderanch.com

This method actually delegates the work of painting to three protected methods: paintComponent, paintBorder, and paintChildren. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking, the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method, as always. A subclass that ...

31. painting problems    coderanch.com

32. paint() and repaint()    coderanch.com

Just a quick question, I am trying to build a program that will let you click a button to change the background color of a frame. in my actionPerformed method I have the following if(ae.getSource() == red1) { content.setBackground(Color.red) That is where I am stuck, I know I need to call repaint() but what should I put in the paint() method? ...

33. Paint    coderanch.com

Hi friends, I've several tabs in my multilevel JTabbedPane.When i keep clicking on the tabs.I find there is some difficulty in panel getting painted pertaining to each selected tab. It is like, if tab 'B' is clicked you will still see the tab 'A's panel painted.I mean previous tabs information displayed under currently selected tab. Can i get some tip on ...

34. Java paint question    coderanch.com

Is it possible to chnage white image background to transparent using Java 2D API? I know how to set composite to turn whole image transparent, but I am wondering if I can set selective color of the image as transparent?? Is that possible? How can I do this? Any pointers, suggestions would be highly appreciated. TIA, - Manish

35. problem painting    coderanch.com

The drawing is done in the JFrame's 'paint' event. This is not the recommended way to draw in a toplevel container. Better to use a JPanel or JComponent that is dedicated to graphic display. Here is an example. import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; public class FrameDrawing implements ActionListener { FrameDrawingPanel topPanel; FrameDrawingPanel bottomPanel; public void actionPerformed(ActionEvent e) { ...

36. Swing: Slow paint    coderanch.com

Hi Ranchers, I'm creating an application where I need "Snap-component-to-grid" functionality. To show the grid and paint the component that needs to be snapped to the grid, I'm using a coding structure as below: import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JFrame; import javax.swing.JPanel; public class SlowGridRender extends JPanel { private Color gridColor ...

37. problem in using paint    coderanch.com

Hi, I am using below code to move a rectangle on a Canvas - First time when i run my program, rectange comes fine but when i click on the move button it doesn't. Below is my code to do that - public void actionPerformed(ActionEvent ae) { for (int i=0;i<10 ;i++ ) { (MyPictureAct.x)++; mt.repaint(); ///mt is object reference of my ...

38. Paint Problem    coderanch.com

import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; public class VizTest extends JPanel { public VizTest() { super(); JTextField text = new JTextField(); text.setText("sample text"); add(text); } public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.RED); g.drawOval(10, 10, 300, 300); setVisible(true); setOpaque(true); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(2000, 2000); VizTest v = new VizTest(); ...

40. simple painting... really confusing...    coderanch.com

package os; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Graphics; import javax.swing.JApplet; import javax.swing.JPanel; public class ganttcharts extends JApplet { private Drawing drawing; public void init() { drawing = new Drawing(); Container cont = getContentPane(); cont.setLayout(new BorderLayout()); cont.add(drawing, BorderLayout.CENTER); } private static final class Drawing extends JPanel { public void paintComponent (Graphics g) { super.paintComponent(g); g.drawRect(10,10,70,30); g.drawRect(80,10,40,30); g.drawRect(120, 10, 80, 30); } } ...

41. Question about painting    coderanch.com

42. Having two problem on paint    coderanch.com

hi there, I have some problem on using paint below is my code: import javax.swing.*; import java.awt.*; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; class MyCanvas extends JComponent { private ImageIcon logo2 = new ImageIcon( "Logo2.gif" ); int x = 0; int y =0; public void paint( Graphics g ) { logo2.paintIcon( this, g, x, y ...

43. creating an application similar to ms paint in java...    coderanch.com

Here's the deal...I am creating my own version of ms paint in java. I am expected to work in the constraints of awt (swing strictly prohibited). I need image buttons for functionalities such as drawing a rectangle etc just as it is in the actual application. It is noted that no such buttons are available in Java so I surfed a ...

44. Dialogbox getting stuck on paint    coderanch.com

Greetings. I have a small problem with a dialogbox and a paint method I hope someone can help me with. I couldn't find any exsisting threadds on this matter, but if there is please direct me to it so I can close this one. I've made a menu to host some mini-games and on the menu I've made it possible for ...

45. question about painting efficiently    java-forums.org

Hello, I'm experimenting with painting in swing, and I'm having some difficulty doing it as efficiently as I can (or I think is possible). Let me show my paintComponent() method as it stands now: Java Code: public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.BLUE); if (W1.redraw) g.drawRect(W1.getX(), W1.getY(), Wall.LENGTH, Wall.THICKNESS); if (W2.redraw) g.drawRect(W2.getX(), W2.getY(), Wall.THICKNESS, Wall.LENGTH); g.setColor(Color.RED); g.drawOval(cx, cy, cw, ch); } ...

46. Paint    java-forums.org

I am attempting to make a paint tpye program for a school project, it is an applet. The current problem i am haveing is that the mouse cant move very quickly before spaces become between them. Is there any way to make my program run faster to get rid of these??? here she is (Try moving your mouse very quickly to ...

47. Paint problem(swing)    forums.oracle.com

I guess there's something wrong in the DrawG class but I'm not sure, can anyone help me? Yes, it has no size. Let me guess you were either adding it to BorderLayout.CENTER or just using add(Component) and not specifying a constraint before? The reason it worked is because unless otherwise specified a component added to a BorderLayout goes into the CENTER ...

48. Swing Painting Problems With Upgrade from Java 1.5 to 1.6    forums.oracle.com

I recently ungraded an app to 1.6 and I am seeing some weird instances were GUI components are only repainting a portion of the GUI. For example, I have a tree on one dialog and it displays perfectly when I open the dialog once, but if I change the tree and redisplay you see stale images and it only refreshes correctly ...