Focus problems for a JTextField in a JTable

Hi,
I have a textfield that is inside of a JPanel and placed in a table cell. The textfield doesn't fill both horizontally and vertically inside the table cell like it normally would. The problem I am encountering is this:
When I click on the cell and I am outside the bounds of the textfield, the textfield cannot grab the focus and let me start typing away. How can I get it so that if i click on the cell ( but outside the bounds of the textfield ) that it knows i'm in that cell and give the focus to the textfield?
If it was me, i wouldn't have the textfield inside a jpanel and I would let it fill the whole cell but the client doesn't want that. They want the textfield set at a certain size and with proper padding around it. That means that only a portion of the cell has the textfield. Somehow I need the table to figure out that the cell was selected but outside of the textfield and then have it be smart enough to know this and switch focus to the textfield so I can start typing. I can post my code if someone needs to see what I am doing.
Thanks ahead of time.

Take a look at Component.setFocusTraversalKeysEnabled() (which exists only in jdk 1.4).
Setting this to false may solve your problem.

Similar Messages

  • Renderer problem for a JButton in a JTable

    Hi all,
    Here is my requirement -
    When the value of a particular cell in a JTable gets changed, another cell in the same selected row should display a JButton. The button should remain displayed for that row. Other rows should not have the button displayed unless there is any change in value of other columns in that row.
    I have the problem in displaying the button only when the values of a particular row is changed. The button gets displayed if I click that button cell which should not happen as the values are not changed for the corresponding row. Also, once the button is displayed for a particular row, if i click some other row, button gets disappeared for the previously selected row.
    Here is the code I have implemented. Please correct me where I am going wrong.
    Renderer code for the button-
    ==================
    class ButtonRenderer extends JButton implements TableCellRenderer {
    public ButtonRenderer() {
    setOpaque(true);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
    if (isSelected) {
    setForeground(table.getSelectionForeground());
    setBackground(table.getSelectionBackground());
    } else{
    setForeground(table.getForeground());
    setBackground(UIManager.getColor("Button.background"));
    TableModel model = table.getModel();
    // get values from the table model's selected row and specific column
    if(// check if values are changed from old ones)
    setText("Undo");
    setVisible(true);
    return (JButton) value;
    else
    JButton button = new JButton("");
    button.setBackground(Color.white);
    button.setBorderPainted(false);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setEnabled(false);
    return button;
    Editor code for the button -
    =======================
    class ButtonCellEditor extends DefaultCellEditor
    public ButtonCellEditor(JButton aButton)
    super(new JTextField());
    setClickCountToStart(0);
    aButton.setOpaque(true);
    aButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    fireEditingStopped();
    editorComponent = aButton;
    protected void fireEditingStopped()
    super.fireEditingStopped();
    public Object getCellEditorValue()
    return editorComponent;
    public boolean stopCellEditing()
    return super.stopCellEditing();
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
    return editorComponent;
    Code setting the renderer/editor -
    ==================================
    TableColumn column = colModel.getColumn(6);
    button.setVisible(true);
    button.setEnabled(true);
    column .setCellRenderer(new ButtonRenderer());
    column .setCellEditor(new ButtonCellEditor(button));
    Please correct me where I am going wrong.
    Thanks in advance!!

    Hope this is what you want...edit the column "Value" and type "Show" to get the desired result.
    import java.awt.Component;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.DefaultCellEditor;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.DefaultTableCellRenderer;
    public class TableEdit2 extends JFrame
         Object[] columns =
         { "A", "Value", "Action" };
         Object[][] data =
         { "A0", "B0", "" },
         { "A1", "B1", "" },
         { "A2", "B2", "" },
         { "A3", "B3", "" },
         { "A4", "B4", "" },
         { "A5", "B5", "" },
         { "A6", "B6", "" },
         { "A7", "B7", "" },
         { "A8", "B8", "" },
         { "A9", "B9", "" },
         { "A10", "B10", "" },
         { "A11", "B11", "" } };
         JTable table = null;
         public TableEdit2()
              super("Table Edit");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              createGUI();
              setLocationRelativeTo(null);
              setSize(400, 300);
              setVisible(true);
         private void createGUI()
              table = new JTable(data, columns)
                   public void setValueAt(Object value, int row, int column)
                        super.setValueAt(value, row, column);
                        ((AbstractTableModel) table.getModel()).fireTableRowsUpdated(
                                  row, row);
              table.getColumn("Action").setCellRenderer(new ButtonRenderer());
              table.getColumn("Action").setCellEditor(new MyTableEditor(new JTextField()));
              JScrollPane sc = new JScrollPane(table);
              add(sc);
         class ButtonRenderer extends DefaultTableCellRenderer
              JButton undoButton = new JButton("Undo");
              public ButtonRenderer()
                   super();
              public Component getTableCellRendererComponent(JTable table,
                        Object value, boolean isSelected, boolean hasFocus, int row,
                        int column)
                   Component comp = super.getTableCellRendererComponent(table, value,
                             isSelected, hasFocus, row, column);
                   if (column == 2)// The Action Column
                        Object checkValue = table.getValueAt(row, 1);
                        if ("Show".equals(String.valueOf(checkValue)))
                             return undoButton;
                   return comp;
         class MyTableEditor extends DefaultCellEditor
              JButton undoButton = new JButton("Undo");
              public MyTableEditor(JTextField dummy)
                   super(dummy);
                   setClickCountToStart(0);
                   undoButton.addActionListener(new ActionListener()
                        public void actionPerformed(ActionEvent e)
                             JOptionPane.showMessageDialog(null, "Do your Action Here");
              public Component getTableCellEditorComponent(JTable table,
                        Object value, boolean isSelected, int row, int column)
                   Component comp = super.getTableCellEditorComponent(table, value, isSelected, row, column);
                   if (column == 2)// The Action Column
                        Object checkValue = table.getValueAt(row, 1);
                        if ("Show".equals(String.valueOf(checkValue)))
                             return undoButton;
                   return comp;
              public Object getCellEditorValue()
                   return "";
          * @param args
         public static void main(String[] args)
              // TODO Auto-generated method stub
              new TableEdit2();
    }

  • 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

  • How to disable the tab focusing for a JTextField object because those ...

    Hi All,
    Here I need some help. I want to disable the tab focusing( tab index) for a JTextField objects because those objects are set as setEditable(false). Also can u tell me about how to change the tab index orders for JTextFields.
    Many thanks,
    Vijaycanaan.

    I want to disable the tab focusing( tab index) for a JTextField objectsLook through the API and find methods with the word "focus" in the method name.
    Also can u tell me about how to change the tab index orders for JTextFields."How to Use the Focus Sub System":
    http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html

  • 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);          

  • JBuilder .exe focus problem

    I have a swing application of a JFrame with a JMenuBar and JTextfields, JButtons, etc... It works great as a standalone application, or when run as an executable .jar. The problem is when I use JBuilder 7 Native Executable Builder and make a .exe out of the application. It also works fine, but when I click on a JMenuItem that does not bring up a JDialog, just performs a function, it performs the function, but refuses thereafter to give focus to the JTextfields and JTextArea, unless I click on a JButton to bring up a JDialog or JFileChooser, close, then the JTextfields accept focus again (what a workaround!!).
    I have added code for a JTextField to requestFocus, grabFocus after the function was performed, and even had the SwingFocusManager disabled, all of which still did not allow focus after the function was performed.
    Once again, this is only in the .exe version of my application- the other "normal" ways run fine. Has anyone else had this problem? Has anyone thought up a solution, or is this just a JBuilder unfixable for their cool neat new feature??
    Thanks for any ideas,
    Jim

    Well, your that did not work either. I think it is not anything to do with the code necessarily- as it is not always reproducible!!- The only commonality is that it occurs only with JBuilders .exe created from the source code- all else works fine. And then, the .exe only has this focus problem on my Dell Inspiron laptop running win 2k- strange- and not always (the first time works-sometimes- and then not afterwards- even when shut down and restarted!!) maybe I'll knock it up to just a OS/Platform problem....well I'll give you the duke anyway for the try-
    Jim

  • Very Strange Focus problem

    I've encountered a very strange focus problem that I hope someone can help me
    with. In my frame, I have a toolbar and some JTextFields. When I press one of
    the toolbar buttons, I do whatever and at the very end I use requestFocusInWindow()
    to set the focus to one of the JTextFields. Now here's the strange part. If I don't
    touch the keyboard or the mouse, I can see the caret in the JTextField as expected.
    As soon as I move the mouse or touch any key, the focus changes to the next
    toolbar button. Makes no sense to me. By the way, I'm running 1.4 on Windows NT.

    Create a new class ToolbarButton extends JButton where you have the following method:
         * Identifies whether or not this component can receive the focus.
         * A disabled button, for example, would return false.
         * @return true if this component can receive the focus
        public boolean isFocusTraversable() {
           return false;
        }This prevents the buttons from getting keyboard focus, this makes only sense for toolbar buttons.
    Cheers,
    Taoufik

  • 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();

  • 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.

  • 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?

  • JTextField in a JTable cell

    Hi,
    I have just started coding in Swings and would like to find out ways by which I can add JtextField in a JTable cell. Is there any?
    Thanks in Advance.
    Cheena

    There sure is. The thing you're looking for is the cells TableCellEditor. Check out this tutorial, it will explain how to use CellEditors, you should have no diffculties adapting the example to your needs (otherwise just post again :-)
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

  • 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.

  • Interesting problem for all students and programmers Have a look!

    Hello. This is a very interesting problem for all programmers and students. I have my spalsh screen class which displays a splash when run from the main method in the same class. However when run from another class( in my case from my login class, when user name and password is validated) I create an instance of the class and show it. But the image in the splash is not shown. Only a squared white background is visible!!!.
    I am sending the two classes
    Can u tell me why and propose a solution. Thanks.
    import java.awt.*;
    import javax.swing.*;
    public class SplashScreen extends JWindow {
    private int duration;
    public SplashScreen(int d) {
    duration = d;
    // A simple little method to show a title screen in the center
    // of the screen for the amount of time given in the constructor
    public void showSplash() {
    JPanel content = (JPanel)getContentPane();
    content.setBackground(Color.white);
    // Set the window's bounds, centering the window
    int width = 300;
    int height =400;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width-width)/2;
    int y = (screen.height-height)/2;
    setBounds(x,y,width,height);
    // Build the splash screen
    JLabel label = new JLabel(new ImageIcon("logo2.gif"));
    JLabel copyrt = new JLabel
    ("Copyright 2004, Timetabler 2004", JLabel.CENTER);
    copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 16));
    content.add(label, BorderLayout.CENTER);
    content.add(copyrt, BorderLayout.SOUTH);
    Color oraRed = new Color(100, 50, 80, 120);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));
    // Display it
    setVisible(true);
    // Wait a little while, maybe while loading resources
    try { Thread.sleep(duration); } catch (Exception e) {}
    setVisible(false);
    public void showSplashAndExit() {
    showSplash();
    // System.exit(0);
    // CLASS CALLING THE SPLASH
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JMenu;
    import javax.swing.*;
    import java.applet.*;
    import java.applet.AudioClip;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.net.URL;
    public class login extends JDialog
    String username;
    String password;
    JTextField text1;
    JPasswordField text2;
    login()
    //super("Login To TIMETABLER");
    text1=new JTextField(10);
    text2 = new JPasswordField(10);
    text2.setEchoChar('*');
    JLabel label1=new JLabel("Username");
    JLabel label2=new JLabel("Password");
    label1.setFont(new Font("Garamond",Font.BOLD,16));
    label2.setFont(new Font("Garamond",Font.BOLD,16));
    JButton ok=new JButton(" O K ");
    ok.setActionCommand("ok");
    ok.setOpaque(false);
    ok.setFont(new Font("Garamond",Font.BOLD,14));
    ok.setBackground(SystemColor.controlHighlight);
    ok.setForeground(SystemColor.infoText);
    ok.addActionListener(new ActionListener (){
    public void actionPerformed(ActionEvent e)
    System.out.println("ddddd");
    //validatedata();
    ReadText mytext1=new ReadText();
    ReadText2 mytext2=new ReadText2();
    String value1=mytext1.returnpassword();
    String value2=mytext2.returnpassword();
    String user=text1.getText();
    String pass=text2.getText();
    System.out.println("->"+value1);
    System.out.println("->"+value2);
    System.out.println("->"+user);
    System.out.println("->"+pass);
    if ( (user.equals(value1)) && (pass.equals(value2)) )
    System.out.println("->here");
    // setVisible(false);
    // mainpage m=new mainpage();
    // m.setDefaultLookAndFeelDecorated(true);
    // m.callsplash();
    /// m.setSize(640,640);
    // m.show();
    //m.setVisible(true);
    SplashScreen splash = new SplashScreen(5000);
    // Normally, we'd call splash.showSplash() and get on with the program.
    // But, since this is only a test...
    splash.showSplashAndExit();
    else
    { text1.setText("");
    text2.setText("");
    //JOptionPane.MessageDialog(null,
    // "Your Password is Incorrect"
    JButton cancel=new JButton(" C A N C E L ");
    cancel.setActionCommand("cancel");
    cancel.setOpaque(false);
    cancel.setFont(new Font("Garamond",Font.BOLD,14));
    cancel.setBackground(SystemColor.controlHighlight);
    cancel.setForeground(SystemColor.infoText);
    cancel.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e)
    dispose();
    System.exit(0);
    JPanel pan1=new JPanel(new GridLayout(2,1,20,20));
    JPanel pan2=new JPanel(new GridLayout(2,1,20,20));
    JPanel pan3=new JPanel(new FlowLayout(FlowLayout.CENTER,20,20));
    pan1.setOpaque(false);
    pan2.setOpaque(false);
    pan3.setOpaque(false);
    pan1.add(label1);
    pan1.add(label2);
    pan2.add(text1);
    pan2.add(text2);
    pan3.add(ok);
    pan3.add(cancel);
    JPanel_Background main=new JPanel_Background();
    JPanel mainpanel=new JPanel(new BorderLayout(25,25));
    mainpanel.setOpaque(false);
    // mainpanel.setBorder(new BorderLayout(25,25));
    mainpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder
    ("Login To Timetabler Vision"),BorderFactory.createEmptyBorder(10,20,10,20)));
    mainpanel.add("West",pan1);
    mainpanel.add("Center",pan2);
    mainpanel.add("South",pan3);
    main.add(mainpanel);
    getContentPane().add(main);
    void validatedata()
    ReadText mytext1=new ReadText();
    ReadText2 mytext2=new ReadText2();
    String value1=mytext1.returnpassword();
    String value2=mytext2.returnpassword();
    String user=text1.getText();
    String pass=text2.getText();
    System.out.println("->"+value1);
    System.out.println("->"+value2);
    System.out.println("->"+user);
    System.out.println("->"+pass);
    if ( (user.equals(value1)) && (pass.equals(value2)) )
    SplashScreen splash = new SplashScreen(5000);
    splash.showSplashAndExit();
    dispose();
    else
    { text1.setText("");
    text2.setText("");
    //JOptionPane.MessageDialog(null,
    // "Your Password is Incorrect"
    public void callsplash()
    {SplashScreen splash= new SplashScreen(1500);
    splash.showSplashAndExit();
    public static void main(String args[])
    { login m=new login();
    Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
    int screenPositionX=(int)(screenSize.width/2-390/2);
    int screenPositionY=(int)(screenSize.height/2-260/2);
    m.setLocation(screenPositionX, screenPositionY);
    //m.setResizable(false);
    m.setSize(600,500);
    m.setSize(390,260);
    m.setVisible(true);

    Hi Luis,
    Use tcode XK99 for vendor mass change, select the Fax no field. You have to take note that this changes will be only 1 fax number for all vendors.
    Else you have to use BAPI for mass change.
    regards,
    maia

  • Problem with select all cells in JTable

    Hi guys! I get some problem about selecting all cells in JTable. I tried to used two methods:
    1> table.selectAll()2> changeSelection(firstcell, lastcell,false,true)
    firstcell:[0,0], lastcell[rowcount-1,colcount-1]
    Result: only the first row selected when i use both methods.
    Note: i set up the selection model as following:
    this.dataSheet.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                    this.dataSheet.setCellSelectionEnabled(true);
                    this.dataSheet.setRowSelectionAllowed(true);
                    this.dataSheet.setColumnSelectionAllowed(true);Thanks !

    What selection properity should be changed in order to enable selectAll() method work properly? Is there Any constraints? Here is the TableModel I am using. And i set up selection mode use the following code:
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setCellSelectionEnabled(true);
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(true);
    import java.util.Vector;
    import javax.swing.table.*;
    import javax.swing.JTable;
    public class DataSheetModel extends AbstractTableModel{
              private Vector data = new Vector();//Store data
              private Vector columnNames = new Vector();//Store head
              public DataSheetModel(){}
              public DataSheetModel(Vector headVector, Vector dataVector){
                   if(headVector != null) this.columnNames = headVector;
                   if(dataVector != null) this.data = dataVector;
              public int getColumnCount(){
                   return columnNames.size()+1;
              public int getRowCount(){
                   return data.size()+1;
              public String getColumnName(int col){
                   if(col==0) return "";
                   else return (String)columnNames.get(col-1);
              public Object getValueAt(int row, int col){
                   if(col==0) {
                        if(row != data.size()) return String.valueOf(row);
                        else return "*";
                   else{
                        if(row != data.size()){
                             Vector rowVector = (Vector)data.elementAt(row);
                             return rowVector.elementAt(col-1);
                        }else return null;
              public void setValueAt(Object value, int row, int col){
                   if(row != this.data.size()){
                        Vector rowVector = (Vector)data.elementAt(row);
                        rowVector.set(col-1,value);
                        this.data.set(row,rowVector);
                        this.fireTableDataChanged();
                   }else{
                        Vector rowVector = new Vector();
                        for(int i=0; i<this.getColumnCount()-1; i++) rowVector.add(null);
                        rowVector.set(col-1,value);
                        this.data.add(rowVector);
                        this.fireTableDataChanged();
              public Class getColumnClass(int c){
                   return getValueAt(0,c).getClass();
              public boolean isCellEditable(int row, int col){
                   if(col == 0) return false;
                   else return true;
              public void setDataVector(Vector head, Vector data){
                   if(head != null) this.columnNames = head;
                   if(data != null) this.data = data;
    }

  • 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

  • Satellite U300 connected to TV - Non supported video format

    I am using Toshiba Satellite U300-15q and it has a vga output so i bought a cable and a box that transfers te analogue signal of vga to digital of hdmi so that i can connect it to my 32' TV Sony make. But if i connect it it says on the tv in yellow l

  • Iphone sounds control

    Hi guys, I just wanted to ask if there's any option to control the sounds of my iphone while being in a call? Here is the situation: I'm in a important call for about 30 minutes, and during that call I'm hearing all the sounds in my ear pretty loud (

  • Trigger BPM Process

    Hello Is there any documentation available as to what are the different ways a BPM Process can be triggered ( like web service, WD4A, VC, etc .. ? I am triggering teh Process through configuration management and that looks very techie when giving a d

  • Navbar won't stretch in Darkroom template

    Hi, I made a page using the Darkroom template, and then increased the content width to 850px (from 700px). But when I stretched the Navbar to the right to fit the new page width, the white outline went across, but the gray fill colour stayed fixed at

  • Entity Framework in WPF Application - Using Statement or Implement IDisposable

    I have a WPF application that uses Entity Framework. I have implemented a Repository that implements IDisposable, that holds my EF context.  When the application starts up I new up a Repository, which news up an EF context, then when the application