Canvas « Graphics « Java Swing Q&A





1. How to make canvas with Swing?    stackoverflow.com

I'm trying to make a paint editor with Java in which I have a toolbar with the objects that I would like to paste in the canvas. I'm using swing components ...

2. Flex : Disabled canvas look and feel    stackoverflow.com

Is there a way in Flex by which a disabled canvas looks exactly the same
as an enabled canvas? I haven't been able to make sense of disabledOverLayAlpha
and disabledColor properties for a ...

3. Are there any GUI toolkits built on top of HTML Canvas like swing,swt,gtk or qt?    stackoverflow.com

Are there any GUI toolkits built on top of HTML Canvas like swing,swt,gtk or qt? So that it is possible to build applications like applets or flex gui:s inside the html ...

4. Need Java Swing HTML canvas with support for integrated swing controls    stackoverflow.com

I would like to create an application in swing in the style of web 2.0 but have the power and functionality of a thick client. I know substance and some other ...

5. can we zoom in zoom out the drawing we draw on the Canvas?    stackoverflow.com

We have an old (more than 10yrs old) Java Swing applicatin which draws lots of circles and connections (lines) between those circles on a JCanvas (a subclass of JComponent) based on ...

6. Help with drawing custom graphics in Swing    stackoverflow.com

I know that i am not calling the graphics paint command in the mainframe in order to display it. but i'm not sure how. thanks in advance

import java.awt.*;
import javax.swing.*;
public class MainFrame extends ...

7. Keep getting an Error "Component must be displayable"    stackoverflow.com

Hi I keep getting an error "Component must be displayable" and cant solve it I looked at the Questions on SO and tried the solutions but to no avail. I'm trying ...

8. Drawing a half gauge/speedometer (JavaScript Canvas or Java Swing Example needed)    stackoverflow.com

has anyone a javascript canvas or java swing example? Something like this: http://www.fmsinc.com/microsoftaccess/controls/components/gauges/gauge-half.gif How should i draw the "separator" lines?

9. AWT Canvas flickering on manual resize    stackoverflow.com

Just out of intellectual interest can you make a Canvas not flicker when doing a manual resize.

