2D « Graphics « Java Swing Q&A





1. Where is groovy.swing.factory.BindProxyFactory?    stackoverflow.com

When trying to use GraphicsBuilder, I get a java.lang.NoClassDefFoundError for groovy.swing.factory.BindProxyFactory. This is my environment:

% java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)
% groovy ...

2. How to design interface for a game in Java    stackoverflow.com

We're a team of a designer and a programmer. Me, the programmer, is hopeless on design of all sorts, so the user interface of the game must be created by the ...

3. Resize problems    stackoverflow.com

Hi gentlemens (and ladys) I am currently creating an Eclipse View that has to contribute an Eclipse RCP app' and which must be nice (and only this one, I don't need an ...

4. Using Swing, I want to draw a couple of points    stackoverflow.com

... in an image and do some calculation on their [x y] coordinates. My first idea was to use an image as the background of a JPanel and then register ...

5. Java 2D. Hovering over Circle    stackoverflow.com

If I draw some circles using Java2D. Is there a way display some text when I hover over any of the circles? i.e. I want to display the ID of ...

6. Technique Needed To Create Such Java2D Look n Feel    stackoverflow.com

I saw the following nice looking tool tips, created using JavaScript JQuery Toolkit. I was planning to implement a similar look in my Java standalone application. I was wondering what is the techniques ...

7. Java swing small 2D game: how to modelize the view?    stackoverflow.com

In a small java swing 2D game, what is the best solution for creating the board view?

  1. Use a component for the board and custom paint it and each square of the ...

8. Swing / Java2D statistics and visualisation libraries    stackoverflow.com

