Line « Graphics « Java Swing Q&A





1. How to draw visual graphs with circular nodes and lines as connections between them?    stackoverflow.com

I want to draw a map some cities in a software that I am designing. I want to know the algorithm for placement of circular nodes on screen (so they dont ...

2. Drawing multiple lines with Java Swing    stackoverflow.com

I'm learning drawing lines with Java Swing in order to draw a labyrinth. I can draw one line at a specified position and it shows just fine. But when I want ...

3. How to delete Drawn Line in java?    stackoverflow.com

well this is my code:

import javax.swing.*;
import javax.*;
import java.awt.*;
import java.awt.Color;
import java.awt.Graphics.*;
import java.awt.event.*;
import javax.swing.UIManager;
public class SimpleGUI extends JFrame{
               public ...

4. Java - Draw a ruler (line with tick marks at 90 degree angle)    stackoverflow.com

I'm using Java AWT to draw lines on a panel (Line2D and Graphics2D.drawLine()) and I'm wondering how I can draw a line with tick marks, similar to: |----|----|----|----|----| I know the positions I'd ...

5. how to draw horizontal line in java swing?    stackoverflow.com

how to draw horizontal line in java swing?

6. Drawing a line connecting two rectangles    stackoverflow.com

I am making my own class diagram app in Swing/AWT but i stopped at this functionality:

  • I want to draw a line between the Class rectangle that already selected and to the ...

7. How can I draw lines, rectangles, and circles in my Java paint program?    stackoverflow.com

I'm working on a paint program for one of my classes and I'm stuck. This is a part of my code (separated into 3 Java classes). When I click on the ...

8. drawn lines connect together instead of being on its own    stackoverflow.com

i am implementing a class with extends a JPanel, and this class is added to a JTabPane, and you can draw things on the area like a Paint program, however when ...

9. How to draw a line without using AWT or Swing?    stackoverflow.com

I have to write a Java class which can draw a line, but java.awt.* and javax.swing.* will not be available. How can I do it? Can I draw the text in ...





10. Java swing editable line drawing    stackoverflow.com

I am writing a zigzag drawer as my school assignment. Basically what is expected is to be able to draw zigzags on a canvas, to be able to move vertices of ...

11. Draw a Line    coderanch.com

12. Can lines be warping inside paint()?    coderanch.com

I had this problem too. The only solution I found is that you have to use multiple drawString ("String", x, y) calls and calculate the x's and y's so that it appears that it simply wraps around to the next line. There may be a simpler solution, but I didn't find it.

13. How to draw an etched line?    coderanch.com

If you need to be able to move the line around to resize the components on either side, you should use the JSplitPane class that comes with Swing. If you just need a line, you can use a JSeparator kinda like this : import java.awt.*; import javax.swing.*; public class HalfPanel extends JPanel { protected JPanel p1, p2; protected JComponent top, bottom; ...

14. draw line object    coderanch.com

i did a program using java2D where i had to connect various entities using line. now my boss wants me NOT to use 2D. i got to use "Visual Paradigm for UML Community Edition". using this sw i am able to create object lines which can be resized - events can be associated with them... what technology r they using? any ...

15. how to draw lines across components    coderanch.com

Hi, I have a jframe, that contains a Menubar and a jscrollpane. The Jscrollpane shows a jlayerdpane containing ca 100 components. Some of them should be connected with a "cable", that will be represented by a line. So I have to draw lines across the components. The extreme case is, that the upper left component of the jlayerdPane should be connected ...

16. Displaying lines with multiple colors    coderanch.com

try this... package testing; import java.awt.*; import javax.swing.*; import javax.swing.text.*; public class textPane extends JFrame { public textPane() { super("duper"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = myTextPane(); getContentPane().add(p); setSize(400, 200); } public JPanel myTextPane() { JPanel panel = new JPanel(); JTextPane tp = new JTextPane(); String data = "this is a line multi-colored of data"; tp.setText(data); SimpleAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setForeground( attrs, ...





17. Drawing Scaled Lines    coderanch.com

Hi. I have an application in which I need to draw approximately 10,000 lines on each repaint. This paints very quickly when the scale of the image is 1.0 or less, but when I increase the scale to greater than 1.0, the slowdown several seconds. Below is a very crude example (that draws the lines in the same place, but still ...

18. How to draw straight line instead of curved line??    coderanch.com

Dear friends: I have following code, which can draw curved lines when mouse moves, but if I only hope to draw stright line, not curved one, How to draw straight line instead of curved line?? If can help advice something, thanks in advance. Regards package com.draw; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; public class DrawLineOnPanel extends JPanel implements ActionListener ...

19. drawing line    coderanch.com

20. drawing lines    coderanch.com

21. Why won't my program draw the line    coderanch.com

Dear Ranchers, package translation; import java.awt.Color; import java.awt.geom.*; import java.awt.geom.Point2D.Double; public class TransmissionLine extends Shapes{ final String name = "TransmissionLine"; static Point2D p1; Line2D.Double tline; static Point2D p2; static double x1,x2,y1,y2; Path2D.Double transmissionline; public TransmissionLine() { } public void getFirstPressed(Point2D xp) { p1=xp; x1=xp.getX(); y1=xp.getY(); } public void getSecondPressed(Point2D xq) { p2=xq; x2=xq.getX(); y2=xq.getY(); } { tline = new Line2D.Double(x1,y1,x2,y2); transmissionline ...

24. Problem on Drawing line    coderanch.com

25. 'Moving' a circle along a line    coderanch.com

I am tinkering with a bit of Java and would like to 'move' a circle along a curved line to simulate a free-kick in football (soccer). I know how to draw a curve based on three sets of coordinates and I know how to draw a circle and I can make a circle 'move' by re-drawing it in a slightly different ...

26. New ground, making progress, but need some guidance with drawing lines.    coderanch.com

I am creating a "flowchart" type application, but instead of being just a documentation aid I want to actually execute the logic represented on screen. However my question is more graphics related than specific to the logic of the application. In the two images attached you will see a number of orange squares. These are customised JPanels. Each panel will know ...

27. Drawing a line between two points with a preview    coderanch.com

Hi! I have a problem that I don't know how to solve. Here's what I'd like to do: I have a JFrame with a grid of squares, and if I click on one of these squares, I want to take this one as starting point, and while I move the mouse to the other squares I want to see a line ...

29. draw smooth dash-ed line    coderanch.com

hi !! i am working on a project that displays graph, a graph can be drawn as simple plain line , dash-ed line , dotted line or dash -dotted line. i don't have any problem with drawing all these of lines , but the problem is lines are not so smooth and if i zoom my graph they become very rough. ...

30. Java GUI drawing a line    java-forums.org

Hello everyone. I have been trying to figure this out for a long time and can't seem to get it right. I am trying to create lines for my graph and I was going by using paint component. Java Code: public void paint(Graphics g){ drawLine(x1, y1, x2, y2); } But no matter what the line will not be drawn. Here is ...

31. GUI lines changing colors    forums.oracle.com

I am creating a GUI where ultimately I would like to have 3 lines painted in a panel first. Then when a play button is hit i would like the lines to start changing colors. However to start it I had decided to have the Thread draw the line (using getGraphics). Right now the line will sometimes draw but will not ...

32. Printing continous info to command line, gui equivalent    forums.oracle.com

Hi, I've got a program thats printing a continous loop of results to the command line just using System.out.println(result). i would like to display this list on a gui, and would like to be able to show just one line at a time, so if say the result is changing every three seconds, then just the most recent one is visible ...