JCombo box focus problem in WinNT/2000

Hi,
We have made use of JCombobox component in our application and we have implemented autocomplete feature for that (Written our own logic). For testing we tried to run our application in Windows NT O/S. As and when user types any value in the JCombobox and if ENTER key is pressed or tries to move out by pressing tab key, then the existence of that value is checked in Registry (User profile ? Part of Autocomplete feature). If the same value does not exists, then the value will be stored in the registry. Here our problem is, user is unable to move out of JCombobox and it goes to infinite loop. To come out of the problem, user will have to terminate the application. However, if we comment part of the code i.e. focusLost part which (Setup Method in below pasted code) has logic to put the user entered value into the JCombobox in the same session of panel, then application works with one limitation i.e. user will have to press the tab key twice to move out of JCombobox.
However, none of the above problem were reported when the application is running in Windows2000 O/S with local admin rights to logon user.
Is this a bug with Swings? Or a limitation with Windows2000 O/s to run the SWING based application.
If somebody has any solution, please forward.
Thanks,
Regards,
Raj.
Code: ===============================================================
package com.tial.tial.ws.util.autocomplete;
import com.tial.tial.ws.model.SelectableFieldModel;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.ComboBoxEditor;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
/** AutoCompleteCombo is used when normal combo Box requires Auto - complete feature.
* * @version 1.0
*modified on 26th March, 03 to solve case problem
*modified on 27th March, 03 to put the user entered value into the combo
public final class AutoCompleteCombo extends JComboBox{
private SelectableFieldModel m_myModel;
private ComboBoxEditor m_myEditor;
private JTextField m_txtEditor;
private int SIZEOFSELECTBOX = 20;
private boolean m_isTextSelected = false;
/** this is dictionary which has the data from the registry and also those entered by the user in the perticular session.
protected AutoCompleteDictionary m_dict;
//Constructors
/** Constructor for this class. Sets up the dictionary received and listners to the present instance.
* @param dict the dictionary received from the panel that uses AutoCompleteCombo.
public AutoCompleteCombo(AutoCompleteDictionary dict, SelectableFieldModel fldModel) {
super();
m_myModel = fldModel;
m_myEditor = super.getEditor();
m_txtEditor = (JTextField)m_myEditor.getEditorComponent();
setUp();
setDictionary(dict);
public AutoCompleteCombo(AutoCompleteDictionary dict) {
super();
m_myModel = null;
m_myEditor = super.getEditor();
m_txtEditor = (JTextField)m_myEditor.getEditorComponent();
setUp();
setDictionary(dict);
/** sets the dictionary received from the panel to the instance of AutoCompleteCombo.
* @param dict dictionary received in the constructor from the panel
public void setDictionary(AutoCompleteDictionary dict) {
m_dict = dict;
/** sets the focus and key listners to the AutoCompleteCombo.
protected void setUp() {
m_txtEditor.addFocusListener(new FocusAdapter() {
//Saves the field value in the dictionary when the focus of the field is lost,
//this is especially made to take care of commonly used TAB to move frm 1 fld to another.
// Comment from below to work atleast with pressing tab key twice.
public void focusLost(FocusEvent e) {
if(m_dict.size() == SIZEOFSELECTBOX){
m_dict.removeEntry(m_dict.last().toString());
m_dict.addEntry(m_txtEditor.getText().toUpperCase());
//to put the user entered value into the combo in the same session of panel
if (null != m_myModel) {
String dictList = m_dict.getElementsList();
String[] dictArray = dictList.split("~");
String enteredTxt = m_txtEditor.getText();
m_myModel.removeAll();
//so that initially the screen gets displayed with this field blank
//System.out.println("1 txt----------->" +m_txtEditor.getText());
m_myModel.addElement("");
//System.out.println("2 txt----------->" +m_txtEditor.getText());
for (int i=0; i<dictArray.length; i++) {
if (dictArray[i] != "" ) {
m_myModel.addElement(dictArray);
m_myModel.setSelectedItem(enteredTxt);
} // Comment till above to work atleast with pressing tab key twice.
m_txtEditor.addKeyListener( new KeyAdapter() {
public void keyPressed(KeyEvent e) {
m_isTextSelected = m_txtEditor.getSelectionStart() != m_txtEditor.getSelectionEnd();
public void keyReleased(KeyEvent e) {
char charPressed = e.getKeyChar();
int charCodePressed = e.getKeyCode();
if (charPressed == KeyEvent.CHAR_UNDEFINED) {
return;
if (charCodePressed == KeyEvent.VK_ENTER) {
//This is 2 restrict the dictionary lenght 2 the given limit
//remove this -1 if in SavePreference, def is "" instead of " "
//if (m_dict.size() - 1 == SIZEOFSELECTBOX) {
if (m_dict.size() == SIZEOFSELECTBOX) {
m_dict.removeEntry(m_dict.last().toString());
m_dict.addEntry(m_txtEditor.getText().toUpperCase());
//to put the user entered value into the combo in the same session of panel
if (null != m_myModel) {
String dictList = m_dict.getElementsList();
String[] dictArray = dictList.split("~");
m_myModel.removeAll();
//so that initially the screen gets displayed with this field blank
m_myModel.addElement("");
for (int i=0; i<dictArray.length; i++) {
if (dictArray[i] != "" ) {
m_myModel.addElement(dictArray[i]);
if (charCodePressed == KeyEvent.VK_DELETE) {
m_dict.removeEntry(m_txtEditor.getText());
//getSelectionStart() gives 0, as for a moment when Enter is pressed, the entire txt is selected.
//hence getCaretPosition is used
// if (m_txtEditor.getSelectionStart() != m_txtEditor.getSelectionEnd() && m_txtEditor.getSelectionEnd() != m_txtEditor.getCaretPosition()) {
// m_txtEditor.setText(m_txtEditor.getText().substring(0, m_txtEditor.getSelectionStart()));
if (m_txtEditor.getCaretPosition() != m_txtEditor.getSelectionEnd()) {
m_txtEditor.setText(m_txtEditor.getText().substring(0, m_txtEditor.getCaretPosition()));
String input = m_txtEditor.getText();
if (lookup(input) != null) {
m_txtEditor.setText(lookup(input));
m_txtEditor.setSelectionStart(input.length());
m_txtEditor.setSelectionEnd(m_txtEditor.getText().length());
m_isTextSelected = true;
else {
m_isTextSelected = false;
if (charCodePressed == KeyEvent.VK_BACK_SPACE
&& m_isTextSelected && input.length() > 0) {
m_txtEditor.setText(input.substring(0, input.length()));
/** used to search for the entered string in the dictionary list.
* @param str the string that is to be searched in the dictionary.
* @return the string from the dictionary that matches with the received str.
protected String lookup(String str) {
if (m_dict != null) {
return m_dict.lookup(str);
return null;

Can you post common part of the stack trace when Java goes into infinite loop?

Similar Messages

  • Empty field created - Jcombo Box strange problem

    Hi,
    I have a list of items in JCombo Box.
    view the list by clicking the drop down button in combo box.
    While the list is still visble hold the CTRL and SHIFT keys together and then choose an item
    the field selected becomes empty.
    Have anyone come across this.
    Thanks
    vijay...

    Can you post common part of the stack trace when Java goes into infinite loop?

  • Weird focus problems (& 1 workaround)

    I am building a wizard with an extension of JDialog. Based on earlier input, I create the JDialog with a bunch of JPanels each with a combobox and a textfield. I have a next, cancel, and back button at the bottom on its own panel. I also have a "Finish" button when I reach the last panel. So I have to change the buttonPanel by putting the finish button on at the end and I put the next button back on when coming back from the last panel.
    The problems I have been running into involve getting focus to one of the JTextfields mentioned above. I had a problem when I built my JDialog after clicking the next button. I removed everything from my ContentPane (cp) using cp.removeAll(). After building my JDialog, my code trys to give focus to the first text field. It wouldn't. I tested the text field and it is indeed focusable, visible, and displayable.
    The fix was removing each individual component from the content pane instead of doing the removeAll(). Then, after adding everything to the content pane, my textfield could grab the focus.
    The only problem that remains is with the back button. When I move back from the final panel the following code is executed:
    buttonPanel.removeAll();
    //buttonPanel.remove(backButton);
    //buttonPanel.remove(finalButton);
    //buttonPanel.remove(cancelButton);
    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(cancelButton);
    Then, as in other cases, the buttonPanel object is added to the content pane. This causes the textfield to be unable to grab focus. I commented out the code and the focus worked fine (but of course my buttonPanel was not correct).
    This is happening with 1.4.1 on windows 2000. I don't have another computer to test this one.
    Am I doing something inherently wrong or is this a bug?
    I've looked around and there are a lot of problems reported with focus and swing, but I wasn't sure if this was a symptom of those problems or if this is something different.
    I appreciate any help you can give.
    thanks,
    Geoff

    I won't throw everything at you but this should be plenty. If anyone needs any explanations I am not going anywhere. I'm trying to figure out if the problem is a bug or not.
    The workaround is mentioned in a comment for the action listener of nextButton. The problem piece of code that is mentioned at the top of this thread is also commented and it is part of the action listener for backButton.
    There are some declarations I have left out and I've left out some helper functions and some private classes, but I looked at it closely. There shouldn't be anything that is a mystery here. But, again, if anything is unclear just give a shout.
    thanks in advance,
    Geoff
    public InfoDialog(JFrame owner, int[] results)
         super(owner, "Wizard", true);
         cp = getContentPane();
         this.owner = owner;
         answers = results;
         lastPanel = answers.length-1;
         //figure out number of panels and last one greater than 0
         for(int i =0; i<answers.length; i++)
              numPanels++;
              if(answers>0)
                   lastPanel = i;
         if(numPanels==0)
              return;
         nameVectors = new Vector[answers.length];
         typeVectors = new Vector[answers.length];
         while(answers[currentPanel]<=0 && currentPanel<answers.length)
              currentPanel++;
         firstPanel = currentPanel;
         inputLabel = new JLabel();
         inputLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
         inputLabel.setText(getInputLabelText(currentPanel));
         panelArray = new JPanel[answers[currentPanel]];
         nameVectors[currentPanel] = new Vector();
         typeVectors[currentPanel] = new Vector();
         comboArray = new ClassComboBox[answers[currentPanel]];
         textArray = new StringTextField[answers[currentPanel]];
         for(int i=0; i<panelArray.length; i++)
              panelArray[i] = new JPanel();
              panelArray[i].setLayout(new BoxLayout(panelArray[i], BoxLayout.X_AXIS));
              comboArray[i] = new ClassComboBox();
              panelArray[i].add(comboArray[i]);
              textArray[i] = new StringTextField(new String(""));
              panelArray[i].add(textArray[i]);
         cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
         //cp.add(infoPanel);
         cp.add(inputLabel);
         for(int i=0; i<panelArray.length; i++)
              cp.add(panelArray[i]);
         //infoPanel = new JPanel();
         //infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.X_AXIS));
         //infoPanel.add(new ClassComboBox());
         //infoPanel.add(new StringTextField(new String("")));
         //cp.add(infoPanel);
         backButton = new JButton("Back");
         backButton.setEnabled(false);
         backButton.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent ae){
                   //save values of previous panel into vector
                   typeVectors[currentPanel] = null;
                   nameVectors[currentPanel] = null;
                   typeVectors[currentPanel] = new Vector();
                   nameVectors[currentPanel] = new Vector();
                   for(int i=0; i<panelArray.length; i++)
                        typeVectors[currentPanel].add((String)comboArray[i].getSelectedItem());
                        nameVectors[currentPanel].add(textArray[i].getText());
                   //remove everything from JDialog
                   //cp.removeAll();
                   cp.remove(inputLabel);
                   for(int i=0; i<panelArray.length; i++)
                        cp.remove(panelArray[i]);
                   cp.remove(buttonPanel);
                   //store last panel, figure out what the new currentPanel val is
                   int previousPanel = currentPanel;
                   currentPanel--;
                   while(answers[currentPanel]<=0 && currentPanel >= firstPanel)
                        currentPanel--;
                   //go through panelArray getting rid of its subcomponents
                   for(int i=0; i<panelArray.length; i++)
                        panelArray[i].removeAll();
                   panelArray = null;
                   comboArray = null;
                   textArray = null;
                   //arrays will be initialized to the appropriate length for the currentPanel
                   panelArray = new JPanel[answers[currentPanel]];                    
                   comboArray = new ClassComboBox[answers[currentPanel]];
                   textArray = new StringTextField[answers[currentPanel]];
                   //inputLabel.setText(pinTypes[currentPanel]);
                   inputLabel.setText(getInputLabelText(currentPanel));
                   cp.add(inputLabel);
                   for(int i=0; i<panelArray.length; i++)
                        panelArray[i] = new JPanel();
                        panelArray[i].setLayout(new BoxLayout(panelArray[i], BoxLayout.X_AXIS));
                        comboArray[i] = new ClassComboBox();
                        comboArray[i].setSelectedItem(typeVectors[currentPanel].get(i));
                        panelArray[i].add(comboArray[i]);
                        //textArray[i] = new StringTextField(new String(""));
                        textArray[i] = new StringTextField((String)nameVectors[currentPanel].get(i));
                        panelArray[i].add(textArray[i]);
                        cp.add(panelArray[i]);
                   //focus problem is caused by this block of code
                   //moving back from last panel
                   if((currentPanel == lastPanel-1) && previousPanel==lastPanel)
                        buttonPanel.removeAll();
                        //the following code did not fix the problem
                        //buttonPanel.remove(backButton);
                        //buttonPanel.remove(finalButton);
                        //buttonPanel.remove(cancelButton);
                        buttonPanel.add(backButton);
                        buttonPanel.add(nextButton);
                        buttonPanel.add(cancelButton);
                   if(currentPanel==firstPanel)
                        backButton.setEnabled(false);
                   cp.add(buttonPanel);
                   //System.out.println();
                   //System.out.println("textArray[0].isVisibile: " + textArray[0].isVisible());
                   //System.out.println("textArray[0].isDisplayable: " + textArray[0].isDisplayable());
                   //System.out.println("textArray[0].isFocusable: " + textArray[0].isFocusable());
                   //textArray[0].grabFocus();
                   pack();
                   //repaint();
                   System.out.println();
                   System.out.println("textArray[0].isVisibile: " + textArray[0].isVisible());
                   System.out.println("textArray[0].isDisplayable: " + textArray[0].isDisplayable());
                   System.out.println("textArray[0].isFocusable: " + textArray[0].isFocusable());
                   textArray[0].grabFocus();
         nextButton = new JButton("Next");
         nextButton.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent ae){
                   //logic to grab information from JComboBox and JTextField
                   typeVectors[currentPanel] = null;
                   nameVectors[currentPanel] = null;
                   typeVectors[currentPanel] = new Vector();
                   nameVectors[currentPanel] = new Vector();
                   for(int i=0; i<panelArray.length; i++)
                        typeVectors[currentPanel].add((String)comboArray[i].getSelectedItem());
                        nameVectors[currentPanel].add(textArray[i].getText());
                   //here is the code that didn't work and the subsequent code
                   //that fixed the problem
                   //cp.removeAll();
                   cp.remove(inputLabel);
                   for(int i=0; i<panelArray.length; i++)
                        cp.remove(panelArray[i]);
                   cp.remove(buttonPanel);
                   currentPanel++;
                   //System.out.println("currentPanel prior to processing: " + currentPanel);
                   if(currentPanel<(answers.length-1))
                        while(answers[currentPanel]<=0 && currentPanel<lastPanel)
                             currentPanel++;
                   for(int i=0; i<panelArray.length; i++)
                        panelArray[i].removeAll();
                        //comboArray[i].removeAll();
                        //textArray[i].removeAll();
                   panelArray = null;
                   comboArray = null;
                   textArray = null;
                   panelArray = new JPanel[answers[currentPanel]];
                   inputLabel.setText(getInputLabelText(currentPanel));
                   cp.add(inputLabel);
                   //test to see if this is the first time reaching this point
                   //if you haven't reached this point before, vector will be null
                   boolean firstTime = false;
                   if(nameVectors[currentPanel]==null)
                        firstTime = true;
                   if(firstTime)
                        nameVectors[currentPanel] = new Vector();
                        typeVectors[currentPanel] = new Vector();
                   comboArray = new ClassComboBox[answers[currentPanel]];
                   textArray = new StringTextField[answers[currentPanel]];
                   //establish the proper # of combo boxes & text fields
                   int len = panelArray.length;
                   for(int i=0; i<len; i++)
                        panelArray[i] = new JPanel();
                        panelArray[i].setLayout(new BoxLayout(panelArray[i], BoxLayout.X_AXIS));
                        comboArray[i] = new ClassComboBox();
                        if(!firstTime)
                             comboArray[i].setSelectedItem(typeVectors[currentPanel].get(i));
                        panelArray[i].add(comboArray[i]);
                        textArray[i] = new StringTextField();
                        if(!firstTime)
                             textArray[i].setText((String)nameVectors[currentPanel].get(i));
                        panelArray[i].add(textArray[i]);
                        cp.add(panelArray[i]);
                   if(currentPanel==lastPanel)
                        buttonPanel.removeAll();
                        buttonPanel.add(backButton);
                        buttonPanel.add(finalButton);
                        buttonPanel.add(cancelButton);
                   backButton.setEnabled(true);
                   cp.add(buttonPanel);
                   //textArray[0].requestFocus();
                   //System.out.println();
                   //System.out.println("textArray[0].isVisibile: " + textArray[0].isVisible());
                   //System.out.println("textArray[0].isDisplayable: " + textArray[0].isDisplayable());
                   //System.out.println("textArray[0].isFocusable: " + textArray[0].isFocusable());
                   //textArray[0].grabFocus();
                   pack();
                   //System.out.println();
                   //System.out.println("textArray[0].isVisibile: " + textArray[0].isVisible());
                   //System.out.println("textArray[0].isDisplayable: " + textArray[0].isDisplayable());
                   //System.out.println("textArray[0].isFocusable: " + textArray[0].isFocusable());
                   textArray[0].grabFocus();
         setLocationRelativeTo(owner);
         setVisible(true);          

  • JTextField focus problems in JApplet

    I have a JApplet like this:
    public class AppletLogin extends JApplet {
    public void init() {
    this.setSize(new Dimension(400,300));
    this.getContentPane().setLayout(new FlowLayout());
    this.getContentPane().add(new JTextField(12));
    this.getContentPane().add(new JTextField(12));
    The first problem I have is that both JTextField don't show the cursor if you click in them, they also don't show selected text. If you select another window and then you select back the browser, the cursor appears.
    The second problem is that sometimes, if the cursor appears in the first JTextField and with the TAB or with the mouse you set the focus on the second JTextField, then you can't focus back to the first JTextField. This second problem disappears if you add "this.requestFocus()" in init.
    This behaviour is shown in Windows NT 4.0 and 98 with Netscape 4.7 and 6.2.
    I don't have this problem in Windows 2000 - Netscape 4.7 / 6.2 and Linux - Netscape 6.2.
    The Plugin is 1.3.1_01a and 1.3.1_02.
    I think I have the same problem explained in bug 4186928 but with a JApplet. I have tried the "dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_ACTIVATED))" workaround, using the 'SwingUtilities.getWindowAncestor(this)' Window, but it doesn't
    work.
    Any suggestions to solve the first problem? Should I submit a bug?

    Of course. Here is the original code. I have only removed 'imports' from other classes of the project used for localization and image loading.
    If you want me to translate for you the Spanish comments to English, please tell me.
    This is the code as is now. I have already tried 'requestFocus' and 'grabFocus' even inside a MouseListener attached to 'usuario' (user) and 'clave' (passwd), with no success.
    This code works fine with 1.2.2 plug-in on any OS and with 1.3.1_02 plug-in on Windows 2000 and Linux.
    But with 1.3.1_02 plug-in under Windows 98/NT4.0 and Netscape 4.7/6.2 the focus is crazy. Our customer uses Windows NT 4.0.
    This panel is for user and passwd validation. We use it attached to an JApplet. It has some methods to attach ActionListener to it. It also has a KeyListener to capture 'intro' events. Thats all.
    package project.pkg
    import java.util.TooManyListenersException;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import javax.swing.border.EmptyBorder;
    // import of other.project.pkg
    // import of other.project.pkg
    import javax.swing.*;
    import java.awt.*;
      * Panel de acceso a la aplicaci�n.
      * @version  $Revision: 1.8 $
    public class PanelAcceso extends JRootPane {
       // Marca de revision. ///////////////////////////////
       private final static String VERSION = "@(#) $Id: PanelAcceso.java,v 1.8 2001/05/08 15:55:46 user Exp $";
       /** Campo usuario */
       private JTextField usuario;
       /** Campo clave */
       private JTextField clave;
       /** Panel de los controles */
       private JPanel controles;
       /** Panel auxiliar marco para controles. */
       private JPanel marco;
       /** ActionListener para notificaci�n de intro. de usuario y passwd */
       private ActionListener entrarActionListener = null;
        * Construye un panel de acceso.
       public PanelAcceso() {
         JLabel portada = new JLabel(/*HERE goes an ImageIcon*/);
         portada.setHorizontalAlignment( SwingUtilities.CENTER);
         portada.setVerticalAlignment( SwingUtilities.CENTER);
         getContentPane().setLayout( new BorderLayout());
         getContentPane().add( portada, BorderLayout.CENTER);
         getContentPane().setBackground( Color.white);
         controles = new JPanel();
         controles.setLayout(new GridLayout(4,2,5,5));
         controles.setOpaque(false);
         controles.add( new JLabel("Ver. 2.5.1"));
         controles.add(Box.createHorizontalGlue());
         controles.add(Box.createHorizontalGlue());
         controles.add(Box.createHorizontalGlue());
         controles.add( new JLabel("User") );
         usuario = new JTextField( 12);
         usuario.addKeyListener(keyListener);
         controles.add( usuario);
         controles.add( new JLabel("Passwd") );
         clave = new JPasswordField( 12);
         clave.addKeyListener(keyListener);
         controles.add( clave);
         // Panel auxiliar marco para controles.
         marco = new JPanel(new FlowLayout(FlowLayout.RIGHT));
         marco.setOpaque(false);
         marco.add(controles);
         setGlassPane(marco);
         // Listener para fijar el borde de marco seg�n cambie de
         // tama�o el panel.
         marco.addComponentListener( new ComponentAdapter() {
           public void componentResized(ComponentEvent e) {
             changeEmptyBorder();
           public void componentShown(ComponentEvent e) {
             changeEmptyBorder();
         marco.setVisible(true);
        * Devuelve el usuario introducido.
       public String getUser() {
         return usuario.getText();
        * Devuelve la contrase�a introducida.
       public String getPasswd() {
         return clave.getText();
        * Limpia el panel de acceso.
       public void limpiar() {
         clave.setText("");
         usuario.setText("");
        * A�ade un listiener a los eventos de
        * petici�n de acceso dado un usuario y
        * una contrase�a.
        * @throws TooManyListenersException si ya se ha a�adido un listener.
       public void addEntrarListener(ActionListener l) throws TooManyListenersException {
         if ((entrarActionListener != null) && (entrarActionListener != l))
           throw new TooManyListenersException("Solo se admite un listener");
         else
           entrarActionListener = l;
        * Borra un listener.
       public void removeEntrarListener(ActionListener l) {
         if (entrarActionListener == l)
           entrarActionListener = null;
         else
           throw new IllegalArgumentException("Intento de borrar un listener no a�adido");
        * Borra todos los listeners.
       public void removeEntrarListeners() {
         entrarActionListener = null;
        * Instancia privada de KeyListener para capturar
        * los 'enter' en los campos de usuario y passwd.
       private KeyListener keyListener = new KeyListener() {
          * Method to handle events for the KeyListener interface.
          * @param e KeyEvent
         public void keyPressed(KeyEvent e) {
           if (e.getKeyCode() != KeyEvent.VK_ENTER)
             return;
           if ((e.getSource() == usuario) )
             clave.requestFocus();
           else {
             requestFocus(); // Se evitan varias pulsaciones seguidas.
             if (entrarActionListener != null)
               entrarActionListener.actionPerformed(new ActionEvent(this, 0, ConstantesXigus.ACCION_ENTRAR));
         /** Method to handle events for the KeyListener interface. */
         public void keyReleased(KeyEvent e) {}
         /** Method to handle events for the KeyListener interface. */
         public void keyTyped(KeyEvent e) {}
        * Ajusta el borde del marco de controles para que aparezcan centrados.
       private void changeEmptyBorder() {
         Dimension dimMarco   = marco.getSize();
         Dimension dimInterno = controles.getPreferredSize();
         int altoBorde  = dimMarco.height - dimInterno.height;
         int anchoBorde = (dimMarco.width - dimInterno.width)/2;
         marco.setBorder( new EmptyBorder( (int)(altoBorde * 0.75), anchoBorde, (int)(altoBorde * 0.25), anchoBorde));
    }Thank you very much for your help

  • Calling1.4.1 signed applet from Javascript causes keyboard/focus problems

    Pretty sure there's a JRE bug here, but I'm posting to forums before I open one in case I'm missing something obvious :-)
    This issue may be specific to IE, I haven't tested elsewhere yet. Our web application is centered around a signed applet that is initialized with XML data via Javascript. We first noticed the problem when our users started upgrading from the 1.3.x plug-in to the 1.4.x plug-in. The major symptom was that shortcut keys stopped working. I debugged the problem off and on for about a month before I boiled it down to a very simple program that demonstrates the issue (included below). Basically, the program has a function that adds a JButton to a JPanel and registers a keyboard listener (using the new DefaultKeyboardFocusManager class) that prints a message to the console. This function is called by the applet's init() method, as well as by a public method that can be called from Javascript (called callMeFromJavascript()). I also included a very simple HTML file that provides a button that calls the callMeFromJavascript() method. You can test this out yourself: To recreate, compile the class below, JAR it up, sign the JAR, and put in the same dir with the HTML file. Load the HTML file in IE 5.0 or greater, and bring the console up in a window right next to it. Now click the button that says init--you should see the small box appear inside the button that indicates it has the focus. Now press some keys on your keyboard. You should see "KEY PRESSED!!!" appearing in the console. This is proper behavior. Now click the Init Applet from Javascript button. It has removed the button called init, and added one called "javascript". Press this button. Notice there is no focus occurring. Now press your keyboard. No keyboard events are registered.
    Where is gets interesting is that if you go back and make this an unsigned applet, and try it again, everything works fine. This bug only occurs if the applet is signed.
    Furthermore, if you try it in 1.3, signed or unsigned, it also works. So this is almost certainly a 1.4 bug.
    Anyone disagree? Better yet, anyone have a workaround? I've tried everything I could think of, including launching a thread from the init() method that sets up the components, and then just waits for the data to be set by Javascript. But it seems that ANY communication between the method called by Javascript and the code originating in init() corrupts something and we don't get keyboard events. This bug is killing my users who are very reliant on their shortcut keys for productivity, and we have a somewhat unique user interface that relies on Javascript for initialization. Any help or suggestions are appreciated.
    ================================================================
    Java Applet (Put it in a signed JAR called mainapplet.jar)
    ================================================================
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MainApplet extends JApplet implements KeyEventDispatcher
        JPanel test;
        public void init()
            System.out.println("init called");
            setUp("init");
        public void callMeFromJavascript()
            System.out.println("callMeFromJavascript called");
            setUp("javascript");
        private void setUp(String label)
            getContentPane().removeAll();
            test = new JPanel();
            getContentPane().add( test );
            JButton button = new JButton(label);
            test.add( button );
            test.updateUI();
            DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);
        public boolean dispatchKeyEvent(KeyEvent e)
            System.out.println("== KEY PRESSED!!! ==");
            return false;
    }================================================================
    HTML
    ================================================================
    <form>
    <APPLET code="MainApplet" archive="mainapplet.jar" align="baseline" id="blah"
         width="200" height="400">
         No Java 2 SDK, Standard Edition v 1.4.1 support for APPLET!!
    </APPLET>
    <p>
    <input type="button" onClick="document.blah.callMeFromJavascript();" value="Init Applet via Javascript">
    </form>

    I tried adding the requestFocus() line you suggested... Same behavior.
    A good thought, but as I mention in my description, the applet has no trouble gaining the focus initially (when init() is called). From what I have seen, it is only when the call stack has been touched by Javascript that I see problems. This is strange though: Your post gave me the idea of popping the whole panel into a JFrame... I tried it, and the keyboard/focus problem went away! It seems to happen only when the component hierarchy is descended from the JApplet's content pane. So that adds yet another variable: JRE 1.4 + Signed + Javascript + components descended from JApplet content pane.
    And yes, signed or unsigned DOES seem to make a difference. Don't ask me to explain why, but I have run this little applet through quite a few single variable tests (change one variable and see what happens). The same JAR that can't receive keyboard events when signed, works just fine unsigned. Trust me, I'm just as baffled as you are.

  • Shuffle problem going between 2000 and XP?

    I recently got my girlfriend a shuffle and it worked fine with my computer, which is running 2000 and has the latest iTunes updates and iPod updater. The only problem I have on my computer using her Shuffle or my Nano is the amount of songs I can transfer at once (which is usually 20, 10 on shuffle).
    Anyway, I'm not sure if Shuffle was the latest version out of the box or not, but it didn't need updating from my computer, unless it was automatic. She took it home to try it on her computer (running XP) and iTunes wanted to format it. I gave her the updates off the site (since she doesn't have internet) and told her to try them since I didn't think it was needed. She tried that and it still managed to screw it up. So I had her restore it and that worked, but she decided after she got it to work to plug it back in again to play with the songs and it had to be restored again and then restored a few more times after that.
    So I was wondering if there was anything I can do to fix it, like uninstall everything that deals with iPod and install the version that came with Shuffle then reinstall the new version over it along with the updater? Take it away because she's apparently bad with technology and have her only deal with my computer for updating her song list? Or was there another way to make it so she won't be restoring shuffle everytime she changes computers? Since I figure it should be compatible enough to go between different versions of windows with different versions of iTunes and still work with no problems.
      Windows 2000  

    That's probably it, since she didn't have any of the music because it was with me. From what I remember, she went around that, and used restore after she backed up all the music. But from what I remember it takes no time at all to a few minutes to restore my Nano, but the Shuffle doesn't have a screen to tell you what's going on (and I find the updater is unreliable with info sometimes).
    She has told me she did the same thing about 20 times before it started to work. So she must've been restoring and thinking 'this isn't doing anything' and ripped it out and eventually gave up and let it do it's thing.
    But I'll have to deal with it next time when she tries to sync it up with my iTunes, so maybe it won't be a big problem this time around.

  • Reader X - Firefox focus problem

    Since I first started using Adobe Reader X, I have had an intermittent keyboard focus problem with Firefox (mostly recently 3.6.14, on Windows 7). If I open a PDF document in a browser tab, sometimes keyboard focus is not returned to Firefox iteself. For instance, I may try to type something into the Firefox search box or URL box, but cannot get keyboard focus there: I cannot get a blinking cursor, though I can select the text there.
    I have not been able to duplicate this problem consistently.
    The workaround is to go to another application entirely, click to move focus there, and then return to Firefox.

    I don't know that "focus" is the right term to use, but I have the same exact problem. Do you have a scroll mouse? I've also noticed that when I scroll within an instance of Adobe Reader that's opened in Firefox using the scroll button on my mouse that the scroll bar does not register the change until I move my cursor over it, then the bar will jump to where it's supposed to be. This is really annoying because I can't quickly judge how far along I am in a .pdf.

  • Trying to add a JCombo Box to a tutorial app

    I am very new to Java and am looking to add a JCombo Box to this tutorial I am working on. Not having much luck with it.
    Can anyone help, I would appreciate it.
    Here is my code, Sorry about the length of it
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Space extends JFrame implements ActionListener
         // ******************************** DECLARE MY COMPONENTS *******************
         private JButton myActive = new JButton("Activate Probe");
         private JButton myLaunch = new JButton("Launch Probe");
         String[] planetList = { "Mars", "Earth", "Saturn"};
         JComboBox myPlanets = new JComboBox(this);
         private JTextArea myTextArea;
         private JScrollPane myScrollPane = new JScrollPane(myTextArea = new JTextArea());
         public Space()
              // ******************************** DEFAULT VARIABLES ******************
              setTitle("PROBE PROJECT");
              getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT));
              // ******************************** SET THE PROPERTIES *******************
              myScrollPane.setPreferredSize(new Dimension(250,300));
              myTextArea.setWrapStyleWord(true);
              myTextArea.setLineWrap(true);
              // ******************************** ADD COMPONENTS TO CONTENT PANE *******************          
              getContentPane().add(myScrollPane);
              getContentPane().add(myActive);
              getContentPane().add(myLaunch);
              getContentPane().add(myPlanets);
              // ******************************** REGISTER LISTENERS ********************************
              myActive.addActionListener(this);
              myLaunch.addActionListener(this);
              planetList.addActionListener(this);
         public void actionPerformed(ActionEvent myEvent)
              Space p;
              p = new Space();
              if (myEvent.getActionCommand().equals("Activate Probe"))
                   myTextArea.append("activated\n");
              } else if (myEvent.getActionCommand().equals("Launch Probe")) {     
                   myTextArea.append("launched\n");                              
         public static void main(String[] args)
              Space myFrame = new Space();
              myFrame.setSize(300, 500);
              myFrame.setVisible(true);
              myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    String[] planetList = { "Mars", "Earth", "Saturn"};
    // JComboBox myPlanets = new JComboBox(this);
    JComboBox myPlanets = new JComboBox(planetList);And
    // planetList.addActionListener(this);
    myPlanets.addActionListener(this);
    // although you may need other listeners, changeListener I think...And a few pointers for next time you post:
    - Post code between [ code ] and [ /code ] tags.
    - Clearly explain your problem. It's not working is not clear enough. In this case, showing the compiler errors would have been handy.
    And this isn't a long post, believe me.
    Cheers,
    Radish21

  • Focus Problem on Solaris with jdk 1.3.1

    Hi all,
    We are having a focus problem on Solaris. The same code works fine on Windows without any problem.
    I am sending the test code and run steps below which you can compile and repeat the problem.
    NOTE: When we put a comment on the line "f1.requestFocus();" in TestFocus.java it works OK.
    Run Steps :
    1. Run TestFocus.class
    2. A JFrame appears with 2 text field and a button
    3. Try to write something on the text fields. It works OK.
    4. Click the button to open a new JFrame
    5. A new JFrame opens with a single text field and a button.
    6. Click the button to close the second frame
    7. You are now on the main JFrame
    8. Try to write something on the text fields. It works OK.
    9. Repeat the steps 4-7
    10. Try to write something on the text fields. You are able to focus and write on the first field. BUT you cannot select or write the second Field!
    JAVA SOURCE FILES :
    PenHesapListener.java :
    public interface PenHesapListener extends java.util.EventListener {
    void tamam_actionPerformed(java.util.EventObject newEvent);
    void iptal_actionPerformed(java.util.EventObject newEvent);
    ------PenHesapLisEventMulticaster.java----------------------------------
    public class PenHesapLisEventMulticaster extends java.awt.AWTEventMulticaster implements PenHesapListener {
    * Constructor to support multicast events.
    * @param a java.util.EventListener
    * @param b java.util.EventListener
    protected PenHesapLisEventMulticaster(java.util.EventListener a, java.util.EventListener b) {
         super(a, b);
    * Add new listener to support multicast events.
    * @return muhasebe.HesappenListener
    * @param a muhasebe.HesappenListener
    * @param b muhasebe.HesappenListener
    public static PenHesapListener add(PenHesapListener a, PenHesapListener b) {
         return (PenHesapListener)addInternal(a, b);
    * Add new listener to support multicast events.
    * @return java.util.EventListener
    * @param a java.util.EventListener
    * @param b java.util.EventListener
    protected static java.util.EventListener addInternal(java.util.EventListener a, java.util.EventListener b) {
         if (a == null) return b;
         if (b == null) return a;
         return new PenHesapLisEventMulticaster(a, b);
    * @return java.util.EventListener
    * @param oldl muhasebe.HesappenListener
    protected java.util.EventListener remove(PenHesapListener oldl) {
         if (oldl == a) return b;
         if (oldl == b) return a;
         java.util.EventListener a2 = removeInternal(a, oldl);
         java.util.EventListener b2 = removeInternal(b, oldl);
         if (a2 == a && b2 == b)
              return this;
         return addInternal(a2, b2);
    * Remove listener to support multicast events.
    * @return muhasebe.HesappenListener
    * @param l muhasebe.HesappenListener
    * @param oldl muhasebe.HesappenListener
    public static PenHesapListener remove(PenHesapListener l, PenHesapListener oldl) {
         if (l == oldl || l == null)
              return null;
         if(l instanceof PenHesapLisEventMulticaster)
              return (PenHesapListener)((PenHesapLisEventMulticaster) l).remove(oldl);
         return l;
    public void tamam_actionPerformed(java.util.EventObject newEvent) {
         ((PenHesapListener)a).tamam_actionPerformed(newEvent);
         ((PenHesapListener)b).tamam_actionPerformed(newEvent);
    public void iptal_actionPerformed(java.util.EventObject newEvent) {
         ((PenHesapListener)a).iptal_actionPerformed(newEvent);
         ((PenHesapListener)b).iptal_actionPerformed(newEvent);
    ---------TestFocus2.java-----------------------------------------
    import javax.swing.*;
    import javax.swing.JOptionPane;
    import java.awt.event.WindowAdapter;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    import java.text.SimpleDateFormat;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.Color;
    import java.util.Locale;
    import java.util.ResourceBundle;
    public class TestFocus2 extends JFrame implements ActionListener
         protected transient PenHesapListener PenhListener = null ;
         JTextField f10 = null;
         JButton b10= null ;
         JTextField f1 = new JTextField() ;
         JButton b1 = new JButton() ;
         JFrame f20 = null;
         public TestFocus2()
              getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
              getContentPane().add(f1);
              getContentPane().add(b1);
              pack();
              setVisible(true);
              b1.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == b1)
                   fireTamam_actionPerformed(e);
         public void addPenHesapListener(PenHesapListener newListener)
              PenhListener = PenHesapLisEventMulticaster.add(PenhListener, newListener);
              return;
         protected void fireTamam_actionPerformed(java.util.EventObject newEvent) {
              PenhListener.tamam_actionPerformed(newEvent);
              this.setVisible(false);
         protected void fireiptal_actionPerformed(java.util.EventObject newEvent) {
              PenhListener.iptal_actionPerformed(newEvent);
         public static void main(String x[])
              TestFocus2 gen01 = new TestFocus2();
    --------TestFocus.java-----------------------------------
    import javax.swing.*;
    import javax.swing.JOptionPane;
    import java.awt.event.WindowAdapter;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    import java.text.SimpleDateFormat;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.Color;
    import java.util.Locale;
    import java.util.ResourceBundle;
    import java.awt.Container;
    public class TestFocus extends JFrame implements ActionListener
         PenKreKart aPenKreKart = null ;      
         Container ctn = null;
         JTextField f10 = null;
         JButton b10= null ;
         JTextField f1 = new JTextField() ;
         JTextField f2 = new JTextField() ;
         JButton b1 = new JButton() ;
         JFrame f20 = null;
         public TestFocus()
              //aPenKreKart = new PenKreKart(true);
              //aPenKreKart.aTemelPencere.setVisible(false);
              getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
              getContentPane().add(f1);
              getContentPane().add(f2);
              getContentPane().add(b1);
              pack();
              setVisible(true);
              b1.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == b1)
                   pencere_islemi();
         // pencere koyma k?sm? .. begin                               
         public void pencere_islemi() {     
              ctn = this;
              ctn.setEnabled(false);
              TestFocus2 fpen = new TestFocus2();
              //aPenKreKart.aTemelPencere.setVisible(true); //buras?          
              //aPenKreKart.aTemelPencere.addPenHesapListener(new PenHesapListener() {
              fpen.addPenHesapListener(new PenHesapListener() {
                        // metod      tamam_actionPerformed begin...          
                        public void tamam_actionPerformed(java.util.EventObject newEvent) {
                             ctn.setEnabled(true);
                             ctn.requestFocus();
                             // Problem is when we comment the below line it works .....
                             f1.requestFocus();
                             System.out.println("tamam");
                        // metod      tamam_actionPerformed end...          
                        // metod      iptal_actionPerformed begin...          
                        public void iptal_actionPerformed(java.util.EventObject newEvent) {
                             ctn.setEnabled(true);
                             ctn.requestFocus();
                             System.out.println("iptal");
                        // metod      iptal_actionPerformed begin...          
         // pencere koyma k?sm? .. end                               
         public static void main(String x[])
              TestFocus gen01 = new TestFocus();

    Hi all,
    We are having a focus problem on Solaris. The same code works fine on Windows without any problem.
    I am sending the test code and run steps below which you can compile and repeat the problem.
    NOTE: When we put a comment on the line "f1.requestFocus();" in TestFocus.java it works OK.
    Run Steps :
    1. Run TestFocus.class
    2. A JFrame appears with 2 text field and a button
    3. Try to write something on the text fields. It works OK.
    4. Click the button to open a new JFrame
    5. A new JFrame opens with a single text field and a button.
    6. Click the button to close the second frame
    7. You are now on the main JFrame
    8. Try to write something on the text fields. It works OK.
    9. Repeat the steps 4-7
    10. Try to write something on the text fields. You are able to focus and write on the first field. BUT you cannot select or write the second Field!
    JAVA SOURCE FILES :
    PenHesapListener.java :
    public interface PenHesapListener extends java.util.EventListener {
    void tamam_actionPerformed(java.util.EventObject newEvent);
    void iptal_actionPerformed(java.util.EventObject newEvent);
    ------PenHesapLisEventMulticaster.java----------------------------------
    public class PenHesapLisEventMulticaster extends java.awt.AWTEventMulticaster implements PenHesapListener {
    * Constructor to support multicast events.
    * @param a java.util.EventListener
    * @param b java.util.EventListener
    protected PenHesapLisEventMulticaster(java.util.EventListener a, java.util.EventListener b) {
         super(a, b);
    * Add new listener to support multicast events.
    * @return muhasebe.HesappenListener
    * @param a muhasebe.HesappenListener
    * @param b muhasebe.HesappenListener
    public static PenHesapListener add(PenHesapListener a, PenHesapListener b) {
         return (PenHesapListener)addInternal(a, b);
    * Add new listener to support multicast events.
    * @return java.util.EventListener
    * @param a java.util.EventListener
    * @param b java.util.EventListener
    protected static java.util.EventListener addInternal(java.util.EventListener a, java.util.EventListener b) {
         if (a == null) return b;
         if (b == null) return a;
         return new PenHesapLisEventMulticaster(a, b);
    * @return java.util.EventListener
    * @param oldl muhasebe.HesappenListener
    protected java.util.EventListener remove(PenHesapListener oldl) {
         if (oldl == a) return b;
         if (oldl == b) return a;
         java.util.EventListener a2 = removeInternal(a, oldl);
         java.util.EventListener b2 = removeInternal(b, oldl);
         if (a2 == a && b2 == b)
              return this;
         return addInternal(a2, b2);
    * Remove listener to support multicast events.
    * @return muhasebe.HesappenListener
    * @param l muhasebe.HesappenListener
    * @param oldl muhasebe.HesappenListener
    public static PenHesapListener remove(PenHesapListener l, PenHesapListener oldl) {
         if (l == oldl || l == null)
              return null;
         if(l instanceof PenHesapLisEventMulticaster)
              return (PenHesapListener)((PenHesapLisEventMulticaster) l).remove(oldl);
         return l;
    public void tamam_actionPerformed(java.util.EventObject newEvent) {
         ((PenHesapListener)a).tamam_actionPerformed(newEvent);
         ((PenHesapListener)b).tamam_actionPerformed(newEvent);
    public void iptal_actionPerformed(java.util.EventObject newEvent) {
         ((PenHesapListener)a).iptal_actionPerformed(newEvent);
         ((PenHesapListener)b).iptal_actionPerformed(newEvent);
    ---------TestFocus2.java-----------------------------------------
    import javax.swing.*;
    import javax.swing.JOptionPane;
    import java.awt.event.WindowAdapter;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    import java.text.SimpleDateFormat;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.Color;
    import java.util.Locale;
    import java.util.ResourceBundle;
    public class TestFocus2 extends JFrame implements ActionListener
         protected transient PenHesapListener PenhListener = null ;
         JTextField f10 = null;
         JButton b10= null ;
         JTextField f1 = new JTextField() ;
         JButton b1 = new JButton() ;
         JFrame f20 = null;
         public TestFocus2()
              getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
              getContentPane().add(f1);
              getContentPane().add(b1);
              pack();
              setVisible(true);
              b1.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == b1)
                   fireTamam_actionPerformed(e);
         public void addPenHesapListener(PenHesapListener newListener)
              PenhListener = PenHesapLisEventMulticaster.add(PenhListener, newListener);
              return;
         protected void fireTamam_actionPerformed(java.util.EventObject newEvent) {
              PenhListener.tamam_actionPerformed(newEvent);
              this.setVisible(false);
         protected void fireiptal_actionPerformed(java.util.EventObject newEvent) {
              PenhListener.iptal_actionPerformed(newEvent);
         public static void main(String x[])
              TestFocus2 gen01 = new TestFocus2();
    --------TestFocus.java-----------------------------------
    import javax.swing.*;
    import javax.swing.JOptionPane;
    import java.awt.event.WindowAdapter;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    import java.text.SimpleDateFormat;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.Color;
    import java.util.Locale;
    import java.util.ResourceBundle;
    import java.awt.Container;
    public class TestFocus extends JFrame implements ActionListener
         PenKreKart aPenKreKart = null ;      
         Container ctn = null;
         JTextField f10 = null;
         JButton b10= null ;
         JTextField f1 = new JTextField() ;
         JTextField f2 = new JTextField() ;
         JButton b1 = new JButton() ;
         JFrame f20 = null;
         public TestFocus()
              //aPenKreKart = new PenKreKart(true);
              //aPenKreKart.aTemelPencere.setVisible(false);
              getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
              getContentPane().add(f1);
              getContentPane().add(f2);
              getContentPane().add(b1);
              pack();
              setVisible(true);
              b1.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == b1)
                   pencere_islemi();
         // pencere koyma k?sm? .. begin                               
         public void pencere_islemi() {     
              ctn = this;
              ctn.setEnabled(false);
              TestFocus2 fpen = new TestFocus2();
              //aPenKreKart.aTemelPencere.setVisible(true); //buras?          
              //aPenKreKart.aTemelPencere.addPenHesapListener(new PenHesapListener() {
              fpen.addPenHesapListener(new PenHesapListener() {
                        // metod      tamam_actionPerformed begin...          
                        public void tamam_actionPerformed(java.util.EventObject newEvent) {
                             ctn.setEnabled(true);
                             ctn.requestFocus();
                             // Problem is when we comment the below line it works .....
                             f1.requestFocus();
                             System.out.println("tamam");
                        // metod      tamam_actionPerformed end...          
                        // metod      iptal_actionPerformed begin...          
                        public void iptal_actionPerformed(java.util.EventObject newEvent) {
                             ctn.setEnabled(true);
                             ctn.requestFocus();
                             System.out.println("iptal");
                        // metod      iptal_actionPerformed begin...          
         // pencere koyma k?sm? .. end                               
         public static void main(String x[])
              TestFocus gen01 = new TestFocus();

  • Focus problem since jre 1.4.2_11

    Hi,
    I have a awkward focus problem with my java applet. Everything is working fine for jre 1.4.2_10 and all older jre.
    The applet is embedded in a large DHTML application running in a shell which uses the internet explorer for rendering. The applet communicates with the sorrounding java script via LiveConnect (JSObjects). We do use the static versioning, in order to determine the adaequate vm version. The controls are all based upon the swing controls, some are a bit modified.
    Since the introduction of jre 1.5 update 6 the static versioning does no longer work properly. So, when I run my applet with 1.4.2_11 and all the predecessors a strange focus problem occurs.
    When I click outside the applet (focus lost) and the click on a jscript control to get back the focus to the applet, the keyboard input does not reach the applet. The comboboxes do not work anymore. A mouse click is recognized, but the data-list which should appear is only flickering for a moment.
    The only way to get the focus back, is to make a mouseclick on a selfmade datepicker (based on swing, implemeted like a popup-window). For sure, the large DHTML application is guilty, but definitely diffrent VM versions do behave differntly.
    Does anyone has an idea, has seen similar effects or knows what has been changed in the jre between 1.4.2_10 and 1.4.2_11 ??
    Any hint is appeciated! I am lost :-(((
    cheers thorsten

    Two things: Is there a document detailing manual removal of this JRE (and indeed others); you mention different 'builds' of the same JRE, this is the first time I have read that there are sub-versions/releases of a JRE. Where do I find out the available builds of this JRE and others and how they differ?

  • How can I add multi columns to a JCombo Box ?

    Dear experts,
    How can I add multi columns to a JCombo Box ?
    Thankx in advance
    Unique

    What do you mean by adding Multiple columns? JCombobox is a component in which you can choose a value from a list(rows) of values. Could you please explain why do you want multiple columns in the JComboBox. I suppose JComboBox is not meant for that.
    Thanks,
    Jana

  • How to load data from text.txt fiel and tokenize it into JCombo box???

    Hi Everyone,
    I am new to Java and Netbeans. I am working on the same GUI project and need your Help!!
    I have two queries and since i am new,please if possible explain step by step
    1.) How can I load the contents of data stored in sometext.txt file when i click the JCombo box]?? Also, if i enter a new string not existing in text, it should display a message and add the new entered data into the sometext.txt file.
    2.) How can i input the contents of table.txt file (which has characters seperated by Tab) into a JTable into specific rows and columns??. Again, the txt should add and update the new entered data.
    I dont want to use any databse connection!!
    Explainations with Examples/Attachments will be greatly and truly appreciated
    Please Please Help me ASAP as i have to submit this assignment by next week!!

    hi camickr,
    I tried to load a file into Jtable. I have used random access file method to read a large text file seperated by tabs. When i tried to run the file, i was unable to load the data from the file. i guess i am missing the link between custom table and the default table. Can you please help me?
    The complete code is attached below:.(The reason i am attaching the whole code is ..so that you can check me where i am going wrong, please dont mind!!)
    package javaapplication;
    import java.io.*;
    import java.util.ArrayList;
    import javax.swing.table.AbstractTableModel;
    public class table extends javax.swing.JFrame {
    /** Creates new form table */
    public class FileTableModel extends AbstractTableModel {
    RandomAccessFile raf;
    ArrayList<Long> lineToPos = new ArrayList<Long>();
    int columnCount = -1;
    public FileTableModel(String fileName) {
    try {
    raf = new RandomAccessFile(new File(fileName), "C://temp.txt");
    lineToPos.add(new Long(0));
    String line = null;
    while ((line = raf.readLine()) != null) {
    if (columnCount == -1)
    columnCount = line.split(" ").length;
    lineToPos.add(new Long(raf.getFilePointer()));
    lineToPos.remove(lineToPos.size()-1);
    } catch (Exception e) {
    e.printStackTrace();
    protected void finalize() throws Throwable {
    super.finalize();
    raf.close();
    public int getColumnCount() {
    return columnCount;
    public int getRowCount() {
    return lineToPos.size();
    public Object getValueAt(int rowIndex, int columnIndex) {
    try {
    raf.seek(lineToPos.get(rowIndex).longValue());
    String line = raf.readLine();
    String[] strs = line.split(" ");
    return strs[columnIndex];
    } catch (IOException e) {
    e.printStackTrace();
    return null;
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTable1.setModel(jTable1.getModel());
    jScrollPane1.setViewportView(jTable1);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(15, Short.MAX_VALUE))
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(14, Short.MAX_VALUE))
    pack();
    }// </editor-fold>
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new table().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JTable jTable1;
    // End of variables declaration
    }

  • Significant Computer Window Focus Problem With Verizon Access Manager 7.7.1.0 (2707e)

    With the newly released Verizon Access Manager 7.7.1.0 (2707e) there is a significant computer focus problem with it.
    What I mean by this is that if I am using ANY application on my computer with the Verizon Access Manager minimized to the Windows System Tray, something will go on with the Verizon Access Manager and it steals the window focus - I am unable to work in the other application unless I click on the application to use it again.  
    An example of this would be my typing to post a message in this forum.  Something occurs in the Verizon Access Manager and my typing is rendered useless unless I click with my mouse on the browser window to be able to use it again.
    I'm highly suspecting whenever networks are coming and going in the Access Manager is when the problem occurs.
     This problem did not exist in the previous version of the Access Manager I was using.
    This is extremely annoying - please issue a fix for this ASAP!

    I have found by not minimzing the Verizon Access Manager 7.7.1.0 (2707e) the focus problem does not occur - it appears to be a problem when the app is minimzed to the system tray.

  • Oracle 8i EE Install problems on Windows 2000

    Problem 1 - LENGTH OF INSTALL FILES PATH.
    The Oracle Universal Installer was coming up fine, but the "Next" button wouldn't do anything. After much trial and error, I discovered this to be related to the path of the install files. Rather than burning to CD, I had copied the install files into a directory C:\ORA816 - when I renamed this directory to just C:\O, the "Next" magically began working. This problem only occurs on Windows 2000, not NT4.
    Problem 2 - CREDENTIAL RETRIEVAL FAILED.
    I got this error (ORA-12638) from the Database Configuration Assistant. This just happened, so I haven't had a chance to figure it out. Has anyone encountered/fixed this problem in Windows 2000? I am running the install as Administrator.
    null

    Re: Problem 2. Just found out that this problem is resolved by removing the line SQLNET.AUTHENTICATION_SERVICES from
    %ORACLE_HOME%\network\admin\sqlnet.ora
    (see: http://technet.oracle.com//tech/migration/workbench/htdocs/relnotes.htm)

  • Focus Problem on the t3i

    My t3i is having focusing problems. What can be the cause?  Can I fine to the focus like on the fullframe cameras?
    Solved!
    Go to Solution.

    Kolourl3lind wrote:
    OK I will but I just relized maybe it's because I am zooming after focusing and recomposing?
    Yep - most lenses are "varifocal" -- meaning that if you carefully focus on a subject at some specific focal length in the zoom range... then zoom to a new focal length, then your subject will no longer be accurately focus.  You must re-focus the lens.
    There are a few lenses which are "parfocal" -- mean that if you zoom the focal length after focusing, your subject will still be accurately focused.  However... VERY FEW lenses are technically "parfocal" (though some are close).
    The lenses that I'm aware of which are "parfocal" are:
    EF 16-135mm f/2.8L USM
    EF 17-40mm f/4L USM
    EF 70-200mm f/2.8L USM (only the non-IS version)
    That's it.  If you use any other lens, you have to re-focus the lens after zooming.
    But I also notice you were shooting at 1/15th sec.  That's a bit slow but you were at 18mm (which helps.)  Here's the guideline on that.
    In the 35mm days, there used to be a general guideline that if the shutter speed is equal to or faster than 1/focal-length (e.g. if shooting at 50mm the you'd want to be at least 1/50th sec.... at 70mm you'd want to be at least 1/70th or faster, etc.) would be adequate.  This number doesn't apply to your T3i, but I'll get to that in a moment.
    But there are a few caveats with that...
    First, It assumes you are actually using very good camera-holding technique and you are actually TRYING to be steady.  Good camera-holding technique means you are supporting the camera from below -- typically your left is palm-up supporting the bottom of the camera and lens and your elbow is in toward your chest/stomach.    Your body weight is centered between your legs and you have a wide stance.  This means you are not leaning so your muscles don't have to work hard to keep you upright and your arms work like a brace to support the camera to your body and of course your body is nicely balanced and stable.  
    Second, It's just a "guideline" -- not a rule.  Some people are noticeably able to be more steady than others (and if caffiene makes you jittery and you just drank a coffee... and all that sort of thing.)  And sometimes it takes a bit of practice to learn good technique.  
    Third, It's also not the same for APS-C size sensor cameras (like your T3i).  For that camera, you'd have to multiple the minimum speed by the crop factor of the camera.  For a Canon APS-C camera it's 1.6 (but if you wanted to use 1.5 that'd be pretty close.)  That means at 50mm instead of using 1/50th you'd actually have to use 1/75th (technically 1/80th if we use the 1.6 factor).  e.g. 50 x 1.6 = 80 so for 50mm we'd use 1/80th.
    If you have a lens that includes image stabilization, then you may be able to shoot a bit slower.
    Most image stabilization claims to improve lens stability by 2 to 4 "stops".  What that means it that you can reduce the speed of the shutter... two to four times slower than you'd normally need because the lens is stabilizing for you.   But more caveats apply because it's not as simple as "you get 4 stops".  The stabilization isn't a guarantee... it's just a liklihood.  If it has to be less ambitious to stabilize your shot it will be far more likely to succeed.  If it has to be more ambitious to stabilize your shot then it'll do it's best... but there's no guarantee that it will work.
    You were shooting at 18mm.  So if you are using excellent posture and camera-holding technique but don't have image stabilization and you're the "average" person trying to hold the camera steady, then we multiply 18 x 1.6 and get 28.8.  There is no 1/28.8th shuter speed so we'll round that to 1/30th (because there is a 1/30th.  
    1 stop slower than 1/30th is 1/15th.. and the image stabilization probably is adequate to get you 1 stop slower successfully.
    2 stops slower is 1/8th.  Image stabilization that claims "4 stops" will usually do well at 2 stops.  So this is less of a sure-fire thing, but it does tilt the odds in your favor.
    3 stops slower is 1/4 sec.  At this point you're pushing the image stabilization system... you'll notice that if you shoot a lot of frames, that the "keeper" rate (good shots you like) will be lower, but you'll see that you are getting some.
    4 stops slower is 1/2 sec (based on the base of 1/30th for an 18mm focal length on an APS-C size sensor camera).  If you push any image stabilized lens to 4 stops, do not expect to get a very high keeper rate.  It'll sometimes help you, but you have to accept that you're really being ambitious in your expectations.
    That's image stabilization by the numbers... take the focal length, multiply it by your crop factor (which is always 1.6 but if you want to use 1.5 because it's a bit easier to do that math in our head it's close enough), round up to the nearest shutter speed available.  If you have image stabilization you can speed up the shutter speed by 1, 2, 3, or 4 times faster... but each time you get more ambitious your odds of getting "keepers" go down (but it's still better than no image stabilization at all.)
    The summary is that your minimum shutter speed (assuming good holding technique and that you are steady, etc. etc.) with image stabilization OFF the 1/30th would be your minimum speed.  At 1/15h sec you were relying on 1 stop of image stabilization help.  The image stabilization technology in the lens is good enought that "most of the time" it probably will be able to do this (not guaranteed... just likely.)  If you were NOT using good posture and holding technique... you may be challenging your image stabilization system to try to keep up.
    Tim Campbell
    5D II, 5D III, 60Da

Maybe you are looking for