I know creating textfields and labels in swing. Now I want to draw a line by plotting pixels in swing, I have read all the examples on this site as well as any other sites also but I'm not getting it. I know how to do it in applets but I want to do it in swing. Please help.
import javax.swing.*;
import java.awt.*;
class dline{
JFrame j;
dline(){
j = new JFrame("Line Draw");
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setExtendedState(Frame.MAXIMIZED_BOTH);
j.setVisible(true);
}
public void paintComponent(Graphics g){
g.drawLine(10, 25,250, 300);
}
public static void main(String s[]){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new dline();
}
});
}
}