Note that there are some explanatory texts on larger screens.

plurals
  1. PODragging of shapes on Jpanel
    primarykey
    data
    text
    <p>I am using JButton's Action listener to draw different shapes.To keep previously drawn shapes on panel all time, I've used an arraylist in which all drawn shapes has added and repaint whole list.How can I drag any shape while others display on Jpanel all the time?</p> <pre><code>protected void paintComponent(Graphics g) { super.paintComponent(g); System.out.println("====&gt;&gt;&gt; " + s); switch (s) { case "Button1": Activity act = new Activity(); act.setArcH(15); act.setArcW(15); act.setBreadth(40); act.setLength(50); act.setXpoint(x); act.setYpoint(y); //========================================================== obj = new ShapePoints(); obj.setShapeId(ShapesID.ROUND_RECTANGLE_ID); obj.setxPoint(act.getXpoint()); obj.setyPoint(act.getYpoint()); obj.setLength(act.getLength()); obj.setBreadth(act.getBreadth()); obj.setArcW(act.getArcW()); obj.setArcH(act.getArcH()); shapePoints.add(obj); Iterator itr = shapePoints.iterator(); while (itr.hasNext()) { ShapePoints sp = (ShapePoints) itr.next(); switch (sp.getShapeId()) { case ShapesID.ARROW_ID: break; case ShapesID.CIRCLE_ID: g.drawOval(obj.getxPoint(), obj.getyPoint(), obj.getLength(), obj.getBreadth()); break; case ShapesID.CON_CIRCLE_ID: g.drawOval(sp.getxPoint(), sp.getyPoint(), sp.getLength(), sp.getLength()); g.fillOval(sp.getxPoint() + 10, sp.getyPoint() + 10, sp.getBreadth() / 2, sp.getBreadth() / 2); break; case ShapesID.RECTANGLE_ID: break; case ShapesID.ROUND_RECTANGLE_ID: g.drawRoundRect(obj.getxPoint(), obj.getyPoint(), obj.getLength(), obj.getBreadth(), obj.getArcW(), obj.getArcH()); break; } } break; </code></pre> <p>this is for 1 button</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.
    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