DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Passing parameters within Java Applets

    Hi all,

    I have been to a few different forums now and nobody seems to be able to anwser this. Below is my code, its a java applet that uses getParameter to extract text from the html page its loaded in, the text is displayed in a jLabel, which all works.

    The problem I am having is that I need to pass a parameter using setBackground of the jLabel, have tried different ways of doing it but it wont work. It should pass the parameter of the colour of the jLabel, say red, green etc from the html page but this doesn't seem to be possible. Their must be a way of doing this. Does anyone know?

    public class MyApplet extends javax.swing.JApplet {
      public void init() {
        try {
          java.awt.EventQueue.invokeAndWait(new Runnable() {
            public void run() {
        } catch (Exception ex) {
      private void initComponents() { 
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JTextField();
        jTextField1.setBackground(java.awt.Color.red); //change, must read in parameter from html page
        getContentPane().add(jTextField1, java.awt.BorderLayout.CENTER);
        jLabel1.setBackground(java.awt.Color.blue); //change, must read in parameter from html page
        getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER);
      private javax.swing.JTextField jTextField1;
      private javax.swing.JTextField jLabel1;

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Welcome to DevX

    I don't know if we will fare any better than the other sites that you have visited, but we try hard.

    I found a couple of things that you might find interesting....



    Hopefully other places haven't given you the same links.

Similar Threads

  1. Replies: 2
    Last Post: 06-14-2006, 03:16 PM
  2. passing command line argument in java
    By smallsouljah in forum Java
    Replies: 1
    Last Post: 11-03-2005, 11:23 AM
  3. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  4. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  5. How to use Java Swing applets...
    By Alligator Bob in forum Java
    Replies: 0
    Last Post: 05-29-2000, 06:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.