Tabbed Pane Focus Problems

Focus traversal doesn't appear to be working on tabs added after the JFrame is initially displayed (at least on JDK 1.4.2):
1) Run the program. Focus is on the last field on the 3rd tab. Use the tab key to cycle through all components. It successfully tabs to the button, the tab, and each text field. This is working ok.
2) Create a new tab.
a) Focus should be on the last text field, but no component appears to have focus. (why???)
b) Type some character. They are added to the last text field. So focus was placed on the last text field, but the caret was not painted (why???)
c) Use the tab key to cycle through the components. When tabbing through the text fields the caret is not painted to indicate focus, except for the last text field (why???)
d) Click on a text field and use the tab key to cycle through all compnents. This time the caret will be painted for the last text field and the text field you just clicked on. (why???)
Any suggestions on how to fix this wierd behaviour? Here's my test code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TabbedPaneFocusTest
     static int columns = 0;
     public static void main(String args[])
          final JTabbedPane tabbedPane = new JTabbedPane();
          newTab(tabbedPane);
          newTab(tabbedPane);
          JComponent component = newTab(tabbedPane);
          JButton button = new JButton("Add Tab");
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    newTab(tabbedPane);
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.getContentPane().add(tabbedPane);
          frame.getContentPane().add(button, BorderLayout.SOUTH);
          frame.setSize(400, 200);
          frame.setLocationRelativeTo( null );
          frame.setVisible(true);
          // Select tab 3 and set focus on the last text field.
          tabbedPane.setSelectedIndex(2);
          component.requestFocusInWindow();
     private static JComponent newTab(JTabbedPane tabbedPane)
          columns++;
          JComponent component = null;
          JPanel panel = new JPanel();
          for (int i = 0; i < columns; i++)
               component = new JTextField("TextField" + columns + i);
               panel.add( component );
          tabbedPane.add( panel, "" + columns );
          tabbedPane.setSelectedIndex( tabbedPane.getTabCount() - 1 );
          component.requestFocusInWindow();
          return component;
}

I tested the last code in Java 1.5.0 (build 1.5.0-b64) on a Linux platform, and it does not seem to work. To determine who has the focus, I added a slithy modified DefaultKeyboardManager that printed out the focus owner, when I run the modified code, it seems that the focus is placed on the last textfield when the panes are created before displaying the frame, this works ok however when I created a pane using the button, the focus is on the button and not on the text field. Apparantly pressing the button does a requestFocusInWindow() on the button after the actionPerformed is executed, overruling the requestFocusInWindow() (just my humble opinion). The modified test code follows below:
Marc
package testfocus;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main
     static int columns = 0;
     public static void main(String args[])
          FocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager()
                         public void processKeyEvent(Component c,KeyEvent e)
                              System.out.println("Focus owner: "+c);
                              super.processKeyEvent(c,e);
          final JTabbedPane tabbedPane = new JTabbedPane();
          newTab(tabbedPane);
          newTab(tabbedPane);
          JComponent component = newTab(tabbedPane);
          JButton button = new JButton("Add Tab");
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    newTab(tabbedPane);
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.getContentPane().add(tabbedPane);
          frame.getContentPane().add(button, BorderLayout.SOUTH);
          frame.setSize(400, 200);
          frame.setLocationRelativeTo( null );
          frame.setVisible(true);
          // Select tab 3 and set focus on the last text field.
          tabbedPane.setSelectedIndex(2);
          component.requestFocusInWindow();
     private static JComponent newTab(JTabbedPane tabbedPane)
          columns++;
          JPanel panel = new JPanel();
          tabbedPane.add( panel, "" + columns );
          tabbedPane.setSelectedIndex( tabbedPane.getTabCount() - 1 );
          for (int i = 0; i < columns; i++)
               panel.add( new JTextField("TextField" + columns + i, 5) );
          JTextField component = (JTextField)panel.getComponent(columns - 1);
          component.requestFocusInWindow();
          return component;
}

