Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Paint Command?
Davey Lopez
Ranch Hand
Posts: 33
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello My task is to draw a chess board with the
java
graphics. It was quite simple doing the board the only have question I have now is someone knows of a command that paints inside the square as they would have to be black and white
-- Thank you
import java.awt.*; import java.awt.event.*; public class CHESSBOARD extends Frame { public CHESSBOARD() {//Creates A Canvas setSize(1000, 1000);//Sets the Size of the canvas setTitle("ChessBoard");//Name of the project setVisible(true);//makes it visible } public void paint(Graphics g) { g.drawLine(50,50,450,50);//1st row line (top border) g.drawLine(50,100,450,100);//2nd row line g.drawLine(50,150,450,150);//3rd row line g.drawLine(50,200,450,200);//4th row line g.drawLine(50,250,450,250);//5th row line g.drawLine(50,300,450,300);//6th row line g.drawLine(50,350,450,350);//7th row line g.drawLine(50,400,450,400);//8th row line g.drawLine(50,450,450,450);//9th row line(bottom border) g.drawLine(50,50,50,450); //1 collumn(left border) g.drawLine(100,50,100,450);//2 collumn not counting border g.drawLine(150,50,150,450);//3 collumn not counting border g.drawLine(200,50,200,450);//4 collumn not counting border g.drawLine(250,50,250,450);//5 collumn not counting border g.drawLine(300,50,300,450);//6 collumn not counting border g.drawLine(350,50,350,450);//7 collumn not counting border g.drawLine(400,50,400,450);//8 collumn not counting border g.drawLine(450,50,450,450);//9 collumn(right border) } }
Ron McLeod
Marshal
Posts: 4501
572
I like...
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Would
Graphics#fillRect
work for that?
Piet Souris
Bartender
Posts: 5465
212
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It most certainly will.
And an economical way of doing: draw a big white square as your board,
and then only draw 32 black squares on it.
Greetz,
Piet
There are three kinds of actuaries: those who can count, and those who can't.
Davey Lopez
Ranch Hand
Posts: 33
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
All right thanks everyone that worked
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
How to create a JPanel that maintains the same aspect ratio when resized?
Ladders and slides
Implementing repaint() to panel after mouseclick
Someone, everyone, PLEASE HELP ME ON A PROJECT!!
Short Example of Fullscreen Graphics
More...