Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
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 07-05-2007, 06:51 AM
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
Problem with JButton
Hello, I'm new in java and i need some help with buttons and their actions.
I need to insert buttons to perform three actions (draw lines).

Code:
import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; public class antras extends JApplet { private Rectangle2D Shape4; public antras () { setBackground( Color.black ); Shape4 = new Rectangle2D.Float (10.F, 10.F, 480.F, 280.F); } public void paint (Graphics g) { Graphics2D g2D; boolean Contained; g2D = (Graphics2D) g; g2D.setColor(Color.white); g2D.fill (Shape4); Contained = Shape4.intersectsLine (400., 10., 480., 70.); //first action g2D.setColor (Color.green); g2D.drawLine (10, 100, 489, 100); //second action g2D.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1f, new float[] {2f},0f)); g2D.setColor (Color.green); g2D.drawLine (10, 140, 490, 140); //third action g2D.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1f, new float[] {5f},0f)); g2D.setColor (Color.green); g2D.drawLine (10, 200, 490, 200); } }
Can anybody help?
Thanks.
Marcus

Last edited by Marcus : 07-05-2007 at 06:54 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-05-2007, 06:56 AM
Member
 
Join Date: Jun 2007
Posts: 95
Felissa is on a distinguished road
What you need to look into is an Action Listener for any buttons that you implement.
Some examples can be seen here

I would find the examples much more useful in this case.

Greetings.
Felissa
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
JButton onClick? Joe2003 AWT / Swing 2 01-06-2008 04:04 PM
Help with JButton and layout adlb1300 AWT / Swing 1 12-25-2007 09:33 AM
Need help with JButton event adlb1300 New To Java 2 11-19-2007 02:15 AM
mouse over on JButton gradon Java Applets 1 08-04-2007 06:50 AM
Few action in one Jbutton kubiasty New To Java 0 07-25-2007 11:19 AM


All times are GMT +3. The time now is 05:32 PM.


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