public class FlickerAWT extends Canvas {

public static void main(String[] args) {
 Frame f = new ...





10. Drawing problem with Canvas and Timer    stackoverflow.com

i have a problem with canvas i wanted to show some moving balls on canvas (animation) but there is nothing i can see except black background. can somebody tell me the ...

11. Swing method akin to HTML5's canvas.putImageData(arrayOfPixels, 0,0)    stackoverflow.com

I have some Javascript code that acts on an pixel array defined like so:

screen = {'width':160, 'height':144, 'data':new Array(160*144*4)};
...
canvas.putImageData(GPU._scrn, 0,0);
Where screen is 1D array of width * height * 4 ...

12. Custom Canvas Object Not Auto-Repainting    stackoverflow.com

I'm creating a server/client mmo as a summer project before I head back to high school, and I chose to use Reddwarf and swing for my client side. I created a ...

13. JavaMonkey Canvas    stackoverflow.com

I've been trying to get Java monkey engine-3 to render to a canvas/panel object so it can be embedded in a GUI. I'm sure this must be possible but searching around ...

14. some help reqd in painting of Canvas?    coderanch.com

Hi Freinds , I had made a chat in swings some time back and am now bringing it down to awt, for the colors part of the message window i used canvas as there is not support for multiple colors at the same time in textarea etc.For testing only i made this small class , the problem is that i explicitly ...

15. Canvas to Component?    coderanch.com

16. Word wrapping in Canvas !!!!    coderanch.com

Hi Friends, I have a canvas in a chat applet where all the messages are being drawn/displayed send by different users. Now, the problem is - the width of a canvas is fixed. Now, the problem is when the user types a message the length of which is more than the canvas width, the message gets cuts when the canvas width ...





17. Flickering of Canvas    coderanch.com

i have used AWT for constructing a ImageDrawing tool,for that i used a canvas as the drawing pad.in my tool box i have options such as Line,Circle,Rectangle,Freeline etc.the method which i am using is as follows 1.i record all the points in which line or circle is drawn 2. all the points are recorded in a Vector 3.every time i finished ...

18. Canvas drawing    coderanch.com

This is wrt a chat project. I have created a canvas object which displays images (icons) with text as input by the user. This is added to a scrollpane. The problem is when the scrollbar is moved only the last line of the conversation is painted and the portion above the last line is lost. Kindly reply asap.

19. drawing on the canvas    coderanch.com

could u please help me with some kind of sample code or some tips to have a way out to channelize my thought process for drawing,dragging,resizing and deleting multilpe rectangles on the canvas....like drawing them in MSWord its not that i have not worked on it but i am somewaht stuck after i create multiple rubberbanding rectangles on the click of ...

20. some other class drawing on a canvas    coderanch.com

Hi, is there a way to draw on a canvas from another class? i got the graphics with c.getGraphics() where c is a Canvas. But now i can't seem to get the old graphics to display! seems like there is something i am missing. It is also hard to get the object that draws on the canvas to draw on it ...

21. Native rendering on AWT Canvas    coderanch.com

22. About Canvas and Swing    coderanch.com

Hi Guys! im using Swing interface. i know that i shouldnt use AWT and Swing components together although its possible. i extending the Canvas class and i draw an Image inside ,in mt interface i add the Canvas to a Jpanel. my question are ; sould i be worry about using the Canvas and thw Swing component in the same interface? ...

23. adding swing component on canvas    coderanch.com

24. invisible canvas    coderanch.com

I have read somewhere that you can't have invisible canvas's. What I am trying to do is create a login screen for an applet I am working on. I am rendering a cool background for my login screen in the paint method. Now I want to add buttons and such over it. To organize everything I am using a gridlayout. I ...

25. Scrollable Canvas    coderanch.com

Howdy all, I'm really stuck on a problem and pretty sure I'm missing some obvious detail. I am trying to implement a sort of scrollable canvas. Why? I have an image that I want to display in an applet, but the image is much larger than the applet itself. I've tried to implement this sort of scrollable canvas by adding drawImage(...) ...

26. Urgent Question about paint in Canvas    coderanch.com

Hi,I am using Java to do Bresenham line drawing homework.Users can drag lines on an canvas and a series of circles will show as a result of the algorithm. However,when I resize the canvas or make it reexposed, the previous generated lines will disappear. I know it is due to the calling of paint method in canvas.But anyone can tell me ...

27. double buffering on a canvas    coderanch.com

hi i'm having trouble when trying to double buffer on a canvas for in a panel for a simple asteroid game i'm making. Heres the start of the code for the canvas: public class GameArea extends Applet implements Runnable, MouseListener, MouseMotionListener { private Thread running = null; Graphics buffer; Image offScreen; //Used for double buffering int width, height; Meteor mets[]; public ...

28. what is the swing of canvas ?    coderanch.com

29. paint with canvas    coderanch.com

30. Canvas precision    coderanch.com

You can use double precision numbers to keep track of values and then cast them to appropriate integer coordinates to use to draw them on the canvas. Multiply them by a scale value and then use Math.round(), Math.rint(), or a simple cast to get an integer value. A lot of the Java2D Shape classes actually do use real numbers (both doubles ...

31. How can I have Floating Obj over Canvas?    coderanch.com

I want to have the following visual result: a big background Canvas, and some Opaque Obj(img, frame, etc) floating on top of the Canvas. How can I do this? At the same time I want to have the Drag and drop capability on both the Canvas and the floating object? Is this possible? Any solutions or suggestions will be very welcome. ...

34. a curious problem about canvas    coderanch.com

import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.util.*; import javax.swing.*; public class TestRx { public static void main(String[] args) { JFrame frame = new MainFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); } } class MainFrame extends JFrame { public MainFrame() { setSize(300,300); setTitle("BounceThread"); Container contentPane = getContentPane(); JPanel jPanel2 = new JPanel(); contentPane.add(jPanel2); jPanel2.setPreferredSize(getSize()); jPanel2.setLayout(new BorderLayout()); JPanel nodeCanvas = new JPanel(); JPanel topoCanvas = new ...

35. Canvas resizing    coderanch.com

36. updating a canvas    coderanch.com

37. Flickering in Canvas (Yes, I've read all older posts... but the problem stands)    coderanch.com

I'm creating a canvas where the user can create a diagram, so he draw some circles, links between them, etc. The problem is that when the canvas is updated (e.g. the user moves a line) a great flickering happens. So, the closer I came up was with that code, but if a component is moved, it leaves its "trail". The latter ...

38. Canvas HELP!!!    coderanch.com

Hi, I'm trying to draw things into a frame, that already has something drawn onto it. The code I have below draws squares on top of a jpg picture, in a sequence. The squares are drawn using the Box class, which ive extended from the Canvas class. This works, but there are a trail of squares being left on the frame. ...

39. repaint () not getting called inside Canvas    coderanch.com

I have created a frame and I have created a class inside frame which extends Canvas and I have paint() method inside this class. When I call repaint() method from this canvas class the paint() method is not being called. The paint() gets called only when the frame gets resized. Please help me how to use repaint() inside canvas class. Please ...

40. Canvas not displaying    coderanch.com

Hello, I have a small problem with a program im working on. I have a class that extends JFrame and in that class I have an inner class of type Canvas whose paint method I have overridden. Here is the problem.. When I start my program the canvas does not display the image I have drawn on it. If I resize ...

41. Canvas object not appearing    coderanch.com

Hi, I have an applet, inside which there is a tabbed pane. In the first pane there is a panel, the panel uses GridLayout (1 column, 2 rows). In the top half of this panel is some text areas and a button. In the bottom half I have added a canvas, however the canvas does not appear. Everything else in the ...

42. Adding JComponents to Canvas    coderanch.com

Hello, I am trying to write a small app in Swing/AWT that requires the use of an interactive canvas. It is for building trees with complex relationships. Mostly what I am looking for is the best method for approaching this. I would like to be able to use JComponents to represent tree nodes to leverage action listeners, but components can only ...

43. Canvas Vs Swing    coderanch.com

44. Building Canvas for drawing    coderanch.com

45. Canvas    coderanch.com

46. Double buffering with Canvas    coderanch.com

Hi, I thought I had implemented double buffering with a Canvas, but I noticed that the graphics didn't look smooth at all. I then rewrote it with the overriding JPanel paint method I knew would work and graphics looks a lot better. However, I can't really use this simplified implementation for what I want so would like to understand why the ...

47. difficulty Using Canvas    coderanch.com

48. Drawing order in Canvas [SWT]    coderanch.com

49. Converting canvas to bytes    coderanch.com

50. I need to draw an bezier curve on canvas using swt with the handles    coderanch.com

Hi All, First of all I need to draw a line on canvas its just like bezier curve. After that It should have handles so that I can drag the line into an arc. I saw few exmaples like curve fit on java forums, it is using swing to develop it. But I want in SWT . If anybody can please ...

51. A very large canvas    coderanch.com

52. is Canvas an obsolete class?    coderanch.com

53. Zooming Canvas Area    java-forums.org

HI am new to Java Swings. I opened a new internal frame with a canvas in it for drawing. I want to zoom the canvas. I mean i need to zoom the canvas even before i draw anything. Similar to photoshop. we create a new file with so and so pixel and we can zoom the new opened file upto around ...

54. Drawing an object in my canvas class, the object is created in a separate class    java-forums.org

Hello everyone, I'm quite a noob at Java and this is my first post but I don't know where else to ask and I can't find problem specific solutions to this, I'm sure the answer is something really simple but like I said i'm rather new at Java. basically Im making a program which prints figures onscreen after I press a ...

55. Canvas and mouseMoved()    java-forums.org

I'm trying to get mouse input for a button class so that I can tell if the mouse is over the button or not. The problem is that I'm not getting any input from mouseMoved(). I'm extending a MouseAdapter and adding it to my Canvas using addMouseListener(). As far as I can tell mouseMoved() isn't even getting called does anyone know ...

56. Canvas context dissapears    java-forums.org

Part of my canvas context or all context disappears disappears when JFrame is minimised, or dragged out of screen margins or another window is over it. At the moment I have a GUI class that extends JFrame (NetBeans JFrame design) and that creates the whole GUI along with a canvas. All the objects in the GUI class are JButtons, JTextFields and ...

57. Print whole canvas drawings    java-forums.org

I have a problem with print everything of a canvas class. I explain you in details.......... I have two classes, suppose A and B. A class extends JApplet and implements all the listeners. B class extends Canvas class for drawing different geometrical shapes. I have created an object of B class within A, and within actionPerformed() method of class A, I ...

60. Canvas on Swing?    forums.oracle.com

I need to an applet for a school project which will be used as a tool for explaining the concept of Trees. The user should be able to add/edit/delete nodes and also drag and drop these nodes within the canvas. Something like JFLAP, if you're familiar with it. But I read that I shouldn't use the canvas with swing components because ...