Reputation: 123
I would like to send with a click of the button an applet any parameters to the browser. (Html). I know there are some methods button object but do not know which to use. How can I do this? ps .: I'm using jnlp protocol.
Something like:
key_button = new Button("Click");
key_button.setBounds(150,50,100,20);
add(key_button);
I have an applet code The following code:
package applet;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
//import java.io.BufferedWriter;
//import java.io.FileWriter;
public class UserInput extends Applet implements ActionListener{
TextField key_text1;
static TextField key_text2;
TextField key_output;
Label key_label1,key_label2,key_label3;
Button key_button;
public void init(){
setLayout(null);
// Add different components to the layout.
key_label1 = new Label("Enterpassword1: ");
key_label1.setBounds(20,20,100,20);
add(key_label1);
key_text1 = new TextField(5);
key_text1.setBounds(150,20,100,20);
add(key_text1);
key_button = new Button("Click");
key_button.setBounds(150,50,100,20);
/*******************Here I need to create a method that clicking key_button sends the data entered in the TextField field to the website (html) and html would appear the argument entered the applet TextFiel.**************************/
// key_button.event();
add(key_button);
}
Upvotes: 0
Views: 72
Reputation: 168825
..send with a click of the button an applet any parameters to the browser.
String value = textField.getText();
String path = "the.html";
URL url = new URL(getDocumentBase(), path + "?param=" + value);
getAppletContext().showDocument(url);
Upvotes: 1