Problems whith focus in a JTextField!!!

Hello:
I have a JTextField inside a JFrame, at the beginning, when I open the window the Focus appears in the JTextField.I put disabled this JTextField and later i put it enabled. I would like that the Focus came back to appear in that JTextField.
I have used the method "grabFocus" and doesn�t work.
What can i use?
Thanks in advance.
M�nica

If you read the sdk api doc for grabFocus() you will see that a client code should use requestFocus() instead.

Similar Messages

  • Problem while adding both Key And Focus Listeners to JTextField

    Hi!
    I have something peculiar while adding Key and Focus Listener to JTextField. Suppose i add just Key Listener then everything's fine and i could keep track of keys being pressed. But as soon as i add a Focus Listener to it with the code to select full text in focusGained() method, it starts reponding wrongly to arrow keys pressed and does not perform desired actions. For let arrow key it moves caret by one for the first time after that it does not resond to that unless caret is changed by using mouse. If right arrow key is pressed the it moves the caret to last position from wherever it is. For UP and DOWN it selects the full text(This should be done when it gets focus)
    public void focusGained(FocusEvent fe)
    setCaretPosition(0);
    moveCaretPosition(getDocument().getLength());
    Can someone help me out on this?
    thanks and regards,
    Amit.

    None of those things will cause your JFrame to resize itself. And this is probably a good thing, because your JFrame shouldn't change size once you have created it. Why not create your JPanel so that it has enough space for you to add the component later? Or why not just add the component to start with and then enable it or make it editable when you decide that's necessary?

  • Problem with focus

    hello all people who read this post
    I am migrating an application created with the JDK 1.2 under the JDK 1.4.
    (an intermediate migration without problem was carried out into 1.3).
    And I encounter problems with the focus. None JTextField and other
    components focusable take the focus.
    I still seek the solution but if somebody with already were confronted
    with this problem, I would be grateful to him if it had a solution to
    propose to me.
    Coordialement.
    dinbo
    PS : I am French, I am sorry for my bad English.

    Lets try and trouble shoot your problem.
    Is your code compiled with the 1.2 or 1.4 sdk?with 1.4 sdk
    Are you using swing components or awt components?I use swing components
    Is your program an applet or application?it's an application
    Are you attempting to force the focus from component to component? I made different test which was not conclusive.
    (Are you using the > following methods: nextFocusableComponent(Component aComponent),
    setRequestEnabled(boolean value), transferFocus(), or any of the other focus methods?)yes the old application use them (except transfertFocus())
    Is your code working with any of the focus managers?I carried out different test
    my old application functions correctly if I compile it into 1.3 and that I only launch it.
    If I launch it since the new application into 1.4, it functions but not the focus.
    thanks for your time,thank you for the interest which you carry to my problem.
    dinbo

  • Problem with focus on applet  - jvm1.6

    Hi,
    I have a problem with focus on applet in html page with tag object using jvm 1.6.
    focus on applet work fine when moving with tab in a IEbrowser page with applet executed with jvm 1.5_10 or sup, but the same don't work with jvm1.6 or jvm 1.5 with plugin1.6.
    with jvm 1.5 it's possible to move focus on elements of IEbrowser page and enter and exit to applet.
    i execut the same applet with the same jvm, but after installation of plugin 1.6, when applet gain focus don't release it.
    instead if i execute the same applet with jvm 1.6, applet can't gain focus and manage keyevent, all keyevent are intercepted from browser page.
    (you can find an example on: http://www.vista.it/ita_vista_0311_video_streaming_accessibile_demo.php)
    Any idea?
    Thanks

    Hi piotrek1130sw,
    From what you have described, I think the best approach would be to restore the original IDT driver, restart the computer, test that driver, then install the driver update, and test the outcome of installing the newest driver.
    Use the following link for instructions to recovery the ITD driver using Recovery Manager. Restoring applications and drivers.
    Once the driver is restored, restart the computer and test the audio. If the audio is good you can continue to use this driver, or you can reinstall the update and see what happens. IDT High-Definition (HD) Audio Driver.
    If installing the newest driver causes the issue to occur but the recovered driver worked, I suggest recovering again.
    If neither driver works I will gladly follow up and provide any assistance I can.
    Please let me know the outcome.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • Problem with focus border and ListCellRenderer in custom listbox

    I have a bug in some code that I adapted from another posting on this board -- basically what I've done is I have a class that implements a custom "key/value" mapping listbox in which each list item/cell is actually a JPanel consisting of 3 JLabels: the first label is the "key", the second is a fixed "==>" mapping string, and the 3rd is the value to which "key" is mapped.
    The code works fine as long as the list cell doesn't have the focus. When it does, it draws a border rectangle to indicate focus, but if the listbox needs to scroll horizontally to display all the text, part of the text gets cut off (i.e. "sometex..." where "sometext" should be displayed).
    The ListCellRenderer creates a Gridlayout to lay out the 3 labels in the cell's JPanel.
    What can I do to remedy this situation? I'm not sure what I'd need to do in terms of setting the size of the panel so that all the text gets displayed OK within the listbox. Or if there's something else I can do to fix this. The code and a main() to run the code are provided below. To reproduce the problem, click the Add Left and Add Right buttons to add a "mapping" -- when it doesn't have focus, everything displays fine, but when you give it focus, note the text on the right label gets cut off.
    //======================================================================
    // Begin Source Listing
    //======================================================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.Vector;
    import java.util.Enumeration;
    public class TwoColumnListbox extends JPanel
    private JList m_list;
    private JScrollPane m_Pane;
    public TwoColumnListbox(Collection c)
         DataMapListModel model = new DataMapListModel();
         if (c != null)
         Iterator it = c.iterator();
         while (it.hasNext())
         model.addElement(it.next());
         m_list = new JList(model);
         ListBoxRenderer renderer= new ListBoxRenderer();
              m_list.setCellRenderer(renderer);
              setLayout(new BorderLayout());
              m_list.setVisibleRowCount(4);
              m_Pane = new JScrollPane(m_list);
              add(m_Pane, BorderLayout.NORTH);
    public JList getList()
    return m_list;
    public JScrollPane getScrollPane()
    return m_Pane;
    public static void main(String s[])
              JFrame frame = new JFrame("TwoColumnListbox");
              frame.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {System.exit(0);}
    final DataMappings dm = new DataMappings();
    final TwoColumnListbox lb = new TwoColumnListbox(dm.getMappings());
              final DataMap map = new DataMap();
              JButton leftAddBtn = new JButton("Add Left");
              leftAddBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setSource("JButton1");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JButton leftRemoveBtn = new JButton("Remove Left");
              leftRemoveBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setSource("");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JButton rightAddBtn = new JButton("Add Right");
    rightAddBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setDestination("/getQuote/symbol[]");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JButton rightRemoveBtn = new JButton("Remove Right");
    rightRemoveBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setDestination("");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JPanel leftPanel = new JPanel(new BorderLayout());
              leftPanel.add(leftAddBtn, BorderLayout.NORTH);
              leftPanel.add(leftRemoveBtn, BorderLayout.SOUTH);
    JPanel rightPanel = new JPanel(new BorderLayout());
              rightPanel.add(rightAddBtn, BorderLayout.NORTH);
              rightPanel.add(rightRemoveBtn, BorderLayout.SOUTH);
    frame.getContentPane().add(leftPanel, BorderLayout.WEST);
              frame.getContentPane().add(lb,BorderLayout.CENTER);
    frame.getContentPane().add(rightPanel, BorderLayout.EAST);
              frame.pack();
              frame.setVisible(true);
         class ListBoxRenderer extends JPanel implements ListCellRenderer
              private JLabel left;
              private JLabel arrow;
              private JLabel right;
              private Color clrForeground = UIManager.getColor("List.foreground");
    private Color clrBackground = UIManager.getColor("List.background");
    private Color clrSelectionForeground = UIManager.getColor("List.selectionForeground");
    private Color clrSelectionBackground = UIManager.getColor("List.selection.Background");
              public ListBoxRenderer()
                   setLayout(new GridLayout(1, 2, 10, 0));
                   //setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
                   left = new JLabel("");
                   left.setForeground(clrForeground);               
                   arrow = new JLabel("");
                   arrow.setHorizontalAlignment(SwingConstants.CENTER);
                   arrow.setForeground(clrForeground);
                   right = new JLabel("");
                   right.setHorizontalAlignment(SwingConstants.RIGHT);
                   right.setForeground(clrForeground);
                   add(left);
                   add(arrow);
                   add(right);
              public Component getListCellRendererComponent(JList list, Object value,
                        int index, boolean isSelected, boolean cellHasFocus)
                   if (isSelected)
                        setBackground(list.getSelectionBackground());
                        setForeground(list.getSelectionForeground());
                        left.setForeground(clrSelectionForeground);
                        arrow.setForeground(clrSelectionForeground);
                        right.setForeground(clrSelectionForeground);
                   else
                        setBackground(list.getBackground());
                        setForeground(list.getForeground());
                   left.setForeground(clrForeground);
                        arrow.setForeground(clrForeground);
                        right.setForeground(clrForeground);               
                   // draw focus rectangle if control has focus. Problem with focus
    // and cut off text!!
                   if (cellHasFocus)
                   // FIXME: for Windows LAF I'm not getting the correct thing here for some reason.
                   // Looks OK on Metal though.
                   setBorder(BorderFactory.createLineBorder(UIManager.getColor("focusCellHighlightBorder")));
                   else
                   setBorder(BorderFactory.createEmptyBorder());               
    DataMap map = (DataMap) value;
                   String displaySource = map.getSource();
                   String displayDest = map.getDestination();
                   left.setText(displaySource);
                   arrow.setText("=>to<=");
                   right.setText(displayDest);
                   return this;
    /** Interface for macro editor UI
    * @version 1.0
    class DataMappings
    private Collection mappings;
    public DataMappings()
    setMappings(new Vector(0));
    public DataMappings(Collection maps)
    setMappings(maps);
    /** gets mapping value of a specified source object
    * @param src -- the "key" or source object, what is mapped.
    * @return what the source object is mapped to
    * @version 1.0
    public Object getValue(String src)
    if (src != null)
    Iterator it = mappings.iterator();
    while (it.hasNext());
    DataMap thisMap = (DataMap) it.next();
    if (thisMap.getSource().equals(src))
    return thisMap.getDestination();
    return null;
    /** sets mapping value of a specified source object
    * @param src -- the "key" or source object, what is mapped.
    * @param what the source object is to be mapped to
    * @version 1.0
    public void setValue(String src, String dest)
    if (src != null)
    // see if the value is in there first.
    Iterator it = mappings.iterator();
    while (it.hasNext())
    DataMap thisMap = (DataMap) it.next();
    if (thisMap.getSource().equals(src))
    thisMap.setDestination(dest);
    return;
    // not in the collection, add it
    mappings.add(new DataMap(src, dest));
    /** gets collection of mappings
    * @return a collection of all mappings in this object.
    * @version 1.0
    public Collection getMappings()
    return mappings;
    /** sets collection of mappings
    * @param maps a collection of src to destination mappings.
    * @version 1.0
    public void setMappings(Collection maps)
    mappings = maps;
    /** adds a DataMap
    * @param map a DataMap to add to the mappings
    * @version 1.0
    public void add(DataMap map)
    if (map != null)
    mappings.add(map);
    class DataMap
    public DataMap() {}
    public DataMap(String source, String destination)
    m_source = source;
    m_destination = destination;
    public String getSource()
    return m_source;
    public void setSource(String s)
    m_source = s;
    public String getDestination()
    return m_destination;
    public void setDestination(String s)
    m_destination = s;
    protected String m_source = null;
    protected String m_destination = null;
    /** list model for datamaps that provides ways
    * to determine whether a source is already mapped or
    * a destination is already mapped.
    class DataMapListModel extends DefaultListModel
    public DataMapListModel()
    super();          
    /** determines whether a source is already mapped
    * @param src -- the source property of a datamapping
    * @return true if the source is in the list, false if not
    public boolean containsSource(Object src)
    Enumeration enum = elements();
    while (enum.hasMoreElements())
    DataMap dm = (DataMap) enum.nextElement();
    if (dm.getSource().equals(src))
    return true;
    return false;
    /** determines whether a destination is already mapped
    * @param dest -- the destination property of a datamapping
    * @return true if the destination is in the list, false if not
    public boolean containsDest(Object dest)
    Enumeration enum = elements();
    while (enum.hasMoreElements())
    DataMap dm = (DataMap) enum.nextElement();
    if (dm.getDestination().equals(dest))
    return true;
    return false;
    public DataMappings getDataMaps()
    DataMappings maps = new DataMappings();
    // add all the datamaps in the model
    Enumeration enum = elements();
    while (enum.hasMoreElements())
    DataMap dm = (DataMap) enum.nextElement();
    maps.add(dm);
    return maps;
    //======================================================================
    // End of Source Listing
    //======================================================================

    I did not read the program, but the chopping looks like a layout problem.
    I think it's heavy to use a panel + 3 components in a gridlayout for each cell. look at this sample where i draw the Cell myself,
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class Jlist3 extends JFrame 
         Vector      v  = new Vector();
         JList       jc = new JList(v);
         JScrollPane js = new JScrollPane(jc);
    public Jlist3()
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         for (int j=0; j < 70; j++)     v.add(""+j*1000+"a  d"+j);
           setBounds(1,1,400,310);
         getContentPane().add(js);
         js.setPreferredSize(new Dimension(230,259));
         jc.setSelectedIndex(1);
         jc.setCellRenderer(new MyCellRenderer());
         getContentPane().setLayout(new FlowLayout());
         setVisible(true);
    public class MyCellRenderer extends JLabel implements ListCellRenderer
         String  txt;
         int     idx;
         boolean sel;
    public Component getListCellRendererComponent(JList list,
                             Object  value,           // value to display
                             int     index,           // cell index
                             boolean isSelected,      // is the cell selected
                             boolean cellHasFocus)    // the list and the cell have the focus
         idx = index;
         txt = value.toString();
         sel = isSelected;
         setText(txt);
         return(this);
    public void paintComponent(Graphics g)
         if (idx%2 == 1) g.setColor(Color.white);
              else        g.setColor(Color.lightGray);
         if (sel)        g.setColor(Color.blue);
         g.fillRect(0,0,getWidth(),getHeight());
         StringTokenizer st = new StringTokenizer(txt.trim()," ");
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),1,14);
         g.setColor(Color.red);
         g.drawString("===>",70,14);
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),110,14);
    public static void main (String[] args) 
         new Jlist3();
    Noah
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class Jlist3 extends JFrame
         Vector v = new Vector();
         JList jc = new JList(v);
         JScrollPane js = new JScrollPane(jc);
    public Jlist3()
         addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         for (int j=0; j < 70; j++)     v.add(""+j*1000+"a d"+j);
         setBounds(1,1,400,310);
         getContentPane().add(js);
         js.setPreferredSize(new Dimension(230,259));
         jc.setSelectedIndex(1);
         jc.setCellRenderer(new MyCellRenderer());
         getContentPane().setLayout(new FlowLayout());
         setVisible(true);
    public class MyCellRenderer extends JLabel implements ListCellRenderer
         String txt;
         int idx;
         boolean sel;
    public Component getListCellRendererComponent(JList list,
                             Object value, // value to display
                             int index, // cell index
                             boolean isSelected, // is the cell selected
                             boolean cellHasFocus) // the list and the cell have the focus
         idx = index;
         txt = value.toString();
         sel = isSelected;
         setText(txt);
         return(this);
    public void paintComponent(Graphics g)
         if (idx%2 == 1) g.setColor(Color.white);
              else g.setColor(Color.lightGray);
         if (sel) g.setColor(Color.blue);
         g.fillRect(0,0,getWidth(),getHeight());
         StringTokenizer st = new StringTokenizer(txt.trim()," ");
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),1,14);
         g.setColor(Color.red);
         g.drawString("===>",70,14);
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),110,14);
    public static void main (String[] args)
         new Jlist3();
    }

  • Hi please forword this massage  I have a problem whith paid registration  When i did check and bought 2 ringtones  i paid her  Yesterday but amount taken off my card and i do not know why   If you have  a subscrition to someting please delete ann just qhe

    Hi please forword this massage
    I have a problem whith paid registration
    When i did check and bought 2 ringtones  i paid her
    Yesterday but amount taken off my card and i do not know why 
    If you have  a subscrition to someting please delete ann just qhen i dicide to buy someting then i take maney
    Sent from my iPhone

    Please repost in your native language, as your present post makes no sense.

  • Custom focus rectangle in JTextField

    I'm trying to change my theme/look & feel to show a focus rectangle for JTextField, somewhat like this: [http://www.macvswindows.com/index.php?title=GUI_Customization|http://www.macvswindows.com/index.php?title=GUI_Customization] (second image down, or direct [http://www.macvswindows.com/images/thumb/f/f2/osx_aqua_colors.png/500px-osx_aqua_colors.png|http://www.macvswindows.com/images/thumb/f/f2/osx_aqua_colors.png/500px-osx_aqua_colors.png] ) I don't want to make it exactly like MacOS, but a similar idea.
    For now I'm just trying to do it on the inner part of the field. I can get it to paint with the code below, but then the caret painting messes things up as I tab through the fields or move the caret around inside the fields.
    So it seems I'm headed down the wrong path, what should I be doing? Extending DefaultHighlighter or DefaultCaret, or something else?
    Thanks,
    Jim
    package testui;
    import javax.swing.*;
    import javax.swing.plaf.metal.DefaultMetalTheme;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    public class ThemeTest extends JFrame {
        public class TestMetalTheme extends DefaultMetalTheme {
            public void addCustomEntriesToTable(UIDefaults table) {
                UIManager.put("TextFieldUI", "customui.CustomTextFieldUI");
            public String getName() {
                return "TestMetalTheme";
        public static void main(String[] args) {
            ThemeTest testFrame = new ThemeTest();
            testFrame.setVisible(true);
        public ThemeTest() {
            try {
                MetalLookAndFeel.setCurrentTheme(new TestMetalTheme());
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            } catch (Exception e) {
                e.printStackTrace();
            setSize(500, 500);
            setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            JPanel panel = new JPanel();
            add(panel);
            panel.add(new JTextField("test"));
            panel.add(new JTextField("test"));
            panel.add(new JTextField("test"));
            panel.add(new JButton("button"));
    package testui;
    import javax.swing.*;
    import javax.swing.plaf.ComponentUI;
    import javax.swing.plaf.metal.MetalTextFieldUI;
    import java.awt.*;
    public class CustomTextFieldUI extends MetalTextFieldUI {
        private Color focusColor = Color.cyan;
        private JComponent component;
        public CustomTextFieldUI(JComponent c) {
            if (c == null) {
                throw new IllegalArgumentException("component must be specified");
            this.component = c;
        public static ComponentUI createUI(JComponent c) {
            return new CustomTextFieldUI(c);
        protected void paintSafely(Graphics g) {
            super.paintSafely(g);
            if (component.hasFocus()) {
                Dimension size = component.getSize();
                Graphics2D g2d = (Graphics2D) g;
                System.out.println(g2d.getClip());
                System.out.println(g2d.getClipBounds());
                g2d.setColor(focusColor);
                g2d.setStroke(new BasicStroke(2f));
                g2d.drawRect(1, 1, size.width - 3, size.height - 3);
    }

    Why not just combine the two approaches?
    import java.awt.*;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import javax.swing.*;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.Border;
    import javax.swing.plaf.ComponentUI;
    import javax.swing.plaf.metal.MetalTextFieldUI;
    public class CustomTextFieldUI extends MetalTextFieldUI {
         private Color focusColor = Color.cyan;
         private JComponent component;
         private Border normalBorder;
         private Border focusedBorder;
         private FocusListener focusListener;
         public CustomTextFieldUI( JComponent c ) {
              if ( c == null ) {
                   throw new IllegalArgumentException( "component must be specified" );
              this.component = c;
              focusListener =  new FocusListener() {
                   public void focusGained( FocusEvent fe ) {
                        if ( normalBorder == null ) {
                             normalBorder = component.getBorder();
                             focusedBorder = new BevelBorder( BevelBorder.LOWERED ) {
                                  @Override
                                  public Color getHighlightInnerColor() { return focusColor; }
                                  @Override
                                  public Color getHighlightOuterColor() { return focusColor; }
                                  @Override
                                  public Color getShadowInnerColor() { return focusColor; }
                                  @Override
                                  public Color getShadowOuterColor() { return focusColor; }
                        component.setBorder( focusedBorder );
                   public void focusLost( FocusEvent fe ) {
                        component.setBorder( normalBorder );
         public static ComponentUI createUI( JComponent c ) {
              return new CustomTextFieldUI ( c );
         @Override
         protected void installListeners() {
              super.installListeners();
              component.addFocusListener( focusListener );
         @Override
         protected void uninstallListeners() {
              super.uninstallListeners();
              component.removeFocusListener( focusListener );
    }

  • Problem whith Sales Quotation

    Hello.
    I have a problem whith the sales quotation form, because the form changes to update mode when i go the last register (the document number is over 992) in find mode or with the browser buttons. Do you know why is happening this ??
    Thanks.
    my SAP version is 2007

    Hi,
    Do you have any formatted searches on this form? These can force the form in to Update mode if you choose the option 'Refresh Regularly'.
    Kind Regards,
    Owen

  • I am not able to download the latest version of itunes and it always show me "there is a problem whith this windows installer package. A program required for this install to complete could not be run. Contact your support personnel package vendor"...\

    i am not able to download the latest version of itunes because it show me this "There is a problem whith this windows installer package. A program required for this install to complete could not be run. Contact your support personnel package vendor" And so i cannot put new songs or videos in it...

    Repair your Apple software Update.
    Go to START/ALL PROGRAMS/Apple Software Update. If it offers you a newer version of Apple Software Update, do it but Deselect any other software offered at the same time. Once done, try another iTunes install
    If you don't find ASU in All programs, go to control panel/
    XP- add n remove Programs/highlight ASU, CHANGE then REPAIR.
    Vista or Win7 - Programs n features/highlight ASU and click REPAIR

  • Problems with focus traversal after moving to j2sdk_1.4.1_02

    Hi,
    Just moved to j2sdk_1.4.1_02 and we are having problems where
    focus stays on wrong UI component e.g. a user(user2) is taking edit/write permissions from another user(user1) that has write permissions. User1 is told that they will lose write permissions in
    the next 15 minutes ( information dialog displayed on their screen ) while at the same time on user2's window a text label is updated
    every 5 seconds to say how long before they will have write permissions,
    however, the information dialog displayed on user1 hangs and
    the user can't remove this dialog. Control seems to stay with user2.
    This used to work with the previous java version we used.
    Hope someone can help,
    Thanks

    Didn't say what version you came FROM, but I'm guessing if
    you're having focus related problems it was from PRIOR to 1.4
    when focus handling was revamped.
    You probably need to make sure you are using requestFocusInWindow()
    everywhere instead of requestFocus().
    Check here and possibly search for 1.4 and KeyboardFocusManager
    for new focus handling tutorials.

  • Problem in focusing JScrollPane

    I have problem in focusing a JScrollPane.
    I added a JPanel size 1000x1000 to a JScrollPane and I want to focus at the center of this JPanel.
    I have tried 2 ways to do it, but both don't work.
    1.----adding jPanel to jScrollPane directly----------------
    jScrollPane = new JScrollPane(jPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.getVerticalScrollBar().setValue(500);
    jScrollPane.getHorizontalScrollBar().setValue(500);
    jScrollPane.getVerticalScrollBar().show();
    2.----using JViewport-------------------
    JViewport vp = new JViewport();
    vp.setView(jPanel);
    vp.setViewPosition(new Point(500,500));
    vp.repaint();
    vp.doLayout();
    jScrollPane.setViewport(vp);
    Can anybody tell me where did I go wrong, please?

    Not sure, but I don't think you can set the scroll bar location until the component is visible on the frame. That is a component doesn't really have a size until it is layed out and visible on the screen. So try:
    frame.setVisible(true);
    jScrollPane.getVerticalScrollBar().setValue(500);
    jScrollPane.getHorizontalScrollBar().setValue(500);
    Or your could try adding a ComponentListener to you ScrollPane to set the scrollbar values when the component is shown.
    I'm basing my suggestion on the discussion from this thread:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=476357

  • Hi, i have a problem whith Iphone 4 whith the home boton! What can i do?

    Hi, i have a problem whith Iphone 4 whith the home boton! What can i do?

    As you do not state what the exact issue is... See here...
    The Home button is slow to respond
    If the Home button is slow to respond when exiting one application, try another application.
    If the issue exists only in certain applications, try removing and reinstalling those applications. For further assistance in installing and troubleshooting applications see this article
    If the issue continues, Try turning iPhone off and then on again. If the iPhone will not restart, try resetting it.
    If the issue is still happening, try to restore the iPhone
    Seek service is the issue is still occurring.

  • I have problem whith the bluetooh whit OS X Mavericks The IMAC don't recognize the bluetooh

    I have problem whith the bluetooh whit OS X Mavericks The IMAC don't recognize the mouse

    Hi Alejofer,
    Thanks for visiting Apple Support Communities.
    You may find the troubleshooting steps in this article helpful with troubleshooting bluetooth on your Mac:
    Bluetooth Quick Assist
    http://support.apple.com/kb/ht1153
    Best,
    Jeremy

  • Problem with focus and selecting text in jtextfield

    I have problem with jtexfield. I know that solution will be very simple but I can't figure it out.
    This is simplified version of situation:
    I have a jframe, jtextfield and jbutton. User can put numbers (0-10000) separated with commas to textfield and save those numbers by pressing jbutton.
    When jbutton is pressed I have a validator which checks that jtextfield contains only numbers and commas. If validator sees that there are invalid characters, a messagebox is launched which tells to user whats wrong.
    Now comes the tricky part.
    When user presses ok from messagebox, jtextfield should select the character which validator said was invalid so that user can replace it by pressing a number or comma.
    I have the invalid character, but how can you get the focus to jtextfield and select only the character which was invalid?
    I tried requestFocus(), but it selected whole text in jtextfield and after that command I couldn't set selected text. I tried with commands setSelectionStart(int), setSelectionEnd(int) and select(int,int).
    Then I tried to use Caret and select text with that. It selected the character I wanted, but the focus wasn't really there because it didn't have keyFocus (or something like that).
    Is there a simple way of doing this?

    textField.requestFocusInWindow();
    textField.select(...);The above should work, although read the API on the select(...) method for the newer recommended approach on how to do selection.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Open and Close OnScreen Keyboard while focus gain on JTextField

    Hi
    I have a Jtextfield when ever I click on textfield I want to open OSK(On Screen Keyboard) of Windows 8 OS and windows 7.
    I tried in below mentioned way to open and close in focus listener focusGained() and focusLost() but it is not working. could some body do needful.
    Opening OSK:
    builder = new ProcessBuilder("cmd /c " + sysroot + " /System32/osk.exe");
    Closing Osk:
    Runtime.getRuntime().exec("taskkill /f /im osk.exe");

    You need to start() the ProcessBuilder and you need to split the command like this:
    builder  = new ProcessBuilder("cmd", "/c", sysroot + " /System32/osk.exe");
    builder.start();
    And naturally you should wrap the call in a new Thread or use an ExecutorService to avoid EDT problems.

Maybe you are looking for

  • Startup Screen Pixelated - I really need help on this one.

    15" Macbook Pro - Spring 2011 My startup screen sometimes would be pixelated with the Apple logo and then would go to grey screen and do nothing... then I would be forced to shut down and power it up again. On two occasions, the bootup would have str

  • Save as image

    Hi, I would like to modify the File Dialog so the user can select one format between 3 possible formats to save an image. For example the user has the choice to save its image as bmp OR jpg OR png. So far I could define the pattern file with FileDial

  • Replace 4K screen with FullHD screen

    Hello,I bought a LenovoY50 with 4k screen on an amazon sale for 800 euros but after half a year im annoyedf because of the 4K screen. Now i would like to know if i can replace the 4K screen with a FullHD IPS Screen? Thanks.

  • I can't see my pictures from my mac 10.9.4

    i try to see my picture library and i can't see no pictures what can o do

  • I have problem with lion system when i turn on my computer

    i have lios sitem, when i turn on my computer, it start slow like in 2 time, and don't recognize the wi fi, i have to reiniciar my computer every time that i turn it on to work fine. Why????????????