Similar Messages

  • How to set the focus to the tabbed pane title?

    Dear Friends,
    I'm using tabbed pane (JTabbedPane) in my application. I have 2 tabbed panes and each contain some text fields and buttons.
    In first tabbed, I have 2 text fields, OK and Cancel buttons. I have to set the focus to the title of the tabbed pane after it lost focus from the Cancel button (focus has to move from Cancel button to tabbed pane title by pressing tab key).
    Could anyone please tell me how to set the focus to the tabbed pane title?
    Thanks in advance,
    Sathish kumar D

    Thanks for your reply.
    Could you please tell me how to set focus for title of the tabbed pane throug FocusTraversalPolicy?
    because usually we set the focus for the component by requestFocusInWindow().
    for example set focust to the button OK,
    btnOk.requestFocusInWindow()likewise could you tell me how to set focus to Title of the tabbed pane?
    Sathish kumar D

  • Problem in tabbed panes

    hai friends,
    i am trying to create a tabbed pane which contains 3 panes.(top)
    and i try to add a tabbed pane at bottom of first pane which is a panel.
    i have set the size of panel as panel.setPreferredSize(new Dimension(750, 475));
    Now i am finding i cannot view the tabbed panes added to the panel.
    the relevant code is given below.
    some one have any idea..
    panel.add(new JScrollPane(textArea));
    panel.add(new JScrollPane(table));
    panel.setPreferredSize(new Dimension(750, 475));
    panel.setBackground(Color.PINK);
    JTabbedPane tabbedPane2 = new JTabbedPane     (JTabbedPane.BOTTOM);
    tabbedPane2.add("Result",new JTable(10,10));
    tabbedPane2.add("Message",new JTextArea());
    panel.add(tabbedPane2);
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.addTab("name1", new JScrollPane(panel));
    tabbedPane.addTab("name2",
         new JScrollPane(new JTextArea(5, 5)));
    tabbedPane.addTab("ANALYSIS", new JButton("<   HAI ALL   >"));
    container.add(tabbedPane);
    tabbedPane.setBackground(Color.ORANGE);

    i am giving the code i have done for the development of schema browser.
    i have some what overcome the problem i have faced. but i know its not a proper way.
    i am not able to use other layouts successfully to arrange these components.The layout now i have is not good enough.
    may be because i am beginner.
    kindly give your comments.....
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.border.BevelBorder;
    public class Trial1 extends JFrame implements ActionListener {
         Container container = null;
         private JTextArea textArea;
         private JTextArea result = new JTextArea();
         private JButton connection;
         private JButton execute;
         private ResultSet rs;
         private Connection con;
         public Trial1(String title) {
              super(title);
              container = this.getContentPane();
              container.setBackground(Color.BLACK);
              menu();
              panes();
              makeConnection();
              container.setLayout(new FlowLayout());
              this.setSize(800, 575);
              show();
         void menu() {
              JMenuBar menuBar = new JMenuBar();
              container.add(menuBar, FlowLayout.LEFT);
              menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
              menuBar.setForeground(Color.blue);
              JMenu file = new JMenu("File");
              JMenu edit = new JMenu("Edit");
              JMenu query = new JMenu("Query");
              menuBar.add(file);
              menuBar.add(edit);
              menuBar.add(query);
              file.add(new JMenuItem("New"));
              file.add(new JMenuItem("Open"));
              file.add(new JMenuItem("Save"));
              file.add(new JMenuItem("Save As"));
              file.addSeparator();
              file.add(new JMenuItem("Exit"));
              edit.add(new JMenuItem("Undo"));
              edit.addSeparator();
              edit.add(new JMenuItem("Cut"));
              edit.add(new JMenuItem("Copy"));
              edit.add(new JMenuItem("Paste"));
              edit.addSeparator();
              edit.add(new JMenuItem("Delete"));
              edit.add(new JMenuItem("Select All"));
              query.add(new JMenuItem("Compile"));
              query.add(new JMenuItem("Run"));
              query.add(new JMenuItem("Execute"));
              setJMenuBar(menuBar);
         void panes() {
              JPanel panel = new JPanel();
              textArea = new JTextArea(4, 50);
              textArea.setBorder(BorderFactory.createLineBorder(Color.black));
              JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.BOTTOM);
              JTable table = new JTable(5,10);
              tabbedPane2.add("Result",table);
              table.setBorder(BorderFactory.createLineBorder(Color.black));
              tabbedPane2.add("Message",result);
              tabbedPane2.setPreferredSize(new Dimension(750, 350));
              tabbedPane2.setBackground(Color.ORANGE);
              connection = new JButton("Connection");
              panel.add(connection);
              execute = new JButton("    Execute       ");
              execute.addActionListener(this);
              panel.add(execute);
              panel.add(new JScrollPane(textArea));
              panel.add(tabbedPane2);
              //panel.add(new JScrollPane(table));
              panel.setPreferredSize(new Dimension(750, 475));
              panel.setBackground(Color.PINK);
              //panel.setLayout(new GridLayout(2,3));
              JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
              tabbedPane.addTab("QUERY", new JScrollPane(panel));
              tabbedPane.addTab("SCHEMA BROWSER",
                        new JScrollPane(new JTextArea(5, 5)));
              tabbedPane.addTab("ANALYSIS", new JButton("<   HAI ALL   >"));
              container.add(tabbedPane);
              tabbedPane.setBackground(Color.ORANGE);
         public void actionPerformed(ActionEvent e) {
              Object src = e.getSource();
              /* myArea.getDocument().addDocumentListener( */
              if (src == execute) {
                   String query = textArea.getText();
                   try {
                        Statement smt;
                        smt = null;
                        smt = con.createStatement();
                        rs = smt.executeQuery(query);
                        while (rs.next()) {
                             result.append(rs.getString(1) + "\t" + rs.getInt(2)
                                       + "\n");
                        smt.close();
                   } catch (Exception ae) {
                        ae.printStackTrace();
         void makeConnection() {
              try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection("jdbc:odbc:jmc", "sa", "sprint");
                   //con.close();
                   System.out.println("Connection successfully estabilished.");
              } catch (Exception ae) {
                   ae.printStackTrace();
         public static void main(String arg[]) {
              Trial1 trial = new Trial1(
                        "trials.");
    }

  • Problems on tabbed pane

    Hi
    I want to design Top navigation using tabbed pane. I designed tabbed pane using <rich:tabPanel> and <rich:tab>.this page is common for all the pages. so i want to add some body while adding to another pages.if i am giving body it will display outside the body of rich tabpanel. i want to display my body information if no tabs are selected if i selected any tab tab information also display in the same place....how can i do that...
    Thanks in Advance
    mohan.

    use any plain text or html inside <f:verbatim> it will display under the pane.
    Please use ths following forum for the richfaces related questions:
    http://www.jboss.com/index.html?module=bb&op=viewforum&f=261
    Message was edited by:
    KrishnaS

  • Disposable tabbed pane redrawing

    Hi, i'm using disposable tabbed panes (with close button) in my program and i'm using following method to update their titles according to what user entered:
    //this is class extending JPanel
    public void updatePanelTitle(String newTitle) {
            MainPanel panel = (MainPanel) getParent(); //MainPanel extends JTabbedPane
            panel.setTitleAt(panel.getComponentZOrder(this)-1, newTitle);
            repaint();
        }Point is the title gets changed but the size of panel label does not. However, when i mouse-over the close button there, it gets changed to the size of the text.
    @Override
            public void mouseEntered(MouseEvent e) {
                Component component = e.getComponent();
                if (component instanceof AbstractButton) {
                    AbstractButton button = (AbstractButton) component;
                    button.setBorderPainted(true);
            }setBorderPainted calls inside the repaint method.
    Can anyone give a clue why it is not working or how to fix it?
    Regards,
    Marek

    Well its quite big but if it helps, this is the panel class:
    package presentationTier.view;
    import com.bbgroup.ui.Console;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
    import javax.swing.border.Border;
    import javax.swing.text.BadLocationException;
    import presentationTier.Model.Properties;
    import presentationTier.Model.PropertyInterface;
    import presentationTier.Model.StandardInputOutput;
    import presentationTier.controller.ConfirmListGeneratorAction;
    import presentationTier.controller.ConfirmSearchReplaceAction;
    import presentationTier.controller.OpenBrowseDialogAction;
    * @author marek
    public class ListGeneratorPanel extends JPanel implements StandardInputOutput, PropertyInterface {
        private JLabel labStartPath,  labExtensions;
        private JTextField txtStartPath,  txtExtensions;
        private JButton butBrowse,  butGo;
        private Console console;
        private GridBagConstraints c;
        private Insets labelInsets,  normalInsets;
        public ListGeneratorPanel() {
            super(new GridBagLayout());
            initComponents();
            borderCompononets(BorderFactory.createLoweredBevelBorder());
            resetConstraints();
            c.gridx = 0;
            c.gridy = 0;
            c.insets = labelInsets;
            add(labStartPath, c);
            c.gridx = 1;
            //c.gridwidth = 1;
            c.weightx = 1;
            c.insets = normalInsets;
            add(txtStartPath, c);
            c.gridx = 2;
            //c.gridwidth = 1;
            c.weightx = 0;
            add(butBrowse, c);
            c.gridx = 0;
            c.gridy = 1;
            c.weightx = 0;
            c.insets = labelInsets;
            add(labExtensions, c);
            c.gridx = 1;
            //c.gridwidth = 3;
            c.weightx = 1;
            c.insets = normalInsets;
            add(txtExtensions, c);
            c.gridx = 2;
            c.gridwidth = 1;
            //c.gridheight = 1;
            c.weightx = 0;
            add(butGo, c);
            c.gridx = 0;
            c.gridy = 2;
            c.gridwidth = 5;
            c.weighty = 1;
            add(new JScrollPane(console), c);
            resetConstraints();
        private void initComponents() {
            c = new GridBagConstraints();
            console = new Console(true);
            labelInsets = new Insets(5, 5, 0, 0);
            normalInsets = new Insets(5, 5, 0, 5);
            labStartPath = new JLabel("Search under:");
            labExtensions = new JLabel("File types:");
            txtStartPath = new JTextField();
            txtExtensions = new JTextField();
            butBrowse = new JButton(new OpenBrowseDialogAction(this));
            butGo = new JButton(new ConfirmListGeneratorAction(this));
        private void borderCompononets(Border b) {
            getTxtStartPath().setBorder(b);
            getTxtExtensions().setBorder(b);
        private void resetConstraints() {
            c.ipadx = 0;
            c.ipady = 0;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.weightx = 0;
            c.weighty = 0;
            c.fill = GridBagConstraints.BOTH;
            c.anchor = GridBagConstraints.FIRST_LINE_START;
            c.insets = normalInsets;
        public Properties createProperties() {
            Properties p = new Properties();
            p.setSout(this);
            p.setStartPath(getTxtStartPath().getText());
            p.setExtensions(getTxtExtensions().getText());
            return p;
         * @param line
         * @throws BadLocationException
        public void echo(String line) throws BadLocationException {
            getConsole().echo(line);
         * @param line
         * @param style
         * @throws BadLocationException
        public void echo(String line, String style) throws BadLocationException {
            getConsole().echo(line, style);
        public void drawSeparator() throws BadLocationException {
            getConsole().drawSeparator();
        public void passBrowsedFilePath(String browsedFilePath) {
            getTxtStartPath().setText(browsedFilePath);
        public void updatePanelTitle(String newTitle) {
            MainPanel panel = (MainPanel) getParent();
            panel.setTitleAt(panel.getComponentZOrder(this) - 1, "Generate: " + newTitle);
            updateUI();
            repaint();
        public Console getConsole() {
            return console;
        public JTextField getTxtStartPath() {
            return txtStartPath;
        public JTextField getTxtExtensions() {
            return txtExtensions;
    }When you add instance of this to your JTabbedPane, you will get closeable Tabbed Pane with title you specified in addTab(title, component);
    I implement method updatePanelTitle(String newTitle); to change the title of this tab when suer submits the data. These action controllers that call submitting and updating title are in controller package. Problem is that the title itself is changed when data are submitted but the <b>size of the tab is not adjusted to newTitles length.</b> It is just adjusted when i pull my mouse over the close button that implements action from previous post. It's in this class:
    package com.bbgroup.ui;
    import javax.swing.*;
    import javax.swing.plaf.basic.BasicButtonUI;
    import java.awt.*;
    import java.awt.event.*;
    * Component to be used as tabComponent;
    * Contains a JLabel to show the text and
    * a JButton to close the tab it belongs to
    public class DisposableTabPanel extends JPanel {
        private final JTabbedPane pane;
        public DisposableTabPanel(final JTabbedPane pane) {
            //unset default FlowLayout' gaps
            super(new FlowLayout(FlowLayout.LEFT, 0, 0));
            if (pane == null) {
                throw new NullPointerException("TabbedPane is null");
            this.pane = pane;
            setOpaque(false);
            //make JLabel read titles from JTabbedPane
            JLabel label = new JLabel() {
                @Override
                public String getText() {
                    int i = pane.indexOfTabComponent(DisposableTabPanel.this);
                    if (i != -1) {
                        return pane.getTitleAt(i);
                    return null;
            add(label);
            //add more space between the label and the button
            label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
            //tab button
            JButton button = new TabButton();
            add(button);
            //add more space to the top of the component
            setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
        private class TabButton extends JButton implements ActionListener {
            public TabButton() {
                int size = 17;
                setPreferredSize(new Dimension(size, size));
                setToolTipText("Close this tab");
                //Make the button looks the same for all Laf's
                setUI(new BasicButtonUI());
                //Make it transparent
                setContentAreaFilled(false);
                //No need to be focusable
                setFocusable(false);
                setBorder(BorderFactory.createEtchedBorder());
                setBorderPainted(false);
                //Making nice rollover effect
                //we use the same listener for all buttons
                addMouseListener(buttonMouseListener);
                setRolloverEnabled(true);
                //Close the proper tab by clicking the button
                addActionListener(this);
            public void actionPerformed(ActionEvent e) {
                int i = pane.indexOfTabComponent(DisposableTabPanel.this);
                if (i != -1) {
                    pane.remove(i);
            //we don't want to update UI for this button
            public void updateUI() {
            //paint the cross
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                Graphics2D g2 = (Graphics2D) g.create();
                //shift the image for pressed buttons
                if (getModel().isPressed()) {
                    g2.translate(1, 1);
                g2.setStroke(new BasicStroke(2));
                g2.setColor(Color.BLACK);
                if (getModel().isRollover()) {
                    g2.setColor(Color.MAGENTA);
                int delta = 6;
                g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
                g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
                g2.dispose();
        private final static MouseListener buttonMouseListener = new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
                Component component = e.getComponent();
                if (component instanceof AbstractButton) {
                    AbstractButton button = (AbstractButton) component;
                    button.setBorderPainted(true);
            @Override
            public void mouseExited(MouseEvent e) {
                Component component = e.getComponent();
                if (component instanceof AbstractButton) {
                    AbstractButton button = (AbstractButton) component;
                    button.setBorderPainted(false);
    }I cant possibly post a running code as it uses third party libraries and implements bunch of interfaces, it would require whole nearly whole view-controller part of the project.
    Another problem is that method getComponentZOrder(this) - 1, works for retrieving all tabs except the first one (it returns fine indexes for any tab but -1 for the first one) but sadly there is no such method like getIndex(Component) which would be useful for getting <b>this</b> components index.
    Thanks in advance for ideas.
    Regards, Marek

  • How to a particular panel in a tabbed pane to the front?

    Hello
    I have a small application that uses a tabbed pane. At some point I want to press a button in one of the panels of the tabbed pane and then another panel in the same tabbed pane to show up, as if I had clicked on that tab to bring it to the front.
    Only difference is I don't want to click on the tab to do it but on another button, so I can do some more stuff through the button before I bring the other panel to the front
    I thought I could do this by getting focus, but it seems not to be the case. Getting focus does not mean coming to the front as I originally thought.
    I hope this is clear. Here is an example that you can compile and run. I want to get jpanel2 to the front by clicking jbutton1 and vice versa.
    Any help appreciated.
    (Frame1.java)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Frame1 extends JFrame {
        private JTabbedPane jTabbedPane1 = new JTabbedPane();
        private JPanel jPanel1 = new JPanel();
        private JPanel jPanel2 = new JPanel();
        private JButton jButton1 = new JButton();
        private JButton jButton2 = new JButton();
        private JTextField jTextField1 = new JTextField();
        private JTextField jTextField2 = new JTextField();
        public Frame1() {
            try {
                jbInit();
                this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
        private void jbInit() throws Exception {
            this.getContentPane().setLayout( null );
            this.setSize( new Dimension(400, 300) );
            jTabbedPane1.setBounds(new Rectangle(0, 0, 395, 270));
            jPanel1.setLayout(null);
            jPanel2.setLayout(null);
            jButton1.setText("jButton1");
            jButton1.setBounds(new Rectangle(20, 170, 160, 25));
            jButton1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            jButton1_actionPerformed(e);
            jButton2.setText("jButton2");
            jButton2.setBounds(new Rectangle(20, 135, 160, 25));
            jButton2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            jButton2_actionPerformed(e);
            jTextField1.setBounds(new Rectangle(55, 45, 210, 20));
            jTextField2.setBounds(new Rectangle(95, 50, 180, 20));
            jPanel1.add(jTextField1, null);
            jPanel1.add(jButton1, null);
            jTabbedPane1.addTab("jPanel1", jPanel1);
            jPanel2.add(jTextField2, null);
            jPanel2.add(jButton2, null);
            jTabbedPane1.addTab("jPanel2", jPanel2);
            this.getContentPane().add(jTabbedPane1, null);
        private void jButton1_actionPerformed(ActionEvent e) {
        private void jButton2_actionPerformed(ActionEvent e) {
        public static void main(String[] args) {
            new Frame1();
    }

    tabbedPane.setSelectedIndex(...);

  • Ideas for a "virtually" tabbed pane

    I'm developing on this application for keeping information about products and customers in a shop.
    In my "product manager" window I would like to have tabbed pane with an input interface for different types of goods in each tab respectively. But since the interface is more or less the same for different products (with fields like product name beeing persistent), it would be better to just alter the input components programmatically (in the pane's stateChanged event), rather than having to duplicate components for 7 different tabs... Hope my point gets through. This is strictly a matter of Look & Feel -- this is the most neat sollution i could think of :)

    mannamann wrote:
    I appreciate your commitment to ridding the forums of the "by getters". I know that my question was probably a little superficial, and something that I could have figured out myself. My goal is not to get rid of get byers, but I will want to expend more of my free time and effort helping those where the paybacks for me are greatest -- the highly motivated. It is truly amazing and gratifying to see those of this kind progress.
    But since the primary focus of our project is not GUI-programming, isn't it fair to post a "quicky" here, to draw some knowledge from experts like you? So that I don't have to spend my entire day working out UI, when I prefered to focus on the data model of my program. After all, isn't that what the forum is all about?It's about sharing knowledge, of course, but having said that, you can't ignore the human component either. We're all volunteers, and given our druthers, we'll put in more effort towards those who do likewise. You really can't expect otherwise, right?

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

  • How To use JFile Chooser in a Tabbed Pane Dialog

    I have created a tabbed pane dialog. In one of the tabs I want to add a JFile Chooser.
    How can I approach this problem. also Do I have to use a JDialog with a frame or can I create a JDialog without using a frame and create a instance from the main function.

    I have created a tabbed pane dialog. In one of the
    tabs I want to add a JFile Chooser. Since JFileChooser is a JComponent you could add it to any Container like any other JComponent.
    Maybe you have to do some init by hand which is done normally by the show*() methods of JFileChooser. Taking a look at the source of showDialog() should help.
    Hope that helps,
    Alex

  • Multiple Views of Same Rows from a Tabbed Pane

    I have a Tabbed Pane with several Tabs that access Different Tables. One Table is the child of two different Tables, ie one foreign key on the child that that points to Table A and a second foreign key on the child that points to Table B. I am trying to have a tabbed pane that will show the childs rows one based on the Table A Foreign Key and the second based on the Table B Foreign Key.
    No matter what I have tried, I get only one view from both Tabs. (NOTE: Both of the Tabbed pane that I instantiate from look completly different, ie a different sequence of fields.)
    I have two distinct rowsetinfo's for each tab each with it own distinct Query. I have each MasterLink pointing to the appropriate Master, either Table A or Table B and it doesn't work.
    I have tried to create additional Business components for the second view, but don't know how to link the rowset to the appropriate Business Component, if that's the problem.
    Any help or suggestion would be greatly appreciated, because I'm Lost.

    hi
    i've tried to do that some time ago and i had to give up... unfortunately i think java3D can't use various rendering modes for the same universe
    regards
    GnG

  • Form inside Tabbed Pane

    Hi, I have a JSF Tabbed Pane with 5 tabs and one of the tab's content contains a datascroller with an input text field 'Go To' where the user can enter the page number to jump to. When I hit enter after typing in a page number, it seems like it just refreshes the page (I think it processes as a Tabbed Pane 'tabchangeevent' but in fact it's not). However, after typing in a page number, and manually clicking the 'Go' button, it submits correctly (to the datascroller) and displays the correct content. Any ideas what could be the problem?

    I would try using static, compile time includes rather than runtime includes.

  • Tabbed Panes

    Dear All,
    I have to create a form with tabbed panes. How can i do this using JFC as i m new to JFC. Then i have to submit the form data in the database using JSP. Please help me to solve this.
    Some Code Please
    Thanks & Regards
    Gagan

    gaganarora77,
    This does seem a case of RTFM:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
    Please repost if you have specific problems
    --A                                                                                                                                                                                                                                                                                                                                                           

  • Tab pane height minimum / inconsiste​nt behaviour

    Hi,
    I run into a small but annoying issue with tab controls. (LabView2009f2)
    I want to set the height of the tab control as small as possible.
    - Using property nodes (as in attached example) the minimum height is 31 pixels. With 30 pixels and below an error message is shown ("invalid value").
    - Using the property dialog for the tab I can set height to 1 and setting will be accepted. However after re-opening the dialog the height is changed to 5.
    - After manually setting height to 5, the tab height changes back to 31 as soon as any of the tab properties is changed (like number of tabs, their names, and so on...) - annoying!
    - It doesn't matter if I'm using a classic or a modern style tab.
    So my questions:
    Why is the behaviour inconsistent between changing properties manually and programmatically?
    Why does the tab control allow a height of 5 pixels (atleast by manual setting), but doesn't maintain it afterwards?
    The quick&dirty workaround is to draw a decoration above the tab pane, but using just one property node would be much cleaner...
    Message Edited by GerdW on 11-05-2009 01:46 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    TabPaneHeight.vi ‏9 KB

    Hi,
    thank you for descriping your problem so detailed.
    I've told our R&D department about that. If you want to know about the status you can call the NI Support and ask for information on CAR #195219.
    Actually I don't know when this behaviour will be fixed or if there are only a more detailed informations in the documentation with a minimum value for the tab panel height.
    Sorry I can't tell you more about that right now.
    Thanks for reporting this to us.
    Regards,
    Schilli

  • Adding more rows in a html table(enclosed inside a jsf tabbed pane)

    hi,
    i m facing a problem. i have a html Table inside a jsf Tabbed Pane and a button to add more rows.whenever i click on the button it should add 5 more rows to the table using javscript.
    can anyone hlp me in solving this problem.
    thankx in advance

    Use the elegant JSF h:dataTable instead of plain HTML table with a heap of DOM stuff.

  • Reader X - Firefox focus problem

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

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

Maybe you are looking for

  • Problems with express xy graph

    Hi, I am new to Labview. I am using Labview 8.5. I wish to create a program which reads in an excel spreadsheet and displays the data on an express xy graph. I have been able to read my excel spreadsheet into labview but cannot display a graph in my

  • When I bought my MacBook Pro, I didn't buy the AppleCare PP with it. Now, is it possible for me to buy it separately to cover my MacBook?

    When I bought my MacBook Pro from Apple online store, I didn't buy the AppleCare Protection Plan with it. Now I'm in a different country from where I've bought my MacBook Pro. Is it possible for me to buy AppleCare Protection Plan separately to cover

  • How to embid java code in JavaScript

    Hi!! I am writing JSP program. Do u know how to embid java code in javascirpt ex: <SCRIPT> alert("hello"); <% System.out.println("Hello...Satish. "); %> </SCRIPT> This alert message is not comming when i add the java code.

  • EARLY DELTA INITIALIZATION IN LO COCKPIT

    HI EVERYBODY, SORRY FOR ASKING A SILLY QUESTION --BUT I REALLY NEED AN EXPLANAITION <b>WHAT IS EARLY DELTA INITIALIZATION</b>????(can we select this method the same way we do for Delta init) I KNOW THAT BEFORE DOING DELTA WE WILL DO DELTA INITIALIZAT

  • Dock lights in Mountain Lion

    Is there a way to change the size of the dock lights in Mountain Lion? They are a bit small for me to see.