当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Drawing window in JFrame

问题描述:

I would like to have a separate graphics window (along with a separate cartesian coordinate plane) inside a larger window using java.awt/javax.swing, I've drawn a picture to show you what I mean.

I have no idea how to do this, throwing some kind of literature at me that I can read to understand this better would be really great, a solution for my problem along with that would be awesome.

PS. I haven't really tried anything, as I have no idea what to try.

网友答案:

I recommend downloading NetBeans to start with, as it is the easiest IDE for UI design I know of.

  1. Start with creating the main frame of your application.
  2. Add all the buttons you need and position them as in your picture on the main frame.
  3. Add a JPanel to your frame and call it something like drawingCanvasPanel. This panel will be the drawing area. Don't forget to override the Panel's painComponent method in which you will draw your custom drawings and shapes using the panel's Graphics.
网友答案:

I'd override paintComponent() in a JPanel on the left, as discussed here. A JPanel of JButton in a BoxLayout could go on the right, as shown here. See also the related example, LinePanel.

网友答案:

You can use Internal Frames, for how to use it, see the official tutorial

分享给朋友:
您可能感兴趣的文章:
随机阅读: