package com.drbob42.jbjar.tip12; import java.awt.*; import java.awt.event.*; import java.applet.*; import borland.jbcl.layout.*; public class Invalidate2Applet extends Applet { GridBagLayout gridBagLayout1 = new GridBagLayout(); Label label1 = new Label(); TextField textField1 = new TextField(); Button button1 = new Button(); /* * Initialize the applet */ public void init() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } /* * Component initialization */ private void jbInit() throws Exception { label1.setText("Label"); textField1.setText("Text of which length is greater than label shown"); button1.setLabel("Copy text to label"); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); this.setSize(new Dimension(460, 53)); this.setLayout(gridBagLayout1); this.add(label1, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); this.add(textField1, new GridBagConstraints2(1, 0, 1, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); this.add(button1, new GridBagConstraints2(2, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } /* * Get Applet information */ public String getAppletInfo() { return "Invalidate UI controls demonstration\r\n" + "Hubert A. Klein Ikkink, http://www.drbob42.com/jbuilder"; } /* * Get parameter info */ public String[][] getParameterInfo() { return null; } void button1_actionPerformed(ActionEvent e) { label1.setText(textField1.getText()); label1.invalidate(); validate(); } }