Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-26-2008, 03:17 PM
Member
 
Join Date: May 2008
Posts: 2
mo_mughrabi is on a distinguished road
New to Java, Creating screens with swings on Mac OS X
Hi,
am totally new to the forum and Java itself. I bought a book to teach me how to write Java programs from beginning.. The book has a CD attached with it, everything seem to be working fine accept when I try to create classes that contain javax.swing.JPanel.. look at the code below I couldn't run this on Mac OS X.. is there something am missing or should I download some library files in order for this class to run?

Code:
import java.awt.Graphics; import javax.swing.JPanel; public class Shapes extends JPanel { private int choice; // user's choice of which shape to draw // constructor sets the user's choice public Shapes( int userChoice ) { choice = userChoice; } // end Shapes constructor // draws a cascade of shapes starting from the top-left corner public void paintComponent( Graphics g ) { super.paintComponent( g ); for ( int i = 0; i < 10; i++ ) { // pick the shape based on the user's choice switch ( choice ) { case 1: // draw rectangles g.drawRect( 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 ); break; case 2: // draw ovals g.drawOval( 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 ); break; } // end switch } // end for } // end method paintComponent } // end class Shapes
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating image using java mmahesh_mca New To Java 1 04-27-2008 01:23 AM
java swings emperoraj AWT / Swing 0 03-26-2008 01:50 PM
Creating a Downloader using JAVA shinojkk New To Java 0 01-08-2008 07:08 PM
Drawing charts using swings ravindarjobs New To Java 13 11-03-2007 07:19 AM
Creating Sub forms in java netbeans 5.0 java_newbie NetBeans 14 08-06-2007 09:19 PM


All times are GMT +3. The time now is 03:52 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org