I want to make program load line from database.I've been setting at database every coordinat using double
.but im getting error when i try to load from database and want to drawline in jpanel it's didn't appear in my jpanel.how to fix it? this is my code.
ArrayList<Shape> linesList = new ArrayList<Shape>();
shape line = null;
public void loadline(){
while (rs.next()) {
double x1 = rs.getDouble("coorX"); //getting coordinate
double y1 = rs.getDouble("coorY");
double x2 = rs.getDouble("coorX2");
double y2 = rs.getDouble("coorY2");
line =new Line2D.Double(x1,y1,x2,y2);
linesList.add(line);
repaint();
revalidate();
}
}catch(Exception E){
JOptionPane.showMessageDialog(null, "error load data");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, "error sql");
}}
and this is my paint component method
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(birumuda);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
for(Shape content : linesList){
g2d.draw(content);
}
}