0

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);

    } 
gonz
  • 123
  • 6
  • 1
    Are you trying to modify DOM using an Applet? Do you want to run a function when a button is clicked? Do you want to create a button on DOM? You should clearly say 1. what you want to do, 2. what you have tried and 3. what went wrong. – Pooyan Khosravi Jun 10 '16 at 15:53
  • @PooyanKhosravi I edited – gonz Jun 10 '16 at 17:07
  • 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. – gonz Jun 10 '16 at 17:08
  • `setLayout(null);` Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). – Andrew Thompson Jun 11 '16 at 05:30

1 Answers1

1

..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);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433