0

I'm trying to figure out what would be the most optimal way of drawing lines in a JPanel. The panel is called at the beginning of the execution but the X and Y positions are be passed on after selecting an XML file and parsing said file.

So far I've using JPanel mypanel.add(new JLabel()) for images but I'm not sure how to add lines.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Dan A
  • 11
  • 1
  • Welcome to Stack Overflow! Please make your question a Minimal, Complete, and Verifiable example [M.C.V E](https://stackoverflow.com/help/mcve). Also check [how to ask question](https://stackoverflow.com/help/how-to-ask) to make your post answerable. – Morse Jun 10 '18 at 06:35
  • See [Custom Painting](https://docs.oracle.com/javase/tutorial/uiswing/painting/index.html) and [example](https://stackoverflow.com/a/46577656/3992939) – c0der Jun 10 '18 at 07:13
  • 1
    @Prateek good suggestion, and a tip: `[mcve]` auto expands to [mcve]. – Andrew Thompson Jun 10 '18 at 09:14
  • *"So far I've using `JPanel mypanel.add(new JLabel())` for images but I'm not sure how to add lines."* Lines can be drawn to an image. Here is [an example](https://stackoverflow.com/a/12683632/418556). – Andrew Thompson Jun 10 '18 at 14:52

0 Answers0