[2944] in java-interest

home help back first fref pref prev next nref lref last post

java-interest-digest V1 #226

daemon@ATHENA.MIT.EDU (owner-java-interest-digest@java.su)
Sat Oct 21 06:41:01 1995

From: owner-java-interest-digest@java.sun.com
Date: Wed, 18 Oct 1995 23:30:07 -0700
To: java-interest-digest@java.sun.com
Reply-To: java-interest@java.sun.com

java-interest-digest     Thursday, 19 October 1995     Volume 01 : Number 226

In this issue:

 	Re: URLConnection
 	Re: How to set the backgroud color?
 	Re: compile on PC, serve on SunOS...help!
 	Modality of dialogs/frames
 	[Q] How HotJava running applet?
 	Components and containers
 	Thread in Beta .... again

----------------------------------------------------------------------

From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
Date: Wed, 18 Oct 1995 19:13:44 -0700
Subject: Re: URLConnection

Hi Sybille,

> using the JDK-prebeta I tried to construct an URL Connection as follows
> 
> myURL = new URL( ... );
> myConnection = new URLConnection(myURL);

Try "myConnection = myURL.openConnection()" instead...

				...jim

------------------------------

From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
Date: Wed, 18 Oct 1995 19:34:32 -0700
Subject: Re: How to set the backgroud color?

Hi Tony,

> 1. How do you set the background color within the applet area? The

	setBackground(Color c)

It is implemented in Component so all Component objects support it
(including Applet).

> 2. This is probably related to the first one as well. When I load a gif
> with transparency index set, java seems to simply paint the transparent
> area into the default background color (grey), which doesn't realy
> achieve the desired transparent effect when you draw one image on the
> other. ANy insight?

Java doesn't paint anything for the transparent pixels of an image.
The background might be getting painted if you don't override update().

If your applet gets damage (i.e. it is behind some other window and
then that other window is moved away), the background of the exposed
or damaged area is filled with the background color and paint(Graphics g)
is called for you to repaint the applet.

If you call repaint(), then no background filling will occur but the
update(Graphics g) method will be called.  If you don't override that
method, then the default implementation that will be executed for you
is to clear the background to the background color and to then call
paint(Graphics g).

				...jim

------------------------------

From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
Date: Wed, 18 Oct 1995 19:37:52 -0700
Subject: Re: compile on PC, serve on SunOS...help!

Hi Chantal,