I'm looking for a multifaceted Java2D / Swing visualisation library with which I can render different statistics. Specifically, I'm looking for timeline plotting (with a configurable scrolling and compressing timeline and ...

9. setOpaque(true/false); Java    stackoverflow.com

In Java2D when you use setOpaque I am a little confused on what the true and false does. For example I know that in Swing Opaque means that when painting Swing wont ...





10. Need help understanding the affect of two java gui-related system properties    stackoverflow.com

I had a problem envolving a mixing of lightweight and heavyweight components in java. Weird swing heavyweight & lightweight mixing problem A solution that was suggested to me (outside stackoverflow) was to ...

11. Collision Detection - Java - Rectangle    stackoverflow.com

I would like to know if this is a good idea that conforms to best practices that does not lead to obscenely confusing code or major performance hit(s):

  1. Make my own Collision ...

12. Get object location Java2D (not corner)    stackoverflow.com

How do I get JLabel location instead of top left x/y location of the object in Java?

13. Java2D Distance Collision Detection    stackoverflow.com

My current setup is only useful once collision has been made; obviously there has to be something better than this?

public boolean CollisionCheck(Rectangle rect1, Rectangle rect2) {
   if(rect1.intersects(rect2)) {
  ...

14. how to draw simple eyes in java    stackoverflow.com

How can I draw simplest eyes in Java's swing ? I would like to get something like that : http://img710.imageshack.us/img710/70/eyesp.jpg

15. How to represent double values as circles in a 2d matrix in java    stackoverflow.com

so I want to write a matrix explorer which enables me to reorder rows and columns of a matrix. For this porpouse I used the Jtable class. Now the problem that I ...

16. Swing based 2D graphics library for Text    stackoverflow.com

Is there a library that would give me 2D graphics with a focus on Text for Swing. I am building a simple form designer and need to position text correctly ...





17. Java2D: Increase the line width    stackoverflow.com

I want to increase the Line2D width. I could not find any method to do that. Do I need to actually make a small rectangle for this purpose? Thank you.

18. Java2d: Set gradient for a lines    stackoverflow.com

I am having multiple points in a plane and some hundreds of lines pass through those points. Some points can have more lines passing through them than other points. I want ...

19. Override paintComponent in Netbeans GUI    stackoverflow.com

I've added a JPanel to my Netbeans generated GUI, and add a JPanel BoxThing that overrides paintComponent and draws a small red box, but it doesn't display, paintComponent never even gets ...

20. Operations on Java Swing    stackoverflow.com

In my project,I will get the coordinates of some points from an XML file,and create some visual components using this information ? I am planning to give these components to a ...

21. non-destructive transformations on java2d objects    stackoverflow.com

I would like to be able to zoom and unzoom on a Java2D scene made of Path2D.Double without thickening the lines, just by dilating the distances. I'v tried to apply a transformation ...

22. java 2D drawing    stackoverflow.com

im trying to make a swing app that draws a function's graph(simple for now ex. x+2) but i'm having problems to make mathematical coordinates of my points depending on screen coordinates ...

23. java 2D and swing    stackoverflow.com

I have trouble understanding a fundamental concept in Java 2D.
To give a specific example:
One can customize a swing component via implementing it's own version of the method paintComponent(Graphics g)
Graphics is available ...

24. Suitable widget for drawing a 2D cartesian coordinate system in java    stackoverflow.com

I want to build up a GUI area where users can click randomly. Then I want to retrieve the cartesian (x,y) coordinates of those points where the user clicked. Which GUI ...

25. Java 2d Games with Java SWING    stackoverflow.com

Me and my friend started developing a game just like Zelda for SNES using Java. The only problem is that we don't know what to use: our very own engine with ...

26. Java 2D graphics line drawing in Windows 7    stackoverflow.com

Am using jdk1.6 updates 24. Am facing the issue regarding line drawing in windows 7. In my project I've three components in panel. For example three panels,line starts from middle of ...

27. My text bounding rectangle    stackoverflow.com

From the following code, we can get the bounding rectangle of our text:

Graphics2D twoD = (Graphics2D) g;
FontRenderContext frc = twoD.getFontRenderContext();
Rectangle2D textBound = myFont.getStringBounds(myText, frc);
but in core java textbook, it says that ...

28. Java code, need a quick review (swing, graphics 2D)    stackoverflow.com

public class my_gui extends JFrame {
    public my_gui() {
        setTitle("Broscute 1.0 :p");
        setSize(954, 320);
 ...

29. oval leaves the trail    stackoverflow.com

I am trying to make a simple ball animation, that starts from 1 corner and goes to another corner of the panel. I have written a program for that. ...

30. Text alignment in java printing    stackoverflow.com

I am using 2d graphics to print the string on to the paper. I want the string to be aligned on the paper like right, left, centre. How can I do ...

31. ending the ball's path    stackoverflow.com

I have a small panel where i am making a ball to move by just varying it's x co-ordinate. I want the ball move back when it encounters the end of frame.The ...

32. checking the size of graphic drawing    stackoverflow.com

 public void paintComponent(final Graphics g) {
 super.paintComponent(g);
 g.setColor(Color.red);
 g.drawOval(x,y,width,height);
 g.fillOval(x,y,width,height);
}
This method draws the oval with x=2, y=2,width=10,height=10. How can i get the size of the drawing painted ?

33. Unable to get the conditions right    stackoverflow.com

I am trying to make a program of a bouncing ball. I have tried some conditions in it.But i have not got what i wanted.The ball keeps on moving back and ...

34. ball goes off the screen    stackoverflow.com

i have been trying to make a bouncing ball animation.I have got everything right except for one thing. The ball goes off the screen once it hits the lower deck of the ...

35. How do I create and distribute diagonal stripes on a rectangle?    stackoverflow.com

I would like to be able to create bar charts with JFreeChart that looks similar to the following picture. the desired result It is a very basic mono-colored bar chart, but ...

36. How to have a "Camera" only show a portion of a loaded area    stackoverflow.com

I'm having a little problem with figuring something out (Obviously). I'm creating a 2D Top-down mmorpg, and in this game I wish the player to move around a tiled map similar ...

37. Can't get Java2D to render a simple line to a Graphics object    stackoverflow.com

Because I want to invoke different classes's drawing method and draw different graphs on the JPanel so I need to take the drawing plate(JPanel or something) as an argument, passing it ...

38. Java D3D on MacOs cast failed    stackoverflow.com

What can cause Swing to rise this Exception? There is no really clear grund. I just draw Text in Graphics.paint(). It happens on Windows Emulatro for mac os. On linux or windows ...

39. How to measure Java2D drawing performance in a JComponent?    stackoverflow.com

I'm trying something along these lines:

private static class TexturePanel extends JPanel {

    @Override
    protected void paintComponent(Graphics graphics) {

        ...

40. Comparing an Arc2D with a Component    stackoverflow.com

I have a quick question for you guys, well, quick for you, not quick for me. I have an array that is filled with Arc2D shapes and I have a MouseAdapter Within the ...

41. java.awt.Graphics change color after drawing    stackoverflow.com

I have asked a similar question a while ago here, but didn't get an answer. The original question was about changing the color of a shape after clicking on it. But ...

42. Paint over all other components (Swing, Java)    stackoverflow.com

In my application I need to draw grid lines just like those like Photoshop has - e.g, an user can drag lines over the document to help him align layers. Now, ...

43. Java 2D    coderanch.com

44. 2D API Graphics    coderanch.com

Tom, The Java 2D API is part of the JFC( Java Foundation Classes )... it was created to add more graphics manipulation than the old AWT Graphics class could provide. Swing is the GUI aspect of JFC, built to replace/upgrade the AWT... so Graphics 2D is kinda related to this topic... Swing may be displayed using the Graphics2D class instead of ...

45. 2d arrays    coderanch.com

I have a vector which i convert to an array of objects as follows: Vector vctNumbers = (Vector)vctGraphItems.elementAt(1); Object objArr[] = vctNumbers.toArray(); //array of objects I now need to convert this 1-d Object array, to a 2-d float array: float[][] array = ... If anyone has done this before or can explain this to me i would be very greatful. thanks, ...

46. Swing making 2D look 3D    coderanch.com

47. Delete 2D Line    coderanch.com

48. 2D Line & setCursor    coderanch.com

Here's some code illustrating the concept I was talking about... only one component ( the main JPanel class ) is used... but it keeps track of the Shapes that it draws, and it knows what cursor to set for what shape ( it just uses corresponding array indices... you could use a HashMap to attach specific cursors to specific shapes, or ...

51. Graphics - Swing or 2D What's best    coderanch.com

I'm developing a graphics editor and I'm not sure if I should be using 2D or swing (extending JComponent). From what I can see 2D has a richer API. Being new to Java I'm also a bit confused about 2d (heavyweight) and Swing (lightweight) component. Am I right to assume that I should not put 2D objects into a JPanel (light) ...

52. java swings with 2D graphics    coderanch.com

I'm a little vague about your question. import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; public class Selection { public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new SelectionPanel()); f.setSize(400,300); f.setLocation(200,200); f.setVisible(true); } } class SelectionPanel extends JPanel { Rectangle2D.Double[] rects; Color color, selectionColor; int selectedIndex = -1; boolean selected; Point originP; public SelectionPanel() { color = ...

53. font getting fuzzy on Graphics 2D    coderanch.com

I'm using drawString on a Graphics 2D image object and writing at font sizes anywhere from 8 or 10 to 40. After printing out the image, I've noticed that a lot of the Arial letters are showing up more jagged than they do in Word, and I'm using what seems to be a pretty decent laser jet printer. As you might ...

54. Will Java2D API solve my problem?    coderanch.com

Hi all, Have been out of touch with SWING for quiet some time and now I need to do somethine like this in my project. I have to show certain text and allow the user to select it and give some right click options to him on selecting the text.Based on what right click option he chooses,we need to color the ...

55. java 2d    coderanch.com

hi i am developing an application in swings. it has graphs the graph line moves slowly to the value given in by user(instead pop up the graph, the line in the graph starts from 0 and move up to the mark). how can i do it? if i do it in java2d how can i plug that into swings

56. java 2d graphics    coderanch.com

Hi, Im having some right hassel with java 2d graphics. One class (javaPiano.java) I have a Jpanel that draws a virtual keyboard, and play notes when you press the keys. I have a sperate class that is another jpanel which has music lines (drawStaff.java). in the drawStaff class I have a method public void drawNote (String noteName, Graphics2d g1) { //code ...

57. java 2d performance issue    coderanch.com

It's hard to say without knowing how your application works. Swing uses the graphics2d API extensivly and there are not any issues with that. So I can't imagine it being a graphics2d API issue. More likely it is how you have implemented it. But like I said, you have not really provided enough information to determine that. I realise you probably ...

58. java 2d performance - please read!    coderanch.com

59. java 2d graphics    coderanch.com

60. modifying 2d figures    coderanch.com

Hi, I need to draw different kind of 2d figures on a JPanel, and once drawed I would like to be able to select one of them and modify its size, at this moment I'm just using the paintComponent() method, and every time I make a change I practically have to draw Again all figures, but I was thinking it maybe ...

61. Java2D    coderanch.com

62. Java2D in SWT/JFace    coderanch.com

It's possible to use Swing components within your SWT application, although last time I checked this worked only on Windows, and was supported only in an internal package. But they were working on making it an exported API and also giving it cross-platform support. Search for the Eclipse API class named "SWT_AWT" to check its current status.

63. Casting /2D Graphics    coderanch.com

64. Translation of 2d objects    coderanch.com

65. Graphics 2d Issue    coderanch.com

Please i need help. Is it possible to control the paint method of the graphics 2d object so that it does not automatically update drawings? i am trying to create an application that only draws/updates graphics when specifically requested. The program i have at the moment just executes any commands but i want to slow it down and control it. Please ...

66. Java2D Dinosaur? paint vs. repaint    coderanch.com

Hi, I'm trying to develop a graphical front end to an application, and I think that Java2D seems ideal for me, because i just want to use vector (not bitmapped) graphics + fonts and be able to print out what I see in the window. I made a copy of the Java2D manual, but it bothers me that the date on ...

67. Jfree site,bar chart using 2D    coderanch.com

68. Creating ripple effects using Java2D    coderanch.com

69. Graphics 2D    coderanch.com

i hope i can say this properly... i am trying to make a shape move on screen with the Graphics2D api. previously i was using a Rectangle and going through the process of translating the rectangle and repainting the screen. but then i generalized my class to accept a Shape. i thought using Graphics2D.translate would have the same affect but my ...

70. 2D Array Help    coderanch.com

How do I select a column in the array? I can select the row just fine but for my ComboBox I need to select the column as the values for the combobox. Thanks in advance. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class PlainWrap extends JFrame implements ActionListener, ItemListener{ String[][] partNumberString = { {"PR214","MR43T", "RBL8","14K22"}, {"PR223","R43","RJ6 ","14K24"}, {"PR224","R43N ","RN4 ","14K30"}, {"PR246","R46N","RN8 ...

71. Embeded a 2D Gui in web page    coderanch.com

72. How to read into Java2D    coderanch.com

hi guys~ I tried to figure out how the underlying Java2D works exactly but it turned out a mess. i just couldn't draw an outline of the source code(sun.java2d.*) with very little comments~ so, any advice for me (or syntax errors in my poor english - -), please? Thanks a lot . by the way, have read (o'reilly) , sun.com&jdk_api ...

73. Java 2D bezier curves    coderanch.com

Hi, I've been told to write the code that allows you to interactively control a bezier curve by dragging the control points in applet. Now, I can write the code for this to draw a normal cubic curve with the usual two control points, but what I've been told to do is to allow my bezier curve to be longer by ...

74. Java2D and MVC    coderanch.com

I have this asignment to create a Java SWING application, which uses the Java2D functionality. The user should be able to draw points on the panel and by pushing the Create Polygon button to unite the points into a polygon. I'm not able to create the Points and I am also confused by the MVC Pattern, wich we are obliged to ...

75. Java2D : TextLayout drawing right to left    coderanch.com

Hey, This is a first posting for me but I found lot's of sollutions to common java problems allready in this forum so I have good hope I might get the help I need for this probably obvious problem. However at the moment I'm out of ideas and google search strings. I've been trying to draw a string on a buffered ...

76. 2D drawing question    coderanch.com

77. Moving multiple ojects in Java2D    coderanch.com

I have an applet that I am trying to write that should probably be tackled in multiple parts. Currently I have an applet that creates one rectangle and lets the user click on it (and only on it) and move it around the viewing window. Well, I would like to add more rectangles and make them movable as well. I guess ...

78. How to draw a circle using 2d arrays    coderanch.com

Hello , I am trying to draw some objects using 2d arrays and animate them with AffineTransform class, I drawed the rectangle using 4 points and I had no problem but I dont know how to draw a circle using the same method, is it possible? because if I use points the circle wont be a curve. any ideas please. here ...

79. Need help on graphics 2d plot to add functions    coderanch.com

Hello, i need to make this code draw not only numbers but whatever function inserted. EDIT. Like i cant explain more precisely but maybe it should be created another button and in that button i have to input function like f(x)=x^2 and then program draws graph. ///// GraphingData.java import java.awt.*; import java.awt.font.*; import java.awt.geom.*; import javax.swing.*; public class GraphingData extends JPanel ...

80. perspective transformation in java2d    coderanch.com

yes, i did search the perspective transformation in java, that suggests the use of java imaging api, i have used it but its quite too slow and much complex too... i somewhere heard that , perspective transformation can also be achieved by affine transformations, which is part of java2d, but i don't know how?

81. help: I want to design 2D map?    java-forums.org

82. 2D Graph Repaint Issue    java-forums.org

Hello all...newb question. Please bare with me. I am trying to build a simple graph that will plot array values. I would like for this graph to update so that I have a "live" graph. I have built something (starting with a very generic 2d graphics example) that will plot one array, wait for 2 seconds, then plot the other array. ...

83. Some help needed: 2D Cellular Automata    java-forums.org

84. GUI for Java 2D    java-forums.org

Hello- I'd like to announce that I'm working on a GUI for Java 2D. It's basically a JPanel in which you can interactively create any of the Java 2D shapes (and text as well). You can also create paint gradients. It works as an applet. The applet does not support saving your work, but the jar file is available on request, ...

85. Update GUI after setToolTipText    java-forums.org

HI guys, i have a strange problem. I have an object that extends JLabel and this object is rotated by x degrees in its paintComponent method (using graphics2D method to rotate).. This object have a setToolTipText calling in paintComponentMethod paintComponent(Graphics g) { //code setToolTipText("HELLO!"); } this is the problem: inside the JLabel there is an image. When the text (HELLO) disappear, ...

86. New to Java GUI. Can't get this to work.    java-forums.org

I'm only trying to create Pong. I need a JFrame that has a black background. What am I doing wrong? Here's my code so far... import javax.swing.JFrame; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; public class Pong extends JFrame{ public Pong(){ int width = 800; int height = 600; setSize(width,height); setTitle("Wacky Pong 380"); setBackground(Color.BLACK); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE ); setVisible(true); } public void draw(Graphics g){ ...

87. Drawing coordinates in Java GUI    java-forums.org

88. GUI for ploting curves    java-forums.org

89. How to work Nimbus Look & feel in java    java-forums.org

90. Question on getGraphics() in a JComponent    java-forums.org

I have a situation where I need to update graphics in a JComponent, but I think repaint() is too slow. This is for two reasons: 1. Within paintComponent() there are many items that get drawn, each involving calculation prior to drawing them. So even if I try to repaint() with a clipping rectangle, I still have to do all the calculations ...

91. Silent Printing in java swing application    java-forums.org

92. Collision in GUI 2d Game help    java-forums.org

I have a problem with this code and we can't find where the error is. The method getBounds() or checkCollisions seem to have a problem. Can someone help us? checkCollision is supposed to the check whether the two objects are colliding and getBounds() is supposed to return the size of the rectangle image. Java Code: package mpGame1; import java.awt.*; import java.awt.event.*; ...

93. haw can i learn swing or 2d?    forums.oracle.com

i'm from argentina. i studied the basics of java in thinking in java, but honestly, i don't understand anything of swing.i tried reading the html documentation of the API's but i'm new in this and i don't know how to use them nor understand them. this is the first programming language i'm studying(or at least trying) to learn deeply. i want ...

94. Guidance for creating a simple 2D GUI for game.    forums.oracle.com

Me and a couple of friends are developing a Risk-like game (the board game) with java. We have all the logistics done and we are only missing the GUI. We are comfortable with building normal GUIs based on buttons, menu, input fields, labels, etc. But for this we want to develop something similar to the actual board game. So it would ...