The Artima Developer Community
Sponsored Link

Java Answers Forum
please help me with my applet

28 replies on 2 pages. Most recent reply: Sep 3, 2003 10:50 AM by assan rekowski

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 28 replies on 2 pages [ 1 2 | » ]
assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

please help me with my applet Posted: Sep 1, 2003 2:02 PM
Reply to this message Reply
Advertisement
hi, i'm quite beginner in programming java, morover i'm from poland and it's sometimes difficult for me to understand u, so could write respetively...

The problem, is that i have an applet and a visitor of my site have to fill data with name age etc, when there is no age, or the ThextField has too much signs, (>3) there should appear an error window informing that something is wrong. I suppose it shulod be dialog window, but it's constructor has a variable Frame on the first place, so what should i put there?
If there is somebody, who could help me, i could show my simple project only with few personal data to make all simplest for u. I attach the file, my email is fenders@interia.pl Please help me, here in Poland there is really few forums and people interested in java.


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: please help me with my applet Posted: Sep 2, 2003 12:03 AM
Reply to this message Reply
Have u tried using javax.swing.JOptinPane class
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

yes Posted: Sep 2, 2003 4:12 AM
Reply to this message Reply
i saw two examples at http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/index.html#DialogDemo and here and when i use it in my project, it says " Undefinded packages

javax.swing.JDialog;
javax.swing.JButton;
javax.swing.JRadioButton;
javax.swing.JLabel;
javax.swing.ImageIcon;
javax.swing.BoxLayout;
etc
all javax.* are undentified what can i do?

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

ps. i hava microsoft visual j++ 6 Posted: Sep 2, 2003 4:31 AM
Reply to this message Reply
ps. i hava microsoft visual j++ 6

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: yes Posted: Sep 2, 2003 4:31 AM
Reply to this message Reply
Hmm no idea dear why it is happining.

I just downlaoded the CustomDialog and DemoDialog.java and it ran fine.

Is your all import javax.swing.JDialog; command giving error??

Is a simple import statement
import javax.swing.*; working??

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: yes Posted: Sep 2, 2003 4:32 AM
Reply to this message Reply
Do u have JDK?? Dont laugh if it sounds wierd

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: yes Posted: Sep 2, 2003 4:37 AM
Reply to this message Reply
check this ...you cant use swing package and all those package that came after jdk1.1


As far as Swing goes, you can use a product called 2LKit for VJ++. This will allow you to visually use the Swing components within J++. Since Swing works with 1.1, this will actually work easily.
As far as the other libraries go.... Microsoft doesn't plan on updating the product any, so if you plan to use the tool as more than an editor, you'll need to change your development tool. You won't be able to develop visually in their tool if you want to use JDBC (they use ADO) or any J2EE standard library that requires the Java 2 platform.

If you like the tool as an editor, you can change the menu to compile with the standard JDK, but you won't be able to use the debugger unless you use the MS VM, which is roughly equivalent to something like JDK 1.1.4.

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

q Posted: Sep 2, 2003 5:16 AM
Reply to this message Reply
firstly there is how the working project shoul look]
http://www.ki.uni.lodz.pl/~witek/Java/Zal/JavaZal.htm

i have to do the same one.
Try to push button "Wyslij", an error appears and it saiys tha the field Nazwisko is empty, and how i should do that?

my source is at http://www.toya.net.pl/~grupaie2/this.zip
and i u couldtake a closer look at it please? it'll take u a while it's very simple code.

beside as u see i'm a beginner and i know only that i have microsoft visual java++ 6 .

till this moment i managed with cod on my own, but now thins r getting complicated.

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 5:39 AM
Reply to this message Reply
I manage to do that without this package:
i defined new class


class ResponseWindow extends Frame {
Label nazwLab;
Label adresLab;
Label telLab;

public ResponseWindow(String naz, String ad, String tel) {
super("Error");
nazwLab = new Label(naz);
add("North", nazwLab);
adresLab = new Label(ad);
add("Center", adresLab);
telLab = new Label(tel);
add("South", telLab);
//setModal(this);
addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent event) {
setVisible(false);

}
});
}

