The Artima Developer Community
Sponsored Link

Java Answers Forum
Pop up link?

1 reply on 1 page. Most recent reply: Jun 21, 2002 10:20 PM by Charles Bell

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 1 reply on 1 page
Brian Hayes

Posts: 1
Nickname: quetzal
Registered: Jun, 2002

Pop up link? Posted: Jun 21, 2002 2:38 PM
Reply to this message Reply
Advertisement
Hello

I have a neat little Java applet menu and would like a link from the menu to open up a pop up window in another frame.

I know this can be done in Java, but is there any information anywhere which I could read to show me how to do it? Basically, I need to know how to create the link to open the pop up, and I need to know how to create the pop up itself either in normal Java or Java Swing.

Many thanks


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Pop up link? Posted: Jun 21, 2002 10:20 PM
Reply to this message Reply

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class PopupApplet extends Applet implements ActionListener{

private Frame frame;

public void init(){
frame = new Frame();
frame.addWindowListener(new FrameListener());
MenuBar menuBar = new MenuBar();
frame.setMenuBar(menuBar);
Menu menu = new Menu("PopUps");
menuBar.add(menu);
MenuItem popupItem = new MenuItem("Popup");
menu.add(popupItem);
popupItem.addActionListener(this);
frame.add(this);
frame.setSize(getWidth(),getHeight());
//frame.setLocation(getX() + getWidth()/2- frame.getWidth()/2,getY() + getHeight() -frame.getHeight());
frame.setLocation(getX() ,getY() );
frame.show();

}

public void actionPerformed(ActionEvent ae){
if (ae.getActionCommand().compareTo("Popup") == 0){
System.out.println("do pop up");
Window popupWindow = new Window(frame);
popupWindow.addWindowListener(new FrameListener());
popupWindow.setSize(getWidth()/2, getHeight()/2);
popupWindow.setLocation(getX() +100,getY()+100);
Panel panel = new Panel();
panel.add(new Label("Pop ups are fun."));
popupWindow.setBackground(Color.blue);
popupWindow.add(panel);
popupWindow.show();
}
}

class FrameListener extends WindowAdapter{
public void windowClosing(WindowEvent we){
frame.hide();
}
}
}

*************************************

<html>
<head>
<title>PopupApplet</title>
</head>

<body>
<applet codebase ="." code="PopupApplet.class" width = "400" height = "200">

</applet>

</body>

</html>

Flat View: This topic has 1 reply on 1 page
Topic: Redirecting to a JSP page in a new window from servlet doPost method Previous Topic   Next Topic Topic: Naming object references at compile or run time?

Sponsored Links



Google
  Web Artima.com   

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