I am trying to draw stars/asterisks but i can't. Any idea?

import java.io.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.*;

public class kmd1234 extends JFrame{

kmd1234(){
JFrame f;
JPanel p;
JLabel l;

int x,y;
f = new JFrame("my frame");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

p = new JPanel();
p.setPreferredSize(new Dimension(512, 512));

p.setBackground(Color.WHITE);
l = new JLabel();
l.setText("*");
p.setLayout((new GridLayout(500,500)));

for(int i=1;i<20;i++) {
x=5*i;
y=5+i;
	System.out.print("X: " +x+" ");
        System.out.println("Y: " +y+" ");
	    p.add(l,x,y);

}
	    f.add(p);
	    f.pack();
	    f.setVisible(true); 
//	f.setSize(1000,1000);
	f.setDefaultCloseOperation( EXIT_ON_CLOSE );
}
public static void main(String args[]) {
	new kmd1234();
	}	

}

Cheers

well, you're not trying in that code :)

sorted it out through gridBagLayout :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.