Wrox Programmer Forums
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2004, 07:59 AM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default GUI questions

Currently I am using JDK 1.2.1.

Consider the following simple coding:

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.BasicStroke;
import java.applet.*;


public class Stroke01 extends Applet {

    public void init() {
    }

    public void paint(Graphics g) {

        Graphics2D twoD = (Graphics2D)g;

        BasicStroke pen = new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
        twoD.setStroke(pen);
    }
}

When I try to embed the applet to HTML page, it diplays nothing when I run the browser. Why is it happen? Is Graphics2D not supported in JDK 1.2.1? Because whenever I use 2D effect, the actual output will not be displayed.


 
Old August 24th, 2004, 07:50 AM
Authorized User
 
Join Date: Aug 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are not actually drawing anything in your paint method.. you are just setting the width of your strokes. Add:
twoD.drawString("Hello World", 0, 0);

Ensure your set a size for your applet in your html.
 
Old August 24th, 2004, 09:23 AM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Oh, ya. Thank you so much, Gator.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Reusability of GUI hums .NET Framework 2.0 0 October 20th, 2004 05:51 AM
GUI question hlchuah77 C++ Programming 2 October 4th, 2004 07:10 PM
help in GUI khfarooq Java GUI 5 August 22nd, 2004 05:00 AM
GUI Components Slater BOOK: Beginning Java 2 1 June 18th, 2004 12:09 PM
GUI Programming in C# Neeki4444 C# 0 May 21st, 2004 02:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.