So I was giving this code to run on Netbeans but I'm not sure what's wrong I'm doing, when I copy and past it to new project it keep giving me errors, I think I need to do something when I first create the project, naming most likely, but I can't figure out what's wrong. The code is
Basically, my question is: if I give these two codes what you gonna do, step by step, to run them on NetBeans //code one package LineDrawing;
import java.awt.Color;
import java.awt.Graphics;
public class LiningPanel extends javax.swing.JPanel {
public LiningPanel() { }
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int w = getWidth();
int h = getHeight();
double lines = 15.0;
for(int i = 0; i < lines; i++)
{
int w2 = (int)((i/lines)*w);
int h2 = (int)((i/lines)*h);
g.drawLine(0, h2, w2, h);
}
}
}
// code 2 //////////////////////////////////////////////////////////
package LineDrawing;
import javax.swing.JFrame;
public class LineDrawingTest {
public static void main(String[] args) {
JFrame application = new JFrame();
LiningPanel panel = new LiningPanel();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
application.add(panel);
application.setSize(300, 300);
application.setTitle("Lining Art");
application.setVisible(true);
}
}