Note that there are some explanatory texts on larger screens.

plurals
  1. POActionListener doesn't work properly after drawing line in java
    primarykey
    data
    text
    <p>I have a problem with an action listener after I draw a line, basicly it works just one time, for example, my application is downloading an image, than u pick two points, first with left button mouse, second with right button, than u click "connect points" button, and it is drawing a line. And this works, I can do it with many lines etc. BUT when I close an window with image and reload it the "connect points" button stops working. Dk what to do with it. Here is the code:</p> <p>the painting line part:</p> <pre><code>public void paint(Graphics g) { super.paint(g); myPaint(g); } private void myPaint(Graphics g) { g.drawLine(lx1, ly1, px2, py2); } } </code></pre> <p>ActionListener part:</p> <pre><code>public void actionPerformed(ActionEvent e) { if(e.getSource()==painterka){ Graphics g = imadzysko.getGraphics(); paint(g); lx1=0; ly1=0; px2=0; py2=0; } } </code></pre> <p>Panel with graphic part:</p> <pre><code>void diagramKY (JFrame windower, String tyt, String content) { Listener listener = new Listener(); panelik.setLayout(null); painterka = new JButton("Connect Points"); windower = new JFrame(""); windower.setTitle(tyt+" - diagram"); windower.setSize(800, 600); windower.setVisible(true); windower.setLocationRelativeTo(null); URLdownloader.fileUrl("http://stooq.pl/c/?s="+content+"&amp;c=1d&amp;t=l&amp;a=lg", content+".png",""); imadzysko = new ImagePanel(new ImageIcon(content+".png").getImage()); panelik.add(imadzysko); panelik.add(painterka); imadzysko.addMouseListener(new MyMouseListener()); painterka.addActionListener(listener); Insets insets = panelik.getInsets(); Dimension size = imadzysko.getPreferredSize(); imadzysko.setBounds(20 + insets.left, 20 + insets.top, size.width, size.height); size = painterka.getPreferredSize(); painterka.setBounds(630 + insets.left, 20 + insets.top, size.width, size.height); panelik.repaint(); imadzysko.repaint(); windower.add(panelik); </code></pre> <p>well, any suggestions? :)</p>
    singulars
    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.
 

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