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

Similar Messages

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

  • 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

  • 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 with the JScrollPane...

    Hi there!
    I have a little problem controling the JScrollPane.
    In some class - which extends the JPanel class - I build the GUI within the constructor.
    This class is later included by another class into the center of a border layout. Now when
    I make this whole window visible, everything looks fine except that the scrollpane scrolled
    down to approx. 3/4 of the panel, but I want the Scrollpane to scroll all the way to the top...
    I already tried to manage this by using
    scrollPane.getVerticalScrollBar().setValue(0);
    But this does not do anything as long as I am calling this function from within the constructor.
    When I trigger this function by pressing some JButton it works fine!
    I guess this has something to do with the way Java paints the Frames and the Panels. And that
    maybe the Scrollpane is not yet existend as such when I try to scroll all the way to the top....
    Do you have any suggestions??
    Thx in advance!!

    But this does not do anything as long as I am calling this function from within the constructor.
    scrollPane.getVerticalScrollBar().setValue(0);Try wrapping the above line in a SwingUtilities.invokeLater(...)
    or maybe using
    component.scrollRectToVisible(...);

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

  • Problem in using JScrollPane

    hiii i am creating an image editor in java...
    here is my code for using scrollpane
      contentpane = getContentPane();
                view  =  new JLabel(new ImageIcon(bufferedImage));
                scrollpane =  new JScrollPane(view,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                scrollpane.setPreferredSize(new Dimension(800,600));
                contentpane.add(scrollpane);The problem is that the content of viewport does not change...i.e if i apply any effect to an image....after that as soon as i use the scrollbar, the viewport displays the original image!!!
    What is the problem??
    could someone suggest a solution?

    Can you plzz help me with this??...it is very urgent...
    As i am creating an image editor, so the scrollpane must be updated as soon as i apply any effect to it .....
    along with that whenever a user selects a file from FileDialog...then also it must be updated!!!
    I have extended JFrame for my main class.
    //this is the code i have written when user selects a new file...
    contentpane = getContentPane();
    view =  new JLabel(new ImageIcon(bufferedImage));
    view.setVisible(true);
    crollpane =  new                   JScrollPane(view,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                scrollpane.setPreferredSize(new Dimension(200,200));
                contentpane.add(scrollpane);
    // This is the code for scollpane update
        iicon.setImage(bufferedImage);
          view.setIcon(iicon);
          scrollpane =  new                     JScrollPane(view,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                scrollpane.setPreferredSize(new Dimension(200,200));
                contentpane.add(scrollpane);
               scrollpane.updateUI();Message was edited by:
    rav_ahj

  • Problem removing focused object from a table

    Hi.
    I have a problem removing a component that is focused from a table. The
    whole row is removed except a single component (JSpinner) in one row.
    My table has three columns, the first two are String fields
    (not editable) and the last is a JSpinner. Since there is no
    Default cell renderer or cell editor for JSpinner I had to
    create them.
    So, if no element of the row is focused then calling the function:
    public void clearTable() {
    setVisible(false);
    dataVector.removeAllElements(); // clear data vector
    setVisible(true);
    works just fine
    but if a spinner in a row is focused them that spinner is left alone "floating" on an otherwise empty table.
    Questions:
    1) Any one has an ideia of what might be the problem?
    2) Do I have to play with Focus to solve this? (hate the idea,
    since always been told to avoid messing with focus, because
    of the problems it normally brings)
    Thanks in advance for the help,
    Rgds,
    Jorge

    The problem is that you need to properly stop the editing operation first.if( myTable.isEditing() ) {
        // If you want to throw away any edits use...
        myTable.getCellEditor().cancelCellEditing();
        // If you want to apply any edits, then end use...
        myTable.getCellEditor().stopCellEditing();

  • Camileo P10 Problem with Focus

    Hello everyone,
    I bought a P10 Camileo and after an hour of use I started to have the following problem:
    The camera can no longer focus the image from afar.
    It seems that the focus is fixed, i have to bring the camera to get a clear image.
    Thank's.

    Hi pleone,
    I agree with the user above. You have to disable the image stabilization and than you are able to focus again.
    Furthermore the camera is equipped with a macro switch. Did you notice this?
    I also recommend checking the user manual. It contains a lot of interesting informations about the camera. :)

  • Problem regarding focusing elements after submit

    Hi all
    I have a bunch of radio groups with submit on my page . The requirement is to set focus on the next radiogroup with submit after any radiogroup with submit is clicked.
    But the problem is When user changes the value the focus is moving to the top of the page. Is there any way that we can keep the focus on the same item or other item at the same level ?
    I have written the following statement in HTML Form Element Attributes and Form Element Option Attributes of the first radiogroup with submit (called P4_X) : onClick = "document.getElementById('P4_E').focus();" (The last radiogroup with submit on the page is called P4_E).
    But alas it just doesnt work :-(
    If this is any help, I am pasting a sniplet of the 'view source' of my page
    <td colspan="2" valign="top" class="t3Body"><table class="formlayout" summary="" ><tr><td nowrap="nowrap" align="right"><a class="t3optionalwithhelp" href="javascript:popupFieldHelp('3886301842732082','12829541423701975766')" tabindex="999"></a></td>
    <td colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="3886301842732082" /><fieldset id="P4_X"><input type="radio" name="p_v01" value="%null%" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" /><span onClick = "document.getElementById('P4_E').focus();">%</span>
    <input type="radio" name="p_v01" value="choice1" checked="checked" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" id="P4_X_1" />
    <span onClick = "document.getElementById('P4_E').focus();"><label for="P4_X_1">choice1</label></span>
    <input type="radio" name="p_v01" value="choice2" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" id="P4_X_2" />
    <span onClick = "document.getElementById('P4_E').focus();"><label for="P4_X_2">choice2</label></span>
    <input type="radio" name="p_v01" value="choice3" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" id="P4_X_3" />
    <span onClick = "document.getElementById('P4_E').focus();"><label for="P4_X_3">choice3</label></span></fieldset>
    <td colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="3891304050742114" /><fieldset id="P4_E"><input type="radio" name="p_v08" value="choice1" onclick="doSubmit('P4_E')" id="P4_E_0" />
    <label for="P4_E_0">choice1</label>
    <input type="radio" name="p_v08" value="choice2" onclick="doSubmit('P4_E')" id="P4_E_1" />
    <label for="P4_E_1">choice2</label>
    <input type="radio" name="p_v08" value="choice3" onclick="doSubmit('P4_E')" id="P4_E_2" />
    <label for="P4_E_2">choice3</label></fieldset>
    <a class="eLink" title="Edit" href="javascript:popupURL('f?p=4000:371:14317056829894007819::::P371_ID,FB_FLOW_ID,FB_FLOW_PAGE_ID:3891304050742114,101,4');" tabindex="999"><img src="/i/e.gif" alt="Edit" class="eLink" /></a></td></tr>
    Please help me out !!
    Regards
    -Shantanu Dhanuka

    Hi,
    1 - Create a new HTML region on your page called "Scripts" and in the "Display Point" select "Before Footer" - this places the region at the bottom of the page.
    2 - Create a new Item and put in the new region. Call the item P1_FOCUS_FIELD. Set its Default Value to the name of the field that will receive the focus when the page is FIRST loaded (P_E_1?).
    3 - In the new region's Region Footer, add in the following:
    &lt;script type="text/javascript"&gt;
    var f = document.getElementById("P1_FOCUS_FIELD").value;
    document.getElementById(f).focus();
    &lt;/script&gt;
    4 - Update your submit process to set the value of P1_FOCUS_FIELD to the ID of the field that you want to receive the focus when the page is reloaded.
    Regards
    Andy

  • Problems with focus on mac

    I'm making a Comunity system for online games, and i got a problem with keyFocus in java.awt.Window on MAC (OS9 & X).
    I have some popup dialog for P2P chat etc. The popup dialog is an extension of java.awt.Window and is not using standard awt or swing components. I use the keyListener to send key events to my own graphic implementation that generates a Image that is show i the window by drawing it in the paint method.
    The problem is that I can't get keyFocus on the window, if I add a awt.TextField to the window i can get key focus by requesting keyFocus after showning the window, but if the window has been hidden by another window I can't get the key focus back.
    Is there anyway to give the java.awt.Window keyFocus?
    Is there anyway to make the java.awt.Window Focusable with out havning a focusable component on it?

    I forgot to tell that main program is an applet and must be able to run under all jvm's from 1.1 to 1.4.
    THX

  • Problem gaining focus

    Hi all, Im writing an applicaiton and I'm having some trouble getting the focus where I want it and was wondering if anyone could give me a suggestion.
    Here's the setup: I have a JFrame with a JToolBar on it. One of the buttons on the toolbar fires an extention of PAction that I setup. This PAction brings up a JInternalFrame with an optionpane on it that allows the user to enter/edit several pieces of info (several JTextComponents). On this InternalFrame is an InternalFrameListener, on its internalFrameActivated event I do a requestFocus() on the first JTextComponent on the InternalFrame.
    Whats currently happening is that the internalframe is activating and being selected, but the focus seems to be remaining on the toolbar's button. If I fire the same action using a method other than the toolbar (like the menu), the focus goes exactly where I want it.
    Here's what I know so far from debugging:
    1) The listener is definetly firing.
    2) The component never gains focus (in otherwords, im not loosing it after the request)
    3) There is a thread running but it's sleeping until the ok or cancel button is pressed.
    Here's what I've tried so far:
    1) Removing the thread
    2) Requesting focus on the first component: after the frame is opened, after the frame is activated, at the end of the PAction, and having the action reselect the internalframe then give the component focus
    3) I verified there are no other action listeners on the button.
    4) Stared blankly at my screen for a long time lost in thought.
    Any help will be very appreciated,
    Kris

    I experienced the same problem and the way I resolved it
    was making the toolbar buttons non-focusable.
    But this may not be good for you if you need to navigate the
    toolbar with the keyboard.

  • Problem losing focus

    Hi all,
    I have a problem with a Flex application hosted in an Adobe InDesign CS4. I'm using a panel developed in Flex inside Adobe InDesign. The Flex panel has a Tree component. The problem is that when I click in the Tree component and then I click outside the panel in order to type some text in an InDesign document, the focus still remains in the Flex panel. In fact, the focus is in the Tree component and it is imposible to take the focus out of the panel unless you close the panel.
    Does anybody know how to solve this problem?
    Thaks in advance,
    Alvaro.

    Hi Alex,
    if I click on a button in the same panel and after I click the InDesign document to type some text, I get the same behaviour, the InDesign document doesn't get the focus which is still in the button. So this hapends with any Flex component.
    Thanks.

  • A small problem with a JScrollPane and child windows

    Hi !
    I have created a customized JComponent inside a JScrollPane and when my application starts I create two JTextField's that I put in the JComponent and so far it all works fine to start with, but when ever the JComponent is redrawn after that the JTextField's are overdrawn or at least are not visible any longer...
    Do I need to repaint the sub components of my own JComponent myself or am I doing something very wrong here ?
    a JScrollPane
    a JComponent with some drawing going on in paint()
    a JTextField
    another JTextField
    Mikael

    Ooppps !
    Forget about it, I forgot to put a super.paint( g) at the top of my paint method, that was the problem.
    Mikael

  • Layout Problem in a JScrollPane

    Hi Friends. I have the following problem.
    Fact 1:
    When I add components to a JPanel with a FlowLayout, the components rearrange themself to the next line when the length exceeds the viewable area(horizontally).
    Goal:
    I want to add the JPanel to a scrollPane and I dont want the horizontal scrolling. I want that when I add the components to the JPanel, components are added to the new line, when the horizontal viewable area is used up.(Something like the "fact" mentioned above ... but the difference here is, I want the JPanel inside a JScrollPane)
    Problem :
    When i add the JPanel to the scrollPane and adds components to JPanel... all components come into one line and don't wraps up themself.
    I have also tried with various properties.. telling no horizontal scrollbar etc... but it doesnt helps..... the components are laid off in one single long line.
    Please help me with this problem.
    Thanks a lot in advance.
    Warm Regards,
    Nishant

    hi friends,
    yeah now after a lot of RnD , I am able to implement a solution to the problem... it might not be a good one, but for me it is decent enuf.
    I tried everything , extending a custom JPanel from Scrollable and all sorts of things, but nothing was very helpful.
    One single thing which is most important is the preferredSize of the JPanel, which if you can set properly with the addition/deletion or resizing ,..... the problem is solved.
    so the problem remains only to set the appropiate preferredSize of the Jpanel. unfortunately, the JPanel's respective preferredSize, maximumSize, minimumSize etc are not of much help.
    so I decided to look for the components inside the JPanel and look for the last component position and the height.... but unfortunately (I dont know the reason), I get the position of all components, except the last one correct. So my choice of component now is last but one. I calculated the position of last but one component and added the (height of this component + height of last component + some buffer ), to get the height of the panel.
    and set the preferredSize of the Jpanel appropiately, for ex. in the action, adding components to the panel.. etc .. etc...
    the code snippet is as follows..and it works absolutely fantastic for my requirements, atleast...
    Component[] tmpC = _oLeftPanel.getComponents();
    if(tmpC.length >1)
         double kbuffer = 25D;
         //doing for last but one comp.
         Component kcomp1 = tmpC[tmpC.length - 2];
         double kh1 = kcomp1.getY();
         kh1 += kcomp1.getHeight();
         kh1 += kbuffer;
         //doing it for the last component
         kcomp1 = tmpC[tmpC.length - 1];
         kh1 += kcomp1.getHeight();
         kh1 += kbuffer;
         Dimension kdim = new Dimension((int)_oLeftScrollPane.getViewport().getViewSize().getWidth(), (int)kh1);
         _oLeftPanel.setPreferredSize(kdim);

Maybe you are looking for

  • Count of rows deleted from ResultSet

    Hi: I have the following String query = "delete from REMEDY.trs_notes where ROWID NOT IN (SELECT MIN(ROWID) from REMEDY.trs_notes group by NOTEID)"; stmt = remedyMDSconn.createStatement(); rs = stmt.executeQuery(query); Is there anyway I can get the

  • Installation Issue

    When installing Adobe Photoshop Elements 7, the installation runs fine and completes normally.  However, the application itself does not load when I attempt to run it.  A quick glance at my 'C:\Program Files\Adobe\Photoshop Elements 7.0' folder revea

  • LSMW Recording with multiple lines

    I am creating a recording in LSMW for VA02 - Change Sales Order. My source file contains several lines from the same sales order, the sales order number is maintained in one of the columns. The order originates from an IDOC LSMW I will run ahead of t

  • Error installing av server 10.2.3 on linux 32 bit

    hi, I am trying to install av server on linux x86 32 bit machine from the downloaded software file av_10_2_3_server_linux_x32. All the pre install requisites are met and there is no error until the avca is started by the configuration manager. here i

  • Check this out.

    After much fine tuneing and a few small problems solved by updating my bios. I managed this OC. I have to say I love this system. Thanks Tire Smoke and everyone who helped me.