🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #18

FYI: catching focus problem in JComboBox after moving to Swing1.0.3

#18
From: yan zhou
Date: Thu, 27 Aug 1998 00:00
98 lines
3244 bytes
Hi,

  After I incorporated JB 2 pro. with swing1.0.3
instead of swing 1.0.1, everything was fine
until I encountered catching lostfocus in JComboBox.
It will not catch lostfocus events.

  I attached a simple applet to demonstrate this.
The applet shows that catching lostfocus is fine in
JB with swing 1.0.1, but not with swing 1.0.3

  You might consider this in programming and I would
like suggestions or workarounds. 
Thanks.

			Yan Zhou
			yzhou@mtu.edu


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.sun.java.swing.*;
import borland.jbcl.control.*;
import borland.jbcl.layout.*;

//import com.sun.java.swing.UIManager;
public class Applet1 extends JApplet {
  boolean isStandalone = false;
  BevelPanel bevelPanel1 = new BevelPanel();
  JComboBox jComboBox1 = new JComboBox();
  ButtonControl buttonControl1 = new ButtonControl();
//Get a parameter value
  
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }

  //Construct the applet
  
  public Applet1() {
  }
//Initialize the applet
  
  public void init() {
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
  }
  //static { 
  //  try { 
  //    //UIManager.setLookAndFeel(new
com.sun.java.swing.plaf.metal.MetalLookAndFeel());
  //    //UIManager.setLookAndFeel(new
com.sun.java.swing.plaf.motif.MotifLookAndFeel());
  //    UIManager.setLookAndFeel(new
com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
  //  }
  //  catch (Exception e) {}
  //}
//Component initialization
  
  private void jbInit() throws Exception {
    this.setSize(400,300);
    jComboBox1.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusLost(FocusEvent e) {
        jComboBox1_focusLost(e);
      }
    });
    buttonControl1.setLabel("buttonControl1");
    this.getContentPane().add(bevelPanel1, BorderLayout.CENTER);
    bevelPanel1.add(jComboBox1, new XYConstraints(70, 39, 209, 38));
    bevelPanel1.add(buttonControl1, new XYConstraints(114, 172, 94,
36));

    jComboBox1.addItem("1111");
    jComboBox1.addItem("2222");
    jComboBox1.addItem("3333");
  }
//Get Applet information
  
  public String getAppletInfo() {
    return "Applet Information";
  }
//Get parameter info
  
  public String[][] getParameterInfo() {
    return null;
  }

  void jComboBox1_focusLost(FocusEvent e) {
    System.out.println("Catch focus lost");
  }
}
Technical Details
Message-ID: <35E574FB.6A791D0@mtu.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,7dd7ab6b8b012548,start
X-Google-Attributes: gid111d45,public
X-Google-Thread: 109107,7dd7ab6b8b012548,start
X-Google-Attributes: gid109107,public
From: yan zhou <yzhou@mtu.edu>
Subject: FYI: catching focus problem in JComboBox after moving to Swing1.0.3
Date: 1998/08/27
Message-ID: <35E574FB.6A791D0@mtu.edu>
X-Deja-AN: 385294576
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing,borland.public.jbuilder.compiler