> I'm trying to use win95 to compile java and then move the class files
> to a SunOS web server.  Not working.  Example: I wrote HelloWorld and
> to get it to compile on the PC, included:
> 
> 	import awt.Graphics; 
> 	public class HelloWorld extends browser.Applet {
> 
> Moved it to SunOS and with Netscape2 get the error window containing such as:
> 
> 	I/O exception when loading: browser.Applet
> 	java.lang.UnknownError browser/Applet
> 
> What am I doing wrong?  I must be able to compile on the PC and serve/run
> the web on SunOS.

You are trying to run an Alpha applet in Netscape Navigator which only
supports Beta applets.  The entire class tree was reorganized between
Alpha and Beta.  If you want to use applets with Navigator 2.0, then you
will have to develop them with a Beta applet development environment,
which is currently only available on Solaris.  The PC version of the
Beta development environment is not available yet (we're working on
it).  See "http://java.sun.com/" for more details...

				...jim

------------------------------

From: rvhoof@nynexst.com (Ron van Hoof)
Date: Wed, 18 Oct 1995 22:58:22 -0400
Subject: Modality of dialogs/frames

Hi all!

	I'm currently writing a backward chainer (inference mechanism)
and need to use an ask-dialog, in case a value for an attribute cannot
be found in the knowledge base.

	Does anybody know how I can implement the modality for a frame.
(The current Java Dialog does not support modality yet and Netscape
2.0 doesn't support the dialogs at all (gives errors)). 

Below I've given the methods calling the ask-dialog and the class
for the ask-dialog itself. Any feedback is welcome...

Ron


In the class Variable I have the following two methods:
public void traceValues() {
	// Start tracing the value for the variable. First try to
	// infer the variable based on the rules in the knowledge
	// base, if this doesn't provide a value for the variable
	// then if the variable is askable, ask for the value.
	ruleBase.traceHandler().writeTrace("Tracing values for "+name);

	infer();
	if ((established() == false) && isAskable()) {
		ruleBase.traceHandler().writeTrace("Asking value for "+name);
		ask();
	} // end if
	setTraced(true);
} // traceValues

public void ask() {
	AskDialog askDlg;

	System.out.println("Entering ask");
	askDlg = new AskDialog();

	// process results dialog
	if (askDlg.pressedButton().equals("OK")) {
		System.out.println("OK");
		setTraced(true);
		value = askDlg.getText();
		System.out.println("value: "+value().toString());
	}
	else if (askDlg.pressedButton().equals("Cancel")) { 
		setTraced(false);
		System.out.println("Cancel");
		askDlg.dispose();
	} // end if
} // ask

Next is the class AskDialog itself:
class AskDialog extends Frame {

	// Attributes
	TextField	askField;
	String		result = "";
	String		pressedButton = "";

	// Methods

	public AskDialog() {
		//Set title of Dialog and make Dialog modal
		super("Ask...");

		// Create textfield
		askField = new TextField(30);
		Panel north = new Panel();
		north.setLayout(new BorderLayout());
		north.add("Center", askField);

		// Create Button panel
		Panel center = new Panel();
		center.setLayout(new FlowLayout());
		center.add(new Button("OK"));
		center.add(new Button("Cancel"));

		add("North", north);
		add("Center", center);

		// Set Dialog window size
		resize(300, 100);	

		show();
	} //AskDialog

	public boolean action(Event evt, Object arg) {
		if ("OK".equals(arg)) {
			System.out.println("OK pressed");
			pressedButton = "OK";
			result = askField.getText();
			//this.hide();
		}
		else if ("Cancel".equals(arg)) {
			System.out.println("Cancel pressed");
			pressedButton = "Cancel";
			//this.hide();
		}
		return true;
	} // action

	public String pressedButton() {
		return pressedButton;
	} // pressedButton
   
	public String getText() {
		return result;
	} // getText
} // AskDialog


- ---------------------------------------------------------------------
Ron van Hoof                         NYNEX Science & Technology, Inc.
Member of Technical Staff            Research & Development
                                     Work Systems Design Group
E-Mail: rvhoof@nynexst.com	     400 Westchester Avenue, Rm 115a
Voice:  (914) 644-2046 		     White Plains, NY 10604
Fax:    (914) 949-9566 		     USA
- ---------------------------------------------------------------------

------------------------------

From: "Kyung Soon, Park" <sosarian@nuri.net>
Date: Thu, 19 Oct 1995 12:16:00 +0900
Subject: [Q] How HotJava running applet?

Why is Hotjava.exe so small?
When running an applet in Hotjava, is it use API's in subdirectories in HotJava?
In Netscape 2.0b1j, there is no API classes in subdirectory.
But applet could run.
How can I understand these mechanism?

######################################################
     I*NET Technologies, Inc.  (http://www.iworld.net)
     Member of Technical Staff
    
            Mr.  Kyung Soon, Park

     Email : sosarian@nuri.net
     TEL : +82-2-538-6941     
     URL : http://sol.nuri.net/~sosarian
######################################################


------------------------------

From: edanuff@protagonist.com (Ed Anuff)
Date: Wed, 18 Oct 1995 21:06:25 -0800
Subject: Components and containers

Like others on this list, I'm having a tough time with getting components
to lay out and resize correctly.  I've included the source for an example
applet that I'm using to test this out.  I would expect that the panel is
layed out at 100,100 and that the canvas would be positioned at 100,100
within the panel.

- ----------------------
|Applet              |
|                    |
|                    |
|      --------------|
|      |Panel1       |
|      |             |
|      |             |
|      |       ------|
|      |       |\ | /|
|      |       | \|/ |
|      |       |--\--|
|      |       | /|\ |
|      |       |/ | \|
- ----------------------

When run, everything displays at 0,0 (in the applet viewer - in Netscape
nothing displays).  My question is whether this is supposed to be the way
this works or if its a bug?  If its a bug, is it planned to be fixed in the
next rev?  BTW, I'm aware of the reasons why absolute placement is not a
good idea, but nothing in this example is platform dependent.

Ed


- -Hierarchy.java start---------------------------
import java.util.*;
import java.applet.*;
import java.awt.*;

public class Hierarchy extends Applet {

        Panel panel1;
        TestCanvas theCanvas;

        public void init() {
                resize(400, 400);
                setLayout(null);

                panel1 = new Panel();
                panel1.setLayout(null);
                panel1.reshape(100,100,200,200);
                add(panel1);

                theCanvas = new TestCanvas();
                theCanvas.reshape(100,100,100,100);
                panel1.add(theCanvas);

                panel1.move(100,100);
                theCanvas.move(100,100);

                repaint();

                System.out.println(location().x + ", " + location().y + ",
" + size().width + ", " + size().height);
                System.out.println(panel1.location().x + ", " +
panel1.location().y + ", " + panel1.size().width + ", " +
panel1.size().height);
                System.out.println(theCanvas.location().x + ", " +
theCanvas.location().y + ", " + theCanvas.size().width + ", " +
theCanvas.size().height);


        }

        public void start() {
                repaint();

                System.out.println(location().x + ", " + location().y + ",
" + size().width + ", " + size().height);
                System.out.println(panel1.location().x + ", " +
panel1.location().y + ", " + panel1.size().width + ", " +
panel1.size().height);
                System.out.println(theCanvas.location().x + ", " +
theCanvas.location().y + ", " + theCanvas.size().width + ", " +
theCanvas.size().height);

        }

}

class TestCanvas extends Canvas {
    public TestCanvas() {
    }

    public void paint(Graphics g) {
                Rectangle r = bounds();

                g.drawRect(0, 0, r.width-1, r.height-1);
                g.drawLine(0, 0, r.width, r.height);
                g.drawLine(r.width, 0, 0, r.height);
                g.drawLine(0, r.height / 2, r.width, r.height / 2);
                g.drawLine(r.width / 2, 0, r.width / 2, r.height);
    }
}
- -Hierarchy.java end-----------------------------



Ed Anuff
Protagonist Interactive
edanuff@protagonist.com
http://www.protagonist.com/



------------------------------

From: Edith Au <edith@pencom.com>
Date: Thu, 19 Oct 1995 00:08:01 -0400 (EDT)
Subject: Thread in Beta .... again

Hi,
  I have posted this message 2 days ago but  received no response.  Can
someone please help?

=============================================
  
  In Animator.java (beta demo) run() method

Thread me = Thread.currentThread();
....
.....

//engine is a thread started in start() method

while (maxWidth > 0 && maxHeight > 0 && engine == me)
{....}


  What is the role of thread me?  Why does it need to compare
engine and me?

  If I have another applets running on the same page, will
Thread.currentThread() = thread from another applet since only 1
thread is "physically" running at a time ? If it is true,
then the Blink applet might cause problem on a page with 2 or
more applets

public void run()
{
  while (true)
    try { Thread.currentThread().sleep(speed);}
        .......

}

It might put the wrong thread to sleep!

Can someone help?

Cheers,
Edith



------------------------------

End of java-interest-digest V1 #226
***********************************

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post