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?
Code:public class MyApplet extends javax.swing.JApplet { public void init() { try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } } 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 jTextField1.setText(getParameter("myParam1")); getContentPane().add(jTextField1, java.awt.BorderLayout.CENTER); jLabel1.setBackground(java.awt.Color.blue); //change, must read in parameter from html page jLabel1.setText(getParameter("myParam2")); getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER); } private javax.swing.JTextField jTextField1; private javax.swing.JTextField jLabel1; }


Reply With Quote




Bookmarks