and i do :
odp = new ResponseWindow("nazw", "adres", "telefon");
odp.setFont(new Font("Times New Roman CE", Font.PLAIN, 14));
odp.setSize(250, 120);
//odp.pack();
odp.setLocation(200,200);
odp.setVisible(true);
odp.set.setBackground(new Color(122,32,32));


to create window.

my questions now:

how to make this window such window, that if i click
on the page with my applet behind, this window didn,t dissapear?

and how to make on my applet visible black borders,
all like on http://www.ki.uni.lodz.pl/~witek/Java/Zal/JavaZal.htm ??

Thanks that u r helping me, really. i must search here, becouse in my country ehh.
}

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

Re: THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 5:46 AM
Reply to this message Reply
and how to add a button "OK"
that will close the window?

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 7:12 AM
Reply to this message Reply
I checked the link

http://www.ki.uni.lodz.pl/~witek/Java/Zal/JavaZal.htm

and the applet is working fine as per ur requirement.

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

Re: THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 7:37 AM
Reply to this message Reply
BUT IT'S NOT MY APPLET. My teacher mady it and i'am supposed to do the same one

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 8:52 AM
Reply to this message Reply
Change the name of the classes as ur teacher will find that u used his classes :) cheers.

Here are his classes.I tried and it worked.

Class1
import java.awt.Component;
import java.awt.Frame;
 
class ComponentUtilities
{
 
    public static Frame getTopLevelParent(Component component)
    {
        Component c;
        for(c = component; c.getParent() != null; c = c.getParent());
        if(c instanceof Frame)
            return (Frame)c;
        else
            return null;
    }
 
    ComponentUtilities()
    {
    }
}


class2
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
class MessageWindow extends Dialog
{
 
    protected boolean modalResult;
    Button okButton;
 
    protected MessageWindow(Frame frame, String title, String msg)
    {
        super(frame, title, true);
        modalResult = false;
        add("North", new Label(msg));
        Panel mainPanel = new Panel();
        okButton = new Button("Ok");
        mainPanel.add(okButton);
        add("Center", mainPanel);
        okButton.addActionListener(new ActionListener() {
 
            public void actionPerformed(ActionEvent event)
            {
                modalResult = true;
                setVisible(false);
            }
 
        });
        pack();
    }
 
    static boolean doModal(Applet aplet, String title, String msg)
    {
		System.out.println("=========");
        Frame frame = ComponentUtilities.getTopLevelParent(aplet);
        if(frame == null)
            frame = new Frame("Empty");
        MessageWindow tn = new MessageWindow(frame, title, msg);
        java.awt.Point aploc = aplet.getLocation();
        aplet.setEnabled(false);
        tn.setLocation(200, 300);
        tn.setVisible(true);
        aplet.setEnabled(true);
        return tn.modalResult;
    }
}
 
 



and in ur class QueryApplet
in the actipn listener of ur button show MessageDialog as

check if text in nazwLab is null or empty ...show similary u can check all the conditon remove ur code from actionlistener.

Moreover checq the line of code in init ()

String bcVal = getParameter("BGCOLOR");

make sure to provide correct input else it will through exception
MessageWindow.doModal(this, "B\u0142\u0105d", "Nie podano nazwiska klienta");
nazwLab.requestFocus();
return;
 



Hope that will help .....else ciao tomorrow...time for me to go to bed else mamma will shout ;)

goodluck

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 8:53 AM
Reply to this message Reply
remove the line
System.out.println("=========");

from my piece of code that was for check...

assan rekowski

Posts: 22
Nickname: haiaw
Registered: Sep, 2003

Re: THANKS FOR HELPING!!!! :) Posted: Sep 2, 2003 10:29 AM
Reply to this message Reply
it works thanks, but i dont uderstand the
class ComponentUtilities, what does it do? why there is this loop "for"? What does it mean
return (Frame)c;

Besides please tell me, why after removing line
java.awt.Point aploc = aplet.getLocation();
it still working good?

and why when i change
public static Frame getTopLevelParent(Component component) to
public static Frame getTopLevelParent(Applet component)

it still working good?

And how to make black thin borders around my applet

Flat View: This topic has 28 replies on 2 pages [ 1  2 | » ]
Topic: i want to check if a string exists in a file Previous Topic   Next Topic Topic: How to invoke a java program ( service ) which resides at Remote machine?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use