Class « Graphics « Java Swing Q&A





1. Java Graphics Multiple Classes    stackoverflow.com

i have a slight problem. I am trying to write a program that draws a box of crayons. I want to have a method i can call from a main applet ...

2. Using Graphics from anonymous class    stackoverflow.com

This is a part of my code which does some sort of animation; however, there seems to be something wrong: Whenever I try to use the passed 'g' from inside the ...

3. java swing paint on another class    stackoverflow.com

I have a main interface class which has a few containers and panels and UI buttons ect. Then I have a class which draws to a component. I set the component ...

4. calling paint from another class    coderanch.com

Hi Vinod, If you have common parents the problem is quite easy. You can just get the parent and then use the sibling object array to get a handle on the other panel. The code below shows an example. import java.awt.*; import java.awt.event.*; import javax.swing.*; class MyPanel1 extends JPanel { public void paintComponent( Graphics g ) { super.paintComponent( g ); System.out.println( ...

5. Painting from one class to another    coderanch.com

Hello all, I have two classes in the same package. Class MyDialog shall create a dialog in my application and request a drawn String for one of its Panels. The String shall be drawn by my second class, called PaintString. I am unable to connect the two classes. Maybe it is easy, but as I am a newbie, I don't get ...

6. Class with Graphics instance    coderanch.com

I think we need to see more of your code to understand exactly what's going on... Why not use separate JPanels for each of the network status "boxes"? It is way more easier to handle all the sizing issues, and if changes are needed - it's a lot easier to just add a component to a panel than figure out how ...

7. big confusion related to Graphics class    coderanch.com

Hi, I am learning java from an online reference..and I am stuck on GUI chapter... there is a code to write applet or stand alone program,doesn't matter... public class HelloWorldGUI2 { import java.awt.*; import java.awt.event.*; import javax.swing.*; public class HelloWorldGUI2 { private static class HelloWorldDisplay extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawString( "Hello World!", 20, 30 ); } ...

8. Using Graphics from anonymous class    coderanch.com

This is a part of my code which does some sort of animation; however, there seems to be something wrong: Whenever I try to use the passed 'g' from inside the anonymous class to draw anything, it does nothing, yet when I used it outside the anonymous class (inside the rollBalls method) it does what it's supposed to do. Any idea ...

9. Problem in g.drawArc() api of Graphics class    java-forums.org

I have a problem in drawing arc for a non-square extents. I have to draw an arc for the following inputs width = 180, height = 20, startangle = 120 degree, endangle = 180 degree The arc is not coming as expected way. Java API doc itself, it has been mentioned that upper right corner will be always treated for 45 ...





10. ending a graphics class    java-forums.org

Im making a program which has a level editor. I finally completed the editor itself with some help of members of this forum (thanks again). Yet I found another problem. My level editor should return an ArrayList to the calling methode when done, however the methode I called in editor just made a window, some listeners and some graphics and then ...