Creating an applet popup
Hi everyone. I'm pretty new at Java programming, and I started making a simple game. One of the things that I would like players to be able to do is type in the word "map" on the DOS screen or something, and have an applet pop up, and when a player closes the applet, the program itself doesn't close. I've tried a few things, but I get a variety of errors. Does anyone know of how to do this, or something other than an applet I could use? Thanks for looking!
The only way I can think of is to use JSObject to call JavaScript on the current page & have JavaScript do a window.open
http://forum.java.sun.com/thread.jsp?forum=31&thread=295808
Similar Messages
-
I want to create an applet, Please Help...
HI all,
I want to create an applet which should be able to display text and images...
To display text in an applet I am using ...
import java.awt.*;
import java.applet.*;
public class SimpleApplet extends Applet
public void paint(Graphics g)
g.drawString("A Simple Applet", 20, 20);
}Now If I want to create few operators in a different class, and i want to use it from the SimpleApplet class what should be doing.HI all,
I am creating an Gui: The code is here:
import javax.swing.*;
import java.awt.*;
public class Tab extends JFrame
JPanel p,p1,p2,p3,p4,p5;
Frame f1,f2,f3;
JTabbedPane tpane;
public Tab()
p = new JPanel();
p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();
p5 = new JPanel();
tpane = new JTabbedPane();
p.setLayout(new GridLayout(1,1));
tpane.addTab("File",p1);
tpane.addTab("Edit",p2);
tpane.addTab("Document",p3);
tpane.addTab("View",p4);
tpane.addTab("Help",p5);
p.add(tpane);
getContentPane().add(p);
setVisible(true);
public static void main(String[] args)
// TODO Auto-generated method stub
Tab t = new Tab();
}I want to diaplay some text in the main area left. What should I do.
How to add the Text. -
How to create an applet in a JDestopPane?
hello i would like to create an applet (JApplet) in a desktop (JDesktopPane).
i have to put the applet in a JInternalFrame so i can move and resize the window around.
indeed i can have several applets in the JDesktopPane.
it would be more powerfull than viewing it in a web navigator.
more i want to load an applet from its web site from its jar file.
i know that from a html page, you have to tell the navigator where is the jar file with the "archive" tag; the "CODE" tag is the name of the class file not the path to the package like my.package.myclass !
can i put my.package.myclass instead of myclass.class in the "CODE" tag?duplicate post
-
How to create an applet in a jDesktopPane
hello i would like to create an applet (JApplet) in a desktop (JDesktopPane).
i have to put the applet in a JInternalFrame so i can move and resize the window around.
indeed i can have several applets in the JDesktopPane.
it would be more powerfull than viewing it in a web navigator.
more i want to load an applet from its web site from its jar file.
i know that from a html page, you have to tell the navigator where is the jar file with the "archive" tag; the "CODE" tag is the name of the class file not the path to the package like my.package.myclass !
can i put my.package.myclass instead of myclass.class in the "CODE" tag?
here's some snaphot of my softwar kevin_shell to give you some ideas:
http://go.to/kevin-net/SNAP
desktop_panel: the JDesktopPane where i have opened a simple applet.
explorer_panel
it is an open source project.
hope someone answer me, i will give to you my source code.duplicate post
-
How to create an applet that shows a pdf as non-editable.
Hi friends,
Does any one know how to create an applet that shows a pdf document (should make that pdf a non-editable one) while clicking a link.Its urgent for me as I have to complete this one tomorrow itself...please help me...
I am able to view the pdf document but that cannot be make a non-editable one.
Can anyone gave me the code for that one....please I am not very much good in Java.PDF is a proprietary format and Java doesn't support it by default. Are you using a 3rd party tool to create the PDF? If so, you need to review the developer docs to see how to make the document non-editable. Frankly, I don't see why you're using an Applet to view a PDF in the first place. What exactly are you trying to do. I'm confused.
-
Creating an Applet from an Application
So i'm developing my own version of the '80s Space Invader game for class, and one of the requirments is that we have to turn in an application, but also post an Applet version on a website. The game is pretty much done, but I am having trouble creating the Applet from the Application. I've done most of the stuff that i thought you were supposed to do. The thing is, it will run whenever i use the appletviewer from the dos prompt just like it does when i'm running the application. However, when Ii try to view it in an actuall explorer window, it wont load.
The way the program was designed, it had a "SpaceInvaders" class that had the main method, which only had about 4 lines. Then i had a DrawFrame class that extended JFrame, and that had the bulk of the code in it. The main method of the SpaceInvaders class had a "DrawFrame frame = new DrawFrame();" statement, and then a couple set.whatever statements. to change it to an applet, i just commented out the whole of the SpaceInvaders class, then i renamed the DrawFrame class to "public class SpaceInvaders extends JApplet" changed the consructor to the "init()" method, and commented out the setSize and setTitle statements, and also i imported java.applet.*;
when i try to run the html file in firefox, all i get is the frame with a little red 'X' in it, and at the bottom it says "Applet SpaceInvaders notinited"
any help, ideas, or tips would be greately appreciated. Thanks in advance, and if you need any more info, let me know.i created a very simple applet:
import java.applet.*;
import java.awt.*;
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
public class HelloWorld extends Applet {
public void paint(Graphics g) {
// Display "Hello World!"
g.drawString("Hello world!", 50, 25);
}and it ran just fine inside of a browser. I've also ran other applets that should be very similar to mine, but still mine doesn't work. -
How to create an applet, with many squares inside?
Hey,
I'm having problems creating an applet. Heres the image I need to recreate. The drawing should scale, so that it reaches the full width and
height of the applet.
http://img503.imageshack.us/my.php?image=graphicsafx5.jpg
I created a similar one (the code is below), but don't know how to modify it to create the image in the above link. Do I need a for loop? like for ( int i = 0; i < 10; ++i )
import java.applet.Applet;
import java.awt.*;
public class AprilTest1 extends Applet
public void paint(Graphics g)
Graphics2D g2 = (Graphics2D)g;
int width = getWidth();
int height = getHeight();
g2.setColor( Color.black );
g2.fillRect( 0, 0, width, height);
int pen_width = width/90 + 1;
g2.setStroke(new BasicStroke(pen_width));
g2.setColor( Color.white );
g2.drawRect( width/4, height/4, width/2, height/2);
}As CeciNEstPasUnProgrammeur said you do need a loop. You can probably make good use of the % operator inside your loop also.
for(int i=0; i<NUMBER_OF_RECTANGLES; i++){
if(i % 2 == 0) {
//draw black rectangle
} else {
//draw white rectangle
}Just think about what you need to do:
-Start 1 rectangle at (0,0) and have its width and height as getWidth() and getHeight().
-Pick an increment [this will be the 'width' of each rectangle]
-Now for each rectangle you want to move your x and y points right and down by your increment. Moreover, you want to make your width and height smaller by your increment*2
Essentially what I did is initialize 3 variables to 0 [say x, y, and z]. In your for loop use the % operator in an if-else block. If the loop is on an even number make a white rectangle, if the loop is on an odd number make a black rectangle. Set the x and y position to x+z and y+z respectivley. Set the height and width to getHeight()-(z*2) and getWidth()-(z*2) and then increment z by...lets say 10.
This means on the first loop:
x = 0
y = 0
width = getWidth()
height = getHeight()
Second loop:
x = 10
y = 10
width = getWidth()-20 [10 to compensate for the shift, and 10 for the width]
height = getHeight()-20
Here is what I came up with - hope it helps.
import java.applet.Applet;
import java.awt.*;
public class AprilTest1 extends Applet {
private int x, y, z = 0;
public void paint(Graphics g) {
for(int i=0; i<10; i++){
if(i%2==1){
g.setColor( Color.white );
g.fillRect(x+z, y+z, getWidth()-(z*2), getHeight()-(z*2));
} else {
g.setColor( Color.black );
g.fillRect(x+z, y+z, getWidth()-(z*2), getHeight()-(z*2));
z += 10;
}Any questions, feel free to ask :) -
Somebody correct my code Iam trying to create an applet which connects DB
This is throwing many mistakes iam trying to create an applet like an airplace booking which shows combo box of the available aircrafts and when selected it should show the no of available seats
import javax.swing.*;
import java.awt.*;
//<applet code=Aircraft_Booking width=500 height=500></applet>
public class Aircraft_Booking extends JApplet
JLabel lblStdId;
JLabel lblStdSeats;
JLabel lblStdAircraft;
JComboBox jcmbStdAircraft;
JTextField jcmbStdSeats;
JTextField jcmbStdId;
JPanel panel;
//Member Function/
public void init()
panel = new JPanel();
lblStdId = new JLabel("Aircraft Booking");
lblStdSeats = new JLabel("No of Available Seats");
lblStdAircraft = new JLabel("Choose your Aircraft");
//txtStdId = new JTextField(5);/
String p = "Select * from Aircraft where aircrafttypeid";
/*Initialize and load the JDBC-ODBC Bridge driver*/
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
/*Establish a connection with a data source*/
Connection con = DriverManager.getConnection("jdbc:odbc:MyDataSource", "sa", "");
/*Create a Statement object to process the SELECT statement*/
Statement stmt = con.createStatement();
/*Execute the SELECT SQL statement*/
ResultSet rs = stmt.executeQuery(str);
jcmbStdAircraft = new JComboBox(p);
//Add all components to panel/
panel.add(lblStdId);
//panel.add(txtStdId);/
panel.add(lblStdAircraft);
panel.add(jcmbStdAircraft);
//Add Panel to JApplet/
getContentPane().add(panel);
}When running an Applet connections can only be established back to the originating machine unless you have changed the security configuration of the client machine.
This means that you would only be able to connect to the database on the server from which the applet was loaded.
Contrariwise the JDBC-ODBC driver will try to connect to the database on the local machine. So I can't see that working unless this was your intention and you have made the appropriate security config changes - but in such a circumstance Applets are a rather odd choice of environment. -
Hi
I am using Schulmberger Smart Card Tool Kit in order to create applet and applet instances.
I have created the applet inside the card but I couldn't create an applet instance. Because when I am going to create the applet instance by using the software it asks the install parameters. Still I don't know does it ask the parameters to call the method
// Install method
public static void install(byte buffer[],short offset,byte length){
// create a CryptoTest applet instance
new CryptoTest(buffer, offset, length);
} // end of install method
How should I give such parameters. Please reply me soon
If you can give me an example, That is perfect
Thanks
Best regards
Denzil jayasinghe
gayandenzil@gmail,comNormally installation parameters are just passed to the Applet itself. It can evaluate it in the install method. The system specific parameters may be used by the OS to set minimum memory limits. What install parameters are required by your smart card OS, you should find in the data sheet or contact Gemalto customer support (Schlumberger --> Axalto --> Gemalto).
For reference check GP 2.1.1 card specification, 9.5 INSTALL Command, 9.5.2.3.6 INSTALL [for load] and INSTALL [for install] Parameters, Table 9-36: Install Parameter Tags -
What is lightweight and heavyweight ? how to create my applet lightweight?
Sir ,
t have created an applet and in that i have not use any component
for drawing now i want to use component for applet but cant grtting how to do this , by reference of sun java i have found this code for application to create lightweight::
import java.awt.*;
import java.awt.event.*;
* Silly Sample program which demonstrates the basic paint
* callback mechanism in the AWT.
public class test1{
public static void main(String[] args) {
Frame f = new Frame("Have a nice day!");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
f.add(new SmileyCanvas(Color.yellow), BorderLayout.CENTER);
f.pack();
f.show();
* A canvas which renders a smiley-face to the screen
* Note: Canvas is a heavyweight superclass, which makes
* SmileyCanvas also heavyweight. To convert this class to
* a lightweight, change "extends Canvas" to "extends Component".
class SmileyCanvas extends Canvas {
public SmileyCanvas(Color faceColor) {
setForeground(faceColor);
public Dimension getPreferredSize() {
return new Dimension(300,300);
* Paint when the AWT tells us to...
public void paint(Graphics g) {
// Dynamically calculate size information
// (the canvas may have been resized externally...)
Dimension size = getSize();
int d = Math.min(size.width, size.height); // diameter
int ed = d/20; // eye diameter
int x = (size.width - d)/2;
int y = (size.height - d)/2;
// draw head (color already set to foreground)
g.fillOval(x, y, d, d);
g.setColor(Color.black);
g.drawOval(x, y, d, d);
// draw eyes
g.fillOval(x+d/3-(ed/2), y+d/3-(ed/2), ed, ed);
g.fillOval(x+(2*(d/3))-(ed/2), y+d/3-(ed/2), ed, ed);
//draw mouth
g.drawArc(x+d/4, y+2*(d/5), d/2, d/3, 0, -180);
this code is not for applet so how to make this code for applet ?I use the Snippets folder to store re-usable code. Scroll to
the file or
folder desired, double click and voila! Code is inserted into
the page.
As for the other bells & whistles, you are probably
thinking about DW
Extensions (.mxp) files. There are many 3rd party makers of
extensions.
Some are free, some cost a nominal fee. Check around to see
if what you
want isn't already available. If not, read this article.
Creating an Extension:
http://help.adobe.com/en_US/Dreamweaver/10.0_Extending/WS5b3ccc516d4fbf351e63e3d117f508c8d e-7fde.html
Nancy O.
Alt-Web Design & Publishing
www.alt-web.com -
I need to create an applet from a standalone chat client.
Can someone please help me, or suggest some good tutorials about writing applets?
TIA,
Richie.
------------------------BEGIN---------------------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class Client
extends JPanel {
public static void main(String[] args) throws IOException {
String name = args[0];
String host = args[1];
int port = Integer.parseInt(args[2]);
final Socket s = new Socket(host, port);
final Client c = new Client(name, s);
JFrame f = new JFrame("Client : " + name);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
c.shutDown();
System.exit(0);
f.setSize(300, 300);
f.setLocation(100, 100);
f.setContentPane(c);
f.setVisible(true);
private String mName;
private JTextArea mOutputArea;
private JTextField mInputField;
private PrintWriter mOut;
public Client(final String name, Socket s)
throws IOException {
mName = name;
createUI();
wireNetwork(s);
wireEvents();
public void shutDown() {
mOut.println("");
mOut.close();
protected void createUI() {
setLayout(new BorderLayout());
mOutputArea = new JTextArea();
mOutputArea.setLineWrap(true);
mOutputArea.setEditable(false);
add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
mInputField = new JTextField(20);
JPanel controls = new JPanel();
controls.add(mInputField);
add(controls, BorderLayout.SOUTH);
mInputField.requestFocus();
protected void wireNetwork(Socket s) throws IOException {
mOut = new PrintWriter(s.getOutputStream(), true);
final String eol = System.getProperty("line.separator");
new Listener(s.getInputStream()) {
public void processLine(String line) {
mOutputArea.append(line + eol);
mOutputArea.setCaretPosition(
mOutputArea.getDocument().getLength());
protected void wireEvents() {
mInputField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String line = mInputField.getText();
if (line.length() == 0) return;
mOut.println(mName + " : " + line);
mInputField.setText("");
------------------------------END------------------------------Thank you, that was very helpful info. I am new to java, so I find this exercise really touch. Here is what I have so far:
-------------------------BEGIN-------------------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.applet.*;
import javax.swing.*;
public class Client extends Applet implements ActionListener {
String name;
String host;
int port;
final Socket s;
final Client c;
Button sendButton;
TextField txtField;
TextArea txtArea;
public void init() {
setLayout(new FlowLayout());
name = "Richard";
host = InetAddress.getLocalHost();
port = 8000;
Socket s = new Socket(host, port);
Client c = new Client(name, s);
txtField = new TextField();
sendButton = new Button("Send");
txtArea = new TextArea("Chat with " + name + " on " + host " : " + port);
add(txtArea);
add(txtField);
add(sendButton);
sendButton.addActionListener(this);
public void paint(Graphics g) {
g.setColor(Color.red);
g.drawString("<" + name + "> " + txtField.getText(),20,250);
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == sendButton)
repaint();
txtArea.setText(txtField.getText());
private String mName;
private TextArea mOutputArea;
private TextField mInputField;
private PrintWriter mOut;
public Client(final String name, Socket s)
throws IOException {
mName = name;
createUI();
wireNetwork(s);
wireEvents();
public void shutDown() {
mOut.println("");
mOut.close();
protected void createUI() {
setLayout(new BorderLayout());
mOutputArea = new TextArea();
mOutputArea.setLineWrap(true);
mOutputArea.setEditable(false);
add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
mInputField = new TextField(20);
JPanel controls = new JPanel();
controls.add(mInputField);
add(controls, BorderLayout.SOUTH);
mInputField.requestFocus();
protected void wireNetwork(Socket s) throws IOException {
mOut = new PrintWriter(s.getOutputStream(), true);
final String eol = System.getProperty("line.separator");
new Listener(s.getInputStream()) {
public void processLine(String line) {
mOutputArea.append(line + eol);
mOutputArea.setCaretPosition(
mOutputArea.getDocument().getLength());
protected void wireEvents() {
mInputField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String line = mInputField.getText();
if (line.length() == 0) return;
mOut.println(mName + " : " + line);
mInputField.setText(""); -
Simple question on creating an applet in JDeveloper 10g
the Help says:
To create a Java applet: In the Navigator, select the project in which you want to create the new applet. Choose File | New to open the New Gallery. In the Categories tree, expand Client Tier and select Swing/AWT. In the Items list, double-click Applet to open the New Applet dialog.This will open the New Applet dialog that will create the applet for you based on information you specify, including the name, package and class it extends. Press F1 or click H elp to obtain context-sensitive help in the dialog.
Yet when I select Swing/AWT, the Items list has no Applet choice; the choices are:
Dialog
Frame
Java Application
Java Web Start (JNLP) Files
Panel
so how does one create an Applet?Select Web Tier>Applet in the New Gallery.
-
Where to create an applets GUI?
Hi, i'm interested in some comments on where to create an applets GUI.
Recently, i had to use JBuilder 7 to create an applet, and the wizard creates a jbInit() method to create the GUI and calls this method inside the applets constructor.
Up to now, i used to build the applets GUI inside the applets init() method (as practiced by the Java Tutorial).
Any comments on these two different approaches?
Thanks in advance.
MarkusJust for the files: after reading the following paragraph in the Java Tutorial, i have decided to go with the init method:
'The init method is useful for one-time initialization that doesn't take very long. In general, the init method should contain the code that you would normally put into a constructor. The reason applets shouldn't usually have constructors is that an applet isn't guaranteed to have a full environment until its init method is called. For example, the Applet image loading methods simply don't work inside of a applet constructor. The init method, on the other hand, is a great place to call the image loading methods, since the methods return quickly.' (Trail: Writing Applets, Lesson: Overview of Applets, Methods for Milestones)
HTH, Markus -
Java Applet Window showing on signed applet popups
I have an applet deployed that is signed, but I'm experiencing a very annoying problem with JPopup windows that cross outside the border of the JFrame created by the Applet.
Those pop-up windows still show the warning at the bottom "Java Applet Window". That part is pretty annoying and I don't understand why it's doing that since they are coming from a signed, trusted applet.
Just to be clear, any of the JPopups or JDialogs or anything else we display inside the frame doesn't have this warning since we signed the applet.Our team is also using a signed applet and are having trouble with popup items not being accessible outside of the JFrame.
In appletviewer the popup (JXDatePicker) is fully accessible. If running in Internet Explorer on Windows 2000 the portion of the popup outside of the JFrame paints correctly but cannot receive click events correctly.
It would be preferrable that if the popup cannot receive events outside of the applet frame that the popup would be smart enough to pop itself fully in the applet frame.
Any suggestions?
Thank you. -
How to Create Multi select Popup LOV
Hi,
I have a requirment in my application like Below scenario.
I created one page like compose mail. In that i have used popup lov for selecting the user.
But the problem is, it is allowing only one user to be select.In my case i want to select multiple users to send the
mail.
Please help me.
NRHi,
How many users do you have in total? If it is a small number (a few dozen) you could use a multi select list or a shuttle item.
However if there are hundreds of users to choose from, you may need to write your own pop up LOV to select them (probably using an Apex collection to store the temporary list).
Or if you are really cool you could do something web 2.0-style using ajax (like those boxes in facebook where you just type the names of the persons and it shows a autocomplete list).
Luis
Maybe you are looking for
-
No internal hard drives seem to work! Please help!
Hello, I'm really hoping someone can help with this as I am losing my mind! I wanted to upgrade the internal hard drive of my 2009 Macbook Pro from the stock 250GB to a 500GB. The first try was with a Western Digital Scorpio Black (7200 RPM), the sec
-
IMac G4 says it's not connected to Internet but shows it is...
Hi, I'm not even sure I'm in the right place, but I have a few questions. At first when I connected my iMac G4 to the Internet it kept giving me "there is an error connecting to "XXXXX" network" type thing. Now, since I pressed Cmd, Option, O & F and
-
Ours MiFi 5410L has battery problems (draining when plugged in). I've called verizon, but they try to get my to buy yet another *** device. I have to use this one because it has a plug for an external antenna, which I have to have in order to even ge
-
Multiple MIDI Inputs Yet???
Can anyone tell me if LP8 offers multiple MIDI inputs? I use the step sequencer from my Elektron Monomachine for pattern creation and would like to be able to assign the external tracks from it to instrument tracks hosting either native or 3rd party
-
How to set Focus on a Cell in a Table
I have a column for which i set the table editor in the following way : DateTextField contractStarts = new DateTextField(); itemTable.getColumnModel().getColumn(9).setCellEditor(new DefaultCellEditor(contractStarts); When the focus is brought to a ce