Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not quite exactly sure what you are asking. Normally, you put all of the drawing functionality in the paint() method. However, you generally want to keep any long running work off of the AWT dispatch thread which is the same thread that your buttons' actionPerformed() method is invoked on. To keep your program responsive, you may want to delegate it to a SwingWorker.</p> <p>If your app is not being shown, it is likely because you have not called pack() and show() (in that order) during your JPanel's initialization. Generally, you should do this as the last thing in your init() method. Adding components afterward or changing your components state anywhere but in the AWT thread after this may cause AWT to get mad at you and throw an exception.</p> <p>If you are asking how to draw the points themselves, you should look into Graphics.drawPolyline() and the related methods, which you should call from within your paint() method.</p> <p>If you're asking how to draw them from within the button handler, you don't. You call repaint() and let the object repaint itself on its own time. Also, in your case, I wouldn't bother subclasing JButton. Just implement actionListener. In you init() method, just create two buttons and register your listeners with them. This also means that you don't have to override their constructors.</p> <p>Also, you mask submit during your init() method: it is never referenced and neither is bpanel. Also, I would use a separate X and Y array rather than trying to combine them into a single matrix. You don't need to declare matrix to be public since the inner classes can already see it anyway. In fact, you can (and probably should) declare all of the fields to be private. You also have way too many magic numbers floating around and you are fighting Swing way too much: just let it do it's job laying all your stuff out. You should also try show the smallest possible problem that will allow us to answer your problem: this one sort of flows all over the place and is hard to follow.</p> <p>Oh, and the real reason why your lines are not being drawn: you call repaint on your JPanel and not the JFrame that you want to draw on. If you just call repaint() instead of points.repaint() the JFrame will take care of drawing itself and all of its children.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload