I could write this code which draw a grid of dots on the screen. Now i'll like to do the same as a JME aplication as a start to develop dots and lines game on the mobile phones.
any one to direct me in the right direction.
the code:
package dots;
/**
*
* @author Admininstrator
*/
public class dots {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
new grid();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package dots;
/**
*
* @author Administrator
*/
import java.awt.*;
import java.awt.Rectangle.*;
import javax.swing.JFrame;
class grid extends JFrame
{
private Rectangle[][] dots = new Rectangle[5][5] ;
grid()
{
setTitle("Dots Game");
setLocation( new Point( 300, 100 ) ) ;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize( 600, 400 );
setResizable(false) ; // this prevents re-sizing of window
setBackground(Color.gray);
for ( int i = 0; i < 5; i++ )
{
for ( int j = 0; j < 5; j++ )
{
//dots with some space between
dots[i][j] = new Rectangle( 60 + 90*i, 90 + 60*j, 20, 20 ) ;
}
}
setVisible( true );
}
@Override
public void paint( Graphics gc )
{
for ( int i = 0; i < 5; i++ )
{
for ( int j = 0; j < 5; j++ )
{
gc.setColor( Color.black) ;
gc.fillOval( dots[i][j].x, dots[i][j].y, dots[i][j].width, dots[i][j].height ) ;
}
}
}
}


Sign In
Create Account


Back to top









