JTabbedPane exception

does anybody know why BasicTabbedPaneUI throws
the following exception:
java.lang.NullPointerException
     at javax.swing.BoxLayout.checkRequests(Compiled Code)
     at javax.swing.BoxLayout.minimumLayoutSize(Compiled Code)
     at java.awt.Container.minimumSize(Compiled Code)
     at java.awt.Container.getMinimumSize(Compiled Code)
     at javax.swing.JComponent.getMinimumSize(Compiled Code)
     at javax.swing.BoxLayout.checkRequests(Compiled Code)
     at javax.swing.BoxLayout.minimumLayoutSize(Compiled Code)
     at java.awt.Container.minimumSize(Compiled Code)
     at java.awt.Container.getMinimumSize(Compiled Code)
     at javax.swing.JComponent.getMinimumSize(Compiled Code)
     at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout.calculateSize(Compiled Code)
     at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout.minimumLayoutSize(Compiled Code)
     at java.awt.Container.minimumSize(Compiled Code)
     at java.awt.Container.getMinimumSize(Compiled Code)
     at javax.swing.JComponent.getMinimumSize(Compiled Code)
     at javax.swing.BoxLayout.checkRequests(Compiled Code)
     at javax.swing.BoxLayout.preferredLayoutSize(Compiled Code)
     at java.awt.Container.preferredSize(Compiled Code)
     at java.awt.Container.getPreferredSize(Compiled Code)
     at javax.swing.JComponent.getPreferredSize(Compiled Code)
     at javax.swing.BoxLayout.checkRequests(Compiled Code)
     at javax.swing.BoxLayout.preferredLayoutSize(Compiled Code)
     at java.awt.Container.preferredSize(Compiled Code)
     at java.awt.Container.getPreferredSize(Compiled Code)
     at javax.swing.JComponent.getPreferredSize(Compiled Code)
     at javax.swing.BoxLayout.checkRequests(Compiled Code)
     at javax.swing.BoxLayout.layoutContainer(Compiled Code)
     at java.awt.Container.layout(Compiled Code)
     at java.awt.Container.doLayout(Compiled Code)
     at java.awt.Container.validateTree(Compiled Code)
     at java.awt.Container.validateTree(Compiled Code)
     at java.awt.Container.validate(Compiled Code)
     at javax.swing.RepaintManager.validateInvalidComponents(Compiled Code)
     at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Compiled Code)
     at javax.swing.SystemEventQueueUtilities.processRunnableEvent(Compiled Code)
     at javax.swing.SystemEventQueueUtilities.access$1(Compiled Code)
     at javax.swing.SystemEventQueueUtilities$RunnableTarget.processEvent(Compiled Code)
     at java.awt.Component.dispatchEventImpl(Compiled Code)
     at java.awt.Component.dispatchEvent(Compiled Code)
     at java.awt.EventDispatchThread.run(Compiled Code)
Exception occurred during event dispatching:
java.lang.NullPointerException
     at javax.swing.SizeRequirements.calculateAlignedPositions(Compiled Code)
     at javax.swing.BoxLayout.layoutContainer(Compiled Code)
     at java.awt.Container.layout(Compiled Code)
     at java.awt.Container.doLayout(Compiled Code)

This looks like you have tried to add a component to the tabbed pane which has not been initialised/constructed. NullPointerExceptions in GUIs almost always occur in such a situation.
e.g.
public class MyPanel extends JPanel {
  private JLabel myLabel;
  public MyPanel() {
    super();
    // This line will throw a null pointer exception because 'myLabel' has not been instantiated yet
    add(myLabel);   
}

Similar Messages

  • JTabbedPane: Exception occurred during event dispatching:

    Hi,
    I have a JTabbedPane where the tabs can be added dynamically by the method:
    private void addNewTab(JTable aTable) throws java.lang.NullPointerException
    final JTable t = aTable;
    Thread addTab = new Thread()
    public void run()
    JScrollPane scroller = new JScrollPane();
    JTable table;
    if (t==null)
    table = new JTable(columns, 0);
    else
    table = t;
    table.setColumnsEditable(colEditable);
    cachedTables.addElement(table);
    scroller.getViewport().setView(table);
    jtp.insertTab("Tab " + cachedTables.size(), null, scroller, "Tab", cachedTables.size()-1);
    jtp.updateUI();
    SwingUtilities.invokeLater(new Runnable()
    public void run()
    jtp.setSelectedIndex(cachedTables.size()-1);
    jtp.validate();
    addTab.start();
    The problem is that occasionally (20% of the times) I receive this exception:
    Exception occurred during event dispatching:
    java.lang.NullPointerException
         at javax.swing.plaf.basic.BasicTabbedPaneUI.rotateInsets(BasicTabbedPaneUI.java:1159)
         at javax.swing.plaf.basic.BasicTabbedPaneUI.getTabAreaInsets(BasicTabbedPaneUI.java:951)
         at javax.swing.plaf.basic.BasicTabbedPaneUI.calculateTabAreaHeight(BasicTabbedPaneUI.java:924)
         at javax.swing.plaf.basic.BasicTabbedPaneUI.paintContentBorder(BasicTabbedPaneUI.java:637)
         at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(BasicTabbedPaneUI.java:358)
         at javax.swing.plaf.ComponentUI.update(ComponentUI.java:39)
         at javax.swing.JComponent.paintComponent(JComponent.java:395)
         at javax.swing.JComponent.paint(JComponent.java:687)
         at javax.swing.JComponent.paintChildren(JComponent.java:498)
         at javax.swing.JComponent.paint(JComponent.java:696)
         at javax.swing.JComponent.paintWithBuffer(JComponent.java:3878)
         at javax.swing.JComponent._paintImmediately(JComponent.java:3821)
         at javax.swing.JComponent.paintImmediately(JComponent.java:3672)
         at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
         at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
    Does none know, how I can solve the problem?
    Thanks,
    Diego.

    Fix the NullPointerException. The stack trace tells you the line that caused the problem.

  • Exception with JTabbedPane

    In my project, I build a dialog box. I build a JTabbedPane within. Each tab is a panel with JChecxBox. When I add my first panel using the method addTab() no problem, with my second panel still no problem. When I try adding a third, an exception occurs: java.lang.ArrayIndexOutOfBoundsException: 2>1
    I have also used the method printStackTrace to know what's going on:
    java.lang.ArrayIndexOutOfBoundsException: 2 > 1
         at java.util.Vector.insertElementAt(Vector.java:551)
         at javax.swing.JTabbedPane.insertTab(JTabbedPane.java:441)
         at javax.swing.JTabbedPane.addTab(JTabbedPane.java:512)
         at myprojects.hopital.Cl�sComp.<init>(Cl�sComp.java:113)
         at myprojects.hopital.Hopital$1$MenuAction.actionPerformed(Hopital.java:72)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1504)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:279)
         at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:886)
         at java.awt.Component.processMouseEvent(Component.java:3717)
         at java.awt.Component.processEvent(Component.java:3546)
         at java.awt.Container.processEvent(Container.java:1164)
         at java.awt.Component.dispatchEventImpl(Component.java:2595)
         at java.awt.Container.dispatchEventImpl(Container.java:1213)
         at java.awt.Component.dispatchEvent(Component.java:2499)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
         at java.awt.Container.dispatchEventImpl(Container.java:1200)
         at java.awt.Window.dispatchEventImpl(Window.java:912)
         at java.awt.Component.dispatchEvent(Component.java:2499)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
         at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
    It seems that addTab call insertTab calling himself insertElementAt which throw this exception? I don't understand what's going on. Here my code for my DialogBox:
    package myprojects.hopital;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.util.*;
    //import java.lang.*;
    public class Cl�sComp extends JDialog {
         Comparateur[] cl�s;
         int nbCl�s;
         boolean ok;
         JCheckBox jcbAdd;
         JCheckBox jcbMoy;
         JCheckBox jcbM�d;
         JCheckBox jcbEct;
         JCheckBox jcbSamj;
         JCheckBox jcbAll;
         JCheckBox jcbProv;
         JCheckBox jcbTadm;
         JCheckBox jcbTpat;
         JCheckBox jcbAmoy;
         JCheckBox jcbAmed;
         JCheckBox jcbAect;
         JCheckBox jcbVobsinf;
         public Cl�sComp(){
              super((JFrame)null,"Choix des cl�s de comparaisons",true);
              Container contentPane=getContentPane();
              //setLayout(new GridBagLayout());
              nbCl�s=0;
              cl�s=new Comparateur[10];
              class ButtonAction implements ActionListener
                   public void actionPerformed(ActionEvent e) {
                        String commande;
                        commande=e.getActionCommand();
                        if (commande.compareTo("Cancel")==0){
                             hide();
                        if (commande.compareTo("OK")==0){
                             if (jcbAdd.isSelected()) {
                                  Comparateur c=new Comparateur(1);
                                  addCl�(c);
                                  ok=true;
                             if (jcbMoy.isSelected()) {
                                  Comparateur c=new CompMoy(0);
                                  addCl�(c);
                                  ok=true;
                             if (jcbM�d.isSelected()) {
                                  Comparateur c=new CompMed(0);
                                  addCl�(c);
                                  ok=true;
                             if (jcbEct.isSelected()) {
                                  Comparateur c=new CompET(0);
                                  addCl�(c);
                                  ok=true;
                             if (jcbSamj.isSelected()) {
                                  Comparateur c=new CompSAMJ(0);
                                  addCl�(c);
                                  ok=true;
                             hide();
              JTabbedPane jtpMisc=new JTabbedPane();
              JPanel jpCheckBox=new JPanel(new GridLayout(2,2));
              jcbAdd=new JCheckBox("Nombre");
              jcbMoy=new JCheckBox("Moyenne");
              jcbM�d=new JCheckBox("M�diane");
              jcbEct=new JCheckBox("Ecart-type");
              jcbSamj=new JCheckBox("Sapi activit� moyenne");
              jcbAll=new JCheckBox("Tout");
              jcbProv=new JCheckBox("Provenance");
              jcbTadm=new JCheckBox("Type d'admission");
              jcbTpat=new JCheckBox("Type de pathologie");
              jcbAmoy=new JCheckBox("Moyenne");
              jcbAmed=new JCheckBox("M�diane");
              jcbAect=new JCheckBox("Ecart-Type");
              jpCheckBox.add(jcbAdd);
              jpCheckBox.add(jcbMoy);
              jpCheckBox.add(jcbM�d);
              jpCheckBox.add(jcbEct);
              jpCheckBox.add(jcbSamj);
              jtpMisc.addTab("Divers",null,jpCheckBox,"C'est compl�tement foireux");
              jtpMisc.setSelectedIndex(0);
              JPanel jpParamPhys=new JPanel();
              jcbVobsinf=new JCheckBox("Valeur obs. inf.");
              jpParamPhys.add(jcbVobsinf);
              jtpMisc.addTab("Param�tres physiologiques",jpParamPhys);
              JPanel jpActivit�s=new JPanel();
              jpActivit�s.add(jcbProv);
              JPanel jpSapiSev=new JPanel();
              jpSapiSev.add(jcbTpat);
              JPanel jpSapiAct=new JPanel();
              jpSapiAct.add(jcbTadm);
    try{     jtpMisc.addTab("Activit�s",jpParamPhys);
         //     jtpMisc.addTab("SAPI-SEVERITE",jpParamPhys);
         //     jtpMisc.addTab("SAPI-ACTIVITE",jpParamPhys);
         catch(Exception e){
              System.out.println(e.toString());
              System.out.println(e.getMessage());
              System.out.println(e.getLocalizedMessage());
              try{e.printStackTrace(new PrintStream(new FileOutputStream("c:\\Beno�t\\error.txt")));}
              catch(Exception exc){System.out.println("Encore une exception, putain");}
              ButtonAction bAction=new ButtonAction();
              JPanel jpButton=new JPanel(new GridLayout(1,2));
              JButton jbOk=new JButton("OK");
              JButton jbCancel=new JButton("Cancel");
              jpButton.add(jbOk);
              jpButton.add(jbCancel);
              jbCancel.addActionListener(bAction);
              jbOk.addActionListener(bAction);
              contentPane.add(jpButton,BorderLayout.SOUTH);
              contentPane.add(jtpMisc,BorderLayout.CENTER);
         //     contentPane.add(jpCheckBox,BorderLayout.CENTER);
              setSize(500,400);
              setLocation(200,150);
         public Comparateur getCl�(int index){
              return cl�s[index];
         public boolean ok(){
              return ok;
         public int getNbCl�s(){
              return nbCl�s;
         public void addCl�(Comparateur c){
              nbCl�s++;
              cl�s[nbCl�s-1]=c;
    }

    Conceptually wrong.
    Hints: every tab in a JTabbedPane is a JPanel in fact.

  • JTabbedPane gives ArrayIndexOutof Bounds Exception

    I have a project where I am using a JTabbedPane that has 5 tabs.
    Every now and then I receive the following error. The error is not consistent and generally occurs at start up. I am using JBuilder5 (jdk1.3) on a Windows 2000 machine.
    Any help will be appreciated.
    Thanks
    V Shah
    Exception occurred during event dispatching:
    java.lang.ArrayIndexOutOfBoundsException
         at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(BasicTabbedPaneUI.java:343)
         at javax.swing.plaf.metal.MetalTabbedPaneUI.paint(MetalTabbedPaneUI.java:664)
         at javax.swing.plaf.metal.MetalTabbedPaneUI.update(MetalTabbedPaneUI.java:559)
         at javax.swing.JComponent.paintComponent(JComponent.java:398)
         at javax.swing.JComponent.paint(JComponent.java:739)
         at javax.swing.JComponent.paintChildren(JComponent.java:523)
         at javax.swing.JComponent.paint(JComponent.java:748)
         at javax.swing.JComponent.paintWithBuffer(JComponent.java:4393)
         at javax.swing.JComponent._paintImmediately(JComponent.java:4336)
         at javax.swing.JComponent.paintImmediately(JComponent.java:4187)
         at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
         at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:205)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:134)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:101)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:96)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:88)

    Looks to me as if you are looping too far when you add tabs to your TabbedPane...check your logic. Your stack trace is worthless without posting code.

  • Unicode font usage with jTabbedPane

    Hey there
    I faced a problem when I use Unicode characters on JTabbedPane
    the font is amharic power geez unicode1 and it works fine with jLabel and partially with jButtons ( except trying to set text at run time )
    The problem with jTabbedpane is that when I change its tab title property the other tabs disappear ( am using netbeans 5.5 )

    To me, it looks as if your problem is that you're only calling setFont on "this".
    That's only going to set it for the top level frame, and doesn't always do it for every individual component. The easy way to get around this is to go berserk with the setFont call. Set it on anything (heck, set it on your dog if it makes you feel any better)! ;D
    The slightly harder but smarter way to do this is to write a recursive function that drills down your component list.
    public void setFontRecursively(Font myFont, Component comp) {
       comp.setFont(myFont);
       if (comp instanceof Container) {
          Component[] childComps = ((Container)comp).getComponents();
          if (childComps != null) {
             for (int i=0; i < childComps.length; i++) {
                setFontRecursively(myFont, childComps);
    That should basically cover anything bar popup menus and drop-down submenus. You have to recall this as they appear, or they don't get the font straight off.
    Hope that helps!
    Martin Hughes

  • Resize Jpanel and JtabbedPane

    Hi All,
    i implement a resize process on jpanel that include JtabbedPane inside.
    it working fine except one thing.
    when i resize my panel it work fine, until some point it start to shrink and get smaller.
    i think it getting shrink because im getting to the end of my dialog.
    i want to avoid this beheviour and let the tabbedpanel extend as much as possible:
    this is my code:
    package test;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GraphicsConfiguration;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.HeadlessException;
    import java.awt.Point;
    import javax.swing.BorderFactory;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTabbedPane;
    import javax.swing.SwingUtilities;
    public class BaseMain extends JFrame {
         Point sp;
         int     jPanelStartHeight;
         int     jPanelStartWidth;
         int     jTabPaneStartHeight;
         int     jTabPaneStartWidth;
         Point offset;
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JPanel jPanel = null;
         private JTabbedPane jTabbedPane = null;
         private JPanel jPanel1 = null;
         private JTabbedPane jTabbedPane1 = null;
         private JPanel jPanel2 = null;
         private JTabbedPane jTabbedPane2 = null;
         public BaseMain() throws HeadlessException {
              // TODO Auto-generated constructor stub
              super();
              initialize();
         public BaseMain(GraphicsConfiguration arg0) {
              super(arg0);
              // TODO Auto-generated constructor stub
              initialize();
         public BaseMain(String arg0) throws HeadlessException {
              super(arg0);
              // TODO Auto-generated constructor stub
              initialize();
         public BaseMain(String arg0, GraphicsConfiguration arg1) {
              super(arg0, arg1);
              // TODO Auto-generated constructor stub
              initialize();
          * This method initializes jPanel     
          * @return javax.swing.JPanel     
         private JPanel getJPanel() {
              if (jPanel == null) {
                   GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
                   gridBagConstraints1.fill = GridBagConstraints.BOTH;
                   gridBagConstraints1.weighty = 1.0;
                   gridBagConstraints1.weightx = 1.0;
                   gridBagConstraints1.gridheight=3;
                   jPanel = new JPanel();
                   jPanel.setLayout(new BorderLayout());
                   jPanel.setBorder(BorderFactory.createLineBorder(Color.black, 2));
                   jPanel.add(getJTabbedPane(),BorderLayout.SOUTH/* gridBagConstraints1*/);
                   jPanel.addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mousePressed(java.awt.event.MouseEvent e) {
                             System.out.println("mousePressed()"); // TODO Auto-generated Event stub mousePressed()
                             //original size
                             jPanelStartHeight = jPanel.getHeight();
                             jPanelStartWidth  = jPanel.getWidth();
                             jTabPaneStartHeight = jTabbedPane.getHeight();
                             jTabPaneStartWidth  = jTabbedPane.getWidth();
                              offset = SwingUtilities.convertPoint(e.getComponent(),e.getPoint(),jPanel);
                   jPanel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
                        public void mouseDragged(java.awt.event.MouseEvent e) {
                             System.out.println("mouseDragged()"); // TODO Auto-generated Event stub mouseDragged()
                             Point p = SwingUtilities.convertPoint(e.getComponent(),e.getPoint(), jContentPane);
                             jPanel.setSize(jPanelStartWidth,p.y+jPanelStartHeight);
                             jTabbedPane.setSize(jTabPaneStartWidth,p.y+jTabPaneStartHeight);
                             jPanel.setLocation(0/*p.x-offset.x*/,p.y-offset.y);
              return jPanel;
          * This method initializes jTabbedPane     
          * @return javax.swing.JTabbedPane     
         private JTabbedPane getJTabbedPane() {
              if (jTabbedPane == null) {
                   jTabbedPane = new JTabbedPane();
                   jTabbedPane.addTab(null, null, getJPanel1(), null);
                   jTabbedPane.addTab(null, null, getJPanel2(), null);
              return jTabbedPane;
          * This method initializes jPanel1     
          * @return javax.swing.JPanel     
         private JPanel getJPanel1() {
              if (jPanel1 == null) {
                   GridBagConstraints gridBagConstraints = new GridBagConstraints();
                   gridBagConstraints.fill = GridBagConstraints.BOTH;
                   gridBagConstraints.weighty = 1.0;
                   gridBagConstraints.weightx = 1.0;
                   jPanel1 = new JPanel();
                   jPanel1.setLayout(new GridBagLayout());
                   jPanel1.add(getJTabbedPane1(), gridBagConstraints);
              return jPanel1;
          * This method initializes jTabbedPane1     
          * @return javax.swing.JTabbedPane     
         private JTabbedPane getJTabbedPane1() {
              if (jTabbedPane1 == null) {
                   jTabbedPane1 = new JTabbedPane();
              return jTabbedPane1;
          * This method initializes jPanel2     
          * @return javax.swing.JPanel     
         private JPanel getJPanel2() {
              if (jPanel2 == null) {
                   GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
                   gridBagConstraints2.fill = GridBagConstraints.BOTH;
                   gridBagConstraints2.weighty = 1.0;
                   gridBagConstraints2.weightx = 1.0;
                   jPanel2 = new JPanel();
                   jPanel2.setLayout(new GridBagLayout());
                   jPanel2.add(getJTabbedPane2(), gridBagConstraints2);
              return jPanel2;
          * This method initializes jTabbedPane2     
          * @return javax.swing.JTabbedPane     
         private JTabbedPane getJTabbedPane2() {
              if (jTabbedPane2 == null) {
                   jTabbedPane2 = new JTabbedPane();
              return jTabbedPane2;
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        BaseMain thisClass = new BaseMain();
                        thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        thisClass.setVisible(true);
          * This method initializes this
          * @return void
         private void initialize() {
              this.setSize(300, 200);
              this.setContentPane(getJContentPane());
              this.setTitle("JFrame");
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJPanel(), BorderLayout.SOUTH);
              return jContentPane;
    }

    hey gabi,
    i tried your code and it works just fine.... there is no shrinking or any resizing problem?! i don't know... maybe i just don't get it? so maybe u could describe your problem a little more?!
    :)

  • Property change listener error with jtabbedpane

    Greetings
    I have a property change listener on my jtabbedpane (2 panes (index 0 of course and index 1). my problem is when i want to run my app it gives me a java null pointer exception. I believe it is b/c it is starting the app and it see the property change of the first tab at index 0 which is the first tab it sees and tries to run the method that makes the buttons visibility to true. but the buttons are already true. Basically how can I get the property change to run only after the app is visible? I made the buttons visibility false on startup to see if it can run the app but I still got the same error. I hope I am clear enough, if I am not please and I will attempt to reiterate the situation better. thanks for anyones help.
    tabs = new JTabbedPane();
              tabs.addChangeListener(this);
              tabs.setPreferredSize(new java.awt.Dimension(800, 400));
              tabs.addTab("Q", tab1.getMa());
              tabs.addTab("R", tab2);
      public void stateChanged(ChangeEvent changeEvent) {
                JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
               int index = sourceTabbedPane.getSelectedIndex();
               //System.out.println("Tab changed to: " + sourceTabbedPane.getTitleAt(index)+"  Index: "+index);
               if (index==1){
                         changeButtonsF();
                             ///makes buttons false on side panel
               else if (index==0){
                    changeButtonsT();
                     //makes buttons true on side panel
           }

    Basically how can I get the property change to run only after the app is visible?Add the PropertyChangeListener to the tabbed pane after the JFrame is visible.
    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.

  • JTabbedPane, JPane PROBLEM

    Hi!, I have a several problem with JApplet, this is the code:
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    public class NuevoApplet extends JApplet{
    JMenuBar menuBar;
    JMenu menuArchivo, submenu;
    JMenuItem menuNuevo;
    JTabbedPane Tabbed1 = new JTabbedPane();
    JPanel Panel = new JPanel();
    class EventHandler implements ActionListener
              public void actionPerformed(ActionEvent e)
                   //Si se elige salir en el menu
                   if (e.getSource() == menuNuevo)
                        CreaTab();
    ActionListener eventHandler = new EventHandler();
    public void start(){}
    public void init () {
    try {
    UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
    } catch (Exception e) { }
    Panel.setBorder(BorderFactory.createEtchedBorder());
    Panel.setLayout(new java.awt.BorderLayout());
    this.Panel.updateUI();
    this.setContentPane(this.Panel);
    this.CreaMenus();
    this.getContentPane().add(this.Tabbed1,java.awt.BorderLayout.CENTER);
    initConnections();
    private void CreaMenus(){
    //Creamos la barra de men�s
    menuBar = new JMenuBar();
    this.setJMenuBar(menuBar);
    //Creamos el men� de Archivo
    menuArchivo = new JMenu("Archivo");
    menuBar.add(menuArchivo);
    //Creamos los elementos del men� archivo
    menuNuevo = new JMenuItem("Abrir Archivo *.hex");
    menuArchivo.add(menuNuevo);     
    public void initConnections()
    //se suscriben todas las componentes que quieren escuchar los eventos
         menuNuevo.addActionListener(eventHandler);
    public void CreaTab(){
    JPanel a = new JPanel();
    Entorno1 b = new Entorno1();
    a.add(new JButton("BOTON1"),java.awt.BorderLayout.CENTER);
    a.add(new JButton("BOTON2"),java.awt.BorderLayout.EAST);
    this.Tabbed1.addTab("Primera Pesta�a", b); --> PROBLEM, not insert the JPanel b extends Entorno1
         b.repaint();
         Tabbed1.invalidate();
    Tabbed1.getParent().invalidate();
    Tabbed1.validate();
    Tabbed1.repaint();
         this.Tabbed1.updateUI();
         /*this.Tabbed1.validate();
         this.Tabbed1.updateUI();
         this.Tabbed1.revalidate();*/
    public class Entorno1 extends JPanel{
    public void Entorno1(){
         setLayout(new BorderLayout());
         Border raisedBevel = BorderFactory.createRaisedBevelBorder();
    Border loweredBevel = BorderFactory.createLoweredBevelBorder();
    Border compound = BorderFactory.createCompoundBorder
    (raisedBevel, loweredBevel);
    this.setBorder(compound);
    this.add(new JButton("Boton1"),java.awt.BorderLayout.CENTER);
    this.add(new JButton("Boton2"),java.awt.BorderLayout.EAST);
    this.updateUI();
    this.setVisible(true);
    this.revalidate();
    this.repaint();
    } //Fin de la clase Applet16F84
    When I use b extends Entorno1 and I insert as JPanel of JTabbedPane, not show it.
    this.Tabbed1.addTab("Primera Pesta�a", b);
    But this yes show it:
    this.Tabbed1.addTab("Primera Pesta�a", a);
    Why ? ..
    Thanks !

    Your constructor is actually a method and not a constructor.
    Therefore calling new Entorno1() returns you a blank panel.
    change this
    public void Entorno1(){
    ...to this.
    public Entorno1(){that should do it..
    nes

  • JTabbedPane with one close button for all tabs

    Hello,
    there have several solutions been posted for JTabbedPane subclasses that provide tabs with icons working as close buttons on each tab. I think this is not user friendly because the user can hit the close button accidentally when selecting a tab. And a "really close?" dialog is clumsy.
    Therefore I prefer the Netscape browser style: There's only one close button rightmost of the tabs that closes the selected tab. But I don't have an idea how to achieve this.
    Does anyone have a solution or an idea? Thanks in advance for help.

    This solution has been posted several times and is not what I wanted. But I rewrote the thing so that
    - the close buttons are on the right hand side of each tab so that it is conformant with Eclipse style, and
    - the close buttons work only with a left click (see code below).
    I just wonder how I can move the text a little bit to the left so that the appearence is a bit more balanced. Can someone help, please?
    import java.awt.Color;
    import java.awt.FontMetrics;
    import java.awt.Graphics;
    import java.awt.Rectangle;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.plaf.basic.BasicTabbedPaneUI;
    class TabbedPaneCloseButtonUI extends BasicTabbedPaneUI {
        public TabbedPaneCloseButtonUI() {
            super();
        protected void paintTab(
            Graphics g,
            int tabPlacement,
            Rectangle[] rects,
            int tabIndex,
            Rectangle iconRect,
            Rectangle textRect) {
            super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect);
            Rectangle rect = rects[tabIndex];
            g.setColor(Color.black);
            g.drawRect(rect.x + rect.width -19, rect.y + 4, 13, 12);
            g.drawLine(
                rect.x + rect.width -16,
                rect.y + 7,
                rect.x + rect.width -10,
                rect.y + 13);
            g.drawLine(
                rect.x + rect.width -10,
                rect.y + 7,
                rect.x + rect.width -16,
                rect.y + 13);
            g.drawLine(
                rect.x + rect.width -15,
                rect.y + 7,
                rect.x + rect.width -9,
                rect.y + 13);
            g.drawLine(
                rect.x + rect.width -9,
                rect.y + 7,
                rect.x + rect.width -15,
                rect.y + 13);
        protected int calculateTabWidth(
            int tabPlacement,
            int tabIndex,
            FontMetrics metrics) {
            return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + 24;
        protected MouseListener createMouseListener() {
            return new MyMouseHandler();
        class MyMouseHandler extends MouseHandler {
            public MyMouseHandler() {
                super();
            public void mouseReleased(MouseEvent e) {
                int x = e.getX();
                int y = e.getY();
                int tabIndex = -1;
                int tabCount = tabPane.getTabCount();
                for (int i = 0; i < tabCount; i++) {
                    if (rects.contains(x, y)) {
    tabIndex = i;
    break;
         if (tabIndex >= 0 && ! e.isPopupTrigger()) {
    Rectangle tabRect = rects[tabIndex];
    y = y - tabRect.y;
    if ((x >= tabRect.x + tabRect.width - 18)
    && (x <= tabRect.x + tabRect.width - 8)
    && (y >= 5)
    && (y <= 15)) {
    tabPane.remove(tabIndex);
    import java.awt.BorderLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTabbedPane;
    public class TabbedPaneWithCloseButtons {
    JFrame frame;
    JTabbedPane tabPane;
    public TabbedPaneWithCloseButtons() throws Exception {
    frame=new JFrame();
    frame.getContentPane().setLayout(new BorderLayout());
    tabPane=new JTabbedPane();
    tabPane.addTab("test1xxxxxxxxxxxxxx", new JLabel("1"));
    tabPane.addTab("test2xxxxxxxxxxxxxxxxxxx", new ImageIcon("images/icon.gif"), new JLabel("2"));
    tabPane.addTab("test3xxxxxxxx", new JLabel("3"));
    tabPane.setUI(new TabbedPaneCloseButtonUI());
    frame.getContentPane().add(tabPane);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200,200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    public static void main(String[] args) throws Exception {
    TabbedPaneWithCloseButtons test=new TabbedPaneWithCloseButtons();

  • JTabbedPane with close Icons

    Ok, so I was trying to get a JTabbedPane with 'X' icons on each tab. Searched this site, and found no answers, but loads of questions on how to do it. I've done it now, and here's my code.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * A JTabbedPane which has a close ('X') icon on each tab.
    * To add a tab, use the method addTab(String, Component)
    * To have an extra icon on each tab (e.g. like in JBuilder, showing the file type) use
    * the method addTab(String, Component, Icon). Only clicking the 'X' closes the tab.
    public class JTabbedPaneWithCloseIcons extends JTabbedPane implements MouseListener {
      public JTabbedPaneWithCloseIcons() {
        super();
        addMouseListener(this);
      public void addTab(String title, Component component) {
        this.addTab(title, component, null);
      public void addTab(String title, Component component, Icon extraIcon) {
        super.addTab(title, new CloseTabIcon(extraIcon), component);
      public void mouseClicked(MouseEvent e) {
        int tabNumber=getUI().tabForCoordinate(this, e.getX(), e.getY());
        if (tabNumber < 0) return;
        Rectangle rect=((CloseTabIcon)getIconAt(tabNumber)).getBounds();
        if (rect.contains(e.getX(), e.getY())) {
          //the tab is being closed
          this.removeTabAt(tabNumber);
      public void mouseEntered(MouseEvent e) {}
      public void mouseExited(MouseEvent e) {}
      public void mousePressed(MouseEvent e) {}
      public void mouseReleased(MouseEvent e) {}
    * The class which generates the 'X' icon for the tabs. The constructor
    * accepts an icon which is extra to the 'X' icon, so you can have tabs
    * like in JBuilder. This value is null if no extra icon is required.
    class CloseTabIcon implements Icon {
      private int x_pos;
      private int y_pos;
      private int width;
      private int height;
      private Icon fileIcon;
      public CloseTabIcon(Icon fileIcon) {
        this.fileIcon=fileIcon;
        width=16;
        height=16;
      public void paintIcon(Component c, Graphics g, int x, int y) {
        this.x_pos=x;
        this.y_pos=y;
        Color col=g.getColor();
        g.setColor(Color.black);
        int y_p=y+2;
        g.drawLine(x+1, y_p, x+12, y_p);
        g.drawLine(x+1, y_p+13, x+12, y_p+13);
        g.drawLine(x, y_p+1, x, y_p+12);
        g.drawLine(x+13, y_p+1, x+13, y_p+12);
        g.drawLine(x+3, y_p+3, x+10, y_p+10);
        g.drawLine(x+3, y_p+4, x+9, y_p+10);
        g.drawLine(x+4, y_p+3, x+10, y_p+9);
        g.drawLine(x+10, y_p+3, x+3, y_p+10);
        g.drawLine(x+10, y_p+4, x+4, y_p+10);
        g.drawLine(x+9, y_p+3, x+3, y_p+9);
        g.setColor(col);
        if (fileIcon != null) {
          fileIcon.paintIcon(c, g, x+width, y_p);
      public int getIconWidth() {
        return width + (fileIcon != null? fileIcon.getIconWidth() : 0);
      public int getIconHeight() {
        return height;
      public Rectangle getBounds() {
        return new Rectangle(x_pos, y_pos, width, height);
    }You can also specify an extra icon to put on each tab. Read my comments on how to do it.

    With the following code you'll be able to have use SCROLL_TAB_LAYOUT and WRAP_TAB_LAYOUT. With setCloseIcons() you'll be able to set images for the close-icons.
    The TabbedPane:
    import javax.swing.Icon;
    import javax.swing.JComponent;
    import javax.swing.JTabbedPane;
    import javax.swing.JViewport;
    import javax.swing.SwingUtilities;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.FontMetrics;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.event.EventListenerList;
    import javax.swing.plaf.basic.BasicTabbedPaneUI;
    import javax.swing.plaf.metal.MetalTabbedPaneUI;
    * A JTabbedPane which has a close ('X') icon on each tab.
    * To add a tab, use the method addTab(String, Component)
    * To have an extra icon on each tab (e.g. like in JBuilder, showing the file
    * type) use the method addTab(String, Component, Icon). Only clicking the 'X'
    * closes the tab.
    public class CloseableTabbedPane extends JTabbedPane implements MouseListener,
      MouseMotionListener {
       * The <code>EventListenerList</code>.
      private EventListenerList listenerList = null;
       * The viewport of the scrolled tabs.
      private JViewport headerViewport = null;
       * The normal closeicon.
      private Icon normalCloseIcon = null;
       * The closeicon when the mouse is over.
      private Icon hooverCloseIcon = null;
       * The closeicon when the mouse is pressed.
      private Icon pressedCloseIcon = null;
       * Creates a new instance of <code>CloseableTabbedPane</code>
      public CloseableTabbedPane() {
        super();
        init(SwingUtilities.LEFT);
       * Creates a new instance of <code>CloseableTabbedPane</code>
       * @param horizontalTextPosition the horizontal position of the text (e.g.
       * SwingUtilities.TRAILING or SwingUtilities.LEFT)
      public CloseableTabbedPane(int horizontalTextPosition) {
        super();
        init(horizontalTextPosition);
       * Initializes the <code>CloseableTabbedPane</code>
       * @param horizontalTextPosition the horizontal position of the text (e.g.
       * SwingUtilities.TRAILING or SwingUtilities.LEFT)
      private void init(int horizontalTextPosition) {
        listenerList = new EventListenerList();
        addMouseListener(this);
        addMouseMotionListener(this);
        if (getUI() instanceof MetalTabbedPaneUI)
          setUI(new CloseableMetalTabbedPaneUI(horizontalTextPosition));
        else
          setUI(new CloseableTabbedPaneUI(horizontalTextPosition));
       * Allows setting own closeicons.
       * @param normal the normal closeicon
       * @param hoover the closeicon when the mouse is over
       * @param pressed the closeicon when the mouse is pressed
      public void setCloseIcons(Icon normal, Icon hoover, Icon pressed) {
        normalCloseIcon = normal;
        hooverCloseIcon = hoover;
        pressedCloseIcon = pressed;
       * Adds a <code>Component</code> represented by a title and no icon.
       * @param title the title to be displayed in this tab
       * @param component the component to be displayed when this tab is clicked
      public void addTab(String title, Component component) {
        addTab(title, component, null);
       * Adds a <code>Component</code> represented by a title and an icon.
       * @param title the title to be displayed in this tab
       * @param component the component to be displayed when this tab is clicked
       * @param extraIcon the icon to be displayed in this tab
      public void addTab(String title, Component component, Icon extraIcon) {
        boolean doPaintCloseIcon = true;
        try {
          Object prop = null;
          if ((prop = ((JComponent) component).
                        getClientProperty("isClosable")) != null) {
            doPaintCloseIcon = (Boolean) prop;
        } catch (Exception ignored) {/*Could probably be a ClassCastException*/}
        super.addTab(title,
                     doPaintCloseIcon ? new CloseTabIcon(extraIcon) : null,
                     component);
        if (headerViewport == null) {
          for (Component c : getComponents()) {
            if ("TabbedPane.scrollableViewport".equals(c.getName()))
              headerViewport = (JViewport) c;
       * Invoked when the mouse button has been clicked (pressed and released) on
       * a component.
       * @param e the <code>MouseEvent</code>
      public void mouseClicked(MouseEvent e) {
        processMouseEvents(e);
       * Invoked when the mouse enters a component.
       * @param e the <code>MouseEvent</code>
      public void mouseEntered(MouseEvent e) { }
       * Invoked when the mouse exits a component.
       * @param e the <code>MouseEvent</code>
      public void mouseExited(MouseEvent e) {
        for (int i=0; i<getTabCount(); i++) {
          CloseTabIcon icon = (CloseTabIcon) getIconAt(i);
          if (icon != null)
            icon.mouseover = false;
        repaint();
       * Invoked when a mouse button has been pressed on a component.
       * @param e the <code>MouseEvent</code>
      public void mousePressed(MouseEvent e) {
        processMouseEvents(e);
       * Invoked when a mouse button has been released on a component.
       * @param e the <code>MouseEvent</code>
      public void mouseReleased(MouseEvent e) { }
       * Invoked when a mouse button is pressed on a component and then dragged.
       * <code>MOUSE_DRAGGED</code> events will continue to be delivered to the
       * component where the drag originated until the mouse button is released
       * (regardless of whether the mouse position is within the bounds of the
       * component).<br/>
       * <br/>
       * Due to platform-dependent Drag&Drop implementations,
       * <code>MOUSE_DRAGGED</code> events may not be delivered during a native
       * Drag&Drop operation.
       * @param e the <code>MouseEvent</code>
      public void mouseDragged(MouseEvent e) {
        processMouseEvents(e);
       * Invoked when the mouse cursor has been moved onto a component but no
       * buttons have been pushed.
       * @param e the <code>MouseEvent</code>
      public void mouseMoved(MouseEvent e) {
        processMouseEvents(e);
       * Processes all caught <code>MouseEvent</code>s.
       * @param e the <code>MouseEvent</code>
      private void processMouseEvents(MouseEvent e) {
        int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());
        if (tabNumber < 0) return;
        CloseTabIcon icon = (CloseTabIcon) getIconAt(tabNumber);
        if (icon != null) {
          Rectangle rect= icon.getBounds();
          Point pos = headerViewport == null ?
                      new Point() : headerViewport.getViewPosition();
          Rectangle drawRect = new Rectangle(
            rect.x - pos.x, rect.y - pos.y, rect.width, rect.height);
          if (e.getID() == e.MOUSE_PRESSED) {
            icon.mousepressed = e.getModifiers() == e.BUTTON1_MASK;
            repaint(drawRect);
          } else if (e.getID() == e.MOUSE_MOVED || e.getID() == e.MOUSE_DRAGGED ||
                     e.getID() == e.MOUSE_CLICKED) {
            pos.x += e.getX();
            pos.y += e.getY();
            if (rect.contains(pos)) {
              if (e.getID() == e.MOUSE_CLICKED) {
                int selIndex = getSelectedIndex();
                if (fireCloseTab(selIndex)) {
                  if (selIndex > 0) {
                    // to prevent uncatchable null-pointers
                    Rectangle rec = getUI().getTabBounds(this, selIndex - 1);
                    MouseEvent event = new MouseEvent((Component) e.getSource(),
                                                      e.getID() + 1,
                                                      System.currentTimeMillis(),
                                                      e.getModifiers(),
                                                      rec.x,
                                                      rec.y,
                                                      e.getClickCount(),
                                                      e.isPopupTrigger(),
                                                      e.getButton());
                    dispatchEvent(event);
                  //the tab is being closed
                  //removeTabAt(tabNumber);
                  remove(selIndex);
                } else {
                  icon.mouseover = false;
                  icon.mousepressed = false;
                  repaint(drawRect);
              } else {
                icon.mouseover = true;
                icon.mousepressed = e.getModifiers() == e.BUTTON1_MASK;
            } else {
              icon.mouseover = false;
            repaint(drawRect);
       * Adds an <code>CloseableTabbedPaneListener</code> to the tabbedpane.
       * @param l the <code>CloseableTabbedPaneListener</code> to be added
      public void addCloseableTabbedPaneListener(CloseableTabbedPaneListener l) {
        listenerList.add(CloseableTabbedPaneListener.class, l);
       * Removes an <code>CloseableTabbedPaneListener</code> from the tabbedpane.
       * @param l the listener to be removed
      public void removeCloseableTabbedPaneListener(CloseableTabbedPaneListener l) {
        listenerList.remove(CloseableTabbedPaneListener.class, l);
       * Returns an array of all the <code>SearchListener</code>s added to this
       * <code>SearchPane</code> with addSearchListener().
       * @return all of the <code>SearchListener</code>s added or an empty array if
       * no listeners have been added
      public CloseableTabbedPaneListener[] getCloseableTabbedPaneListener() {
        return listenerList.getListeners(CloseableTabbedPaneListener.class);
       * Notifies all listeners that have registered interest for notification on
       * this event type.
       * @param tabIndexToClose the index of the tab which should be closed
       * @return true if the tab can be closed, false otherwise
      protected boolean fireCloseTab(int tabIndexToClose) {
        boolean closeit = true;
        // Guaranteed to return a non-null array
        Object[] listeners = listenerList.getListenerList();
        for (Object i : listeners) {
          if (i instanceof CloseableTabbedPaneListener) {
            if (!((CloseableTabbedPaneListener) i).closeTab(tabIndexToClose)) {
              closeit = false;
              break;
        return closeit;
       * The class which generates the 'X' icon for the tabs. The constructor
       * accepts an icon which is extra to the 'X' icon, so you can have tabs
       * like in JBuilder. This value is null if no extra icon is required.
      class CloseTabIcon implements Icon {
         * the x position of the icon
        private int x_pos;
         * the y position of the icon
        private int y_pos;
         * the width the icon
        private int width;
         * the height the icon
        private int height;
         * the additional fileicon
        private Icon fileIcon;
         * true whether the mouse is over this icon, false otherwise
        private boolean mouseover = false;
         * true whether the mouse is pressed on this icon, false otherwise
        private boolean mousepressed = false;
         * Creates a new instance of <code>CloseTabIcon</code>
         * @param fileIcon the additional fileicon, if there is one set
        public CloseTabIcon(Icon fileIcon) {
          this.fileIcon = fileIcon;
          width  = 16;
          height = 16;
         * Draw the icon at the specified location. Icon implementations may use the
         * Component argument to get properties useful for painting, e.g. the
         * foreground or background color.
         * @param c the component which the icon belongs to
         * @param g the graphic object to draw on
         * @param x the upper left point of the icon in the x direction
         * @param y the upper left point of the icon in the y direction
        public void paintIcon(Component c, Graphics g, int x, int y) {
          boolean doPaintCloseIcon = true;
          try {
            // JComponent.putClientProperty("isClosable", new Boolean(false));
            JTabbedPane tabbedpane = (JTabbedPane) c;
            int tabNumber = tabbedpane.getUI().tabForCoordinate(tabbedpane, x, y);
            JComponent curPanel = (JComponent) tabbedpane.getComponentAt(tabNumber);
            Object prop = null;
            if ((prop = curPanel.getClientProperty("isClosable")) != null) {
              doPaintCloseIcon = (Boolean) prop;
          } catch (Exception ignored) {/*Could probably be a ClassCastException*/}
          if (doPaintCloseIcon) {
            x_pos = x;
            y_pos = y;
            int y_p = y + 1;
            if (normalCloseIcon != null && !mouseover) {
              normalCloseIcon.paintIcon(c, g, x, y_p);
            } else if (hooverCloseIcon != null && mouseover && !mousepressed) {
              hooverCloseIcon.paintIcon(c, g, x, y_p);
            } else if (pressedCloseIcon != null && mousepressed) {
              pressedCloseIcon.paintIcon(c, g, x, y_p);
            } else {
              y_p++;
              Color col = g.getColor();
              if (mousepressed && mouseover) {
                g.setColor(Color.WHITE);
                g.fillRect(x+1, y_p, 12, 13);
              g.setColor(Color.black);
              g.drawLine(x+1, y_p, x+12, y_p);
              g.drawLine(x+1, y_p+13, x+12, y_p+13);
              g.drawLine(x, y_p+1, x, y_p+12);
              g.drawLine(x+13, y_p+1, x+13, y_p+12);
              g.drawLine(x+3, y_p+3, x+10, y_p+10);
              if (mouseover)
                g.setColor(Color.GRAY);
              g.drawLine(x+3, y_p+4, x+9, y_p+10);
              g.drawLine(x+4, y_p+3, x+10, y_p+9);
              g.drawLine(x+10, y_p+3, x+3, y_p+10);
              g.drawLine(x+10, y_p+4, x+4, y_p+10);
              g.drawLine(x+9, y_p+3, x+3, y_p+9);
              g.setColor(col);
              if (fileIcon != null) {
                fileIcon.paintIcon(c, g, x+width, y_p);
         * Returns the icon's width.
         * @return an int specifying the fixed width of the icon.
        public int getIconWidth() {
          return width + (fileIcon != null ? fileIcon.getIconWidth() : 0);
         * Returns the icon's height.
         * @return an int specifying the fixed height of the icon.
        public int getIconHeight() {
          return height;
         * Gets the bounds of this icon in the form of a <code>Rectangle<code>
         * object. The bounds specify this icon's width, height, and location
         * relative to its parent.
         * @return a rectangle indicating this icon's bounds
        public Rectangle getBounds() {
          return new Rectangle(x_pos, y_pos, width, height);
       * A specific <code>BasicTabbedPaneUI</code>.
      class CloseableTabbedPaneUI extends BasicTabbedPaneUI {
        * the horizontal position of the text
        private int horizontalTextPosition = SwingUtilities.LEFT;
         * Creates a new instance of <code>CloseableTabbedPaneUI</code>
        public CloseableTabbedPaneUI() {
         * Creates a new instance of <code>CloseableTabbedPaneUI</code>
         * @param horizontalTextPosition the horizontal position of the text (e.g.
         * SwingUtilities.TRAILING or SwingUtilities.LEFT)
        public CloseableTabbedPaneUI(int horizontalTextPosition) {
          this.horizontalTextPosition = horizontalTextPosition;
         * Layouts the label
         * @param tabPlacement the placement of the tabs
         * @param metrics the font metrics
         * @param tabIndex the index of the tab
         * @param title the title of the tab
         * @param icon the icon of the tab
         * @param tabRect the tab boundaries
         * @param iconRect the icon boundaries
         * @param textRect the text boundaries
         * @param isSelected true whether the tab is selected, false otherwise
        protected void layoutLabel(int tabPlacement, FontMetrics metrics,
                                   int tabIndex, String title, Icon icon,
                                   Rectangle tabRect, Rectangle iconRect,
                                   Rectangle textRect, boolean isSelected) {
          textRect.x = textRect.y = iconRect.x = iconRect.y = 0;
          javax.swing.text.View v = getTextViewForTab(tabIndex);
          if (v != null) {
            tabPane.putClientProperty("html", v);
          SwingUtilities.layoutCompoundLabel((JComponent) tabPane,
                                             metrics, title, icon,
                                             SwingUtilities.CENTER,
                                             SwingUtilities.CENTER,
                                             SwingUtilities.CENTER,
                                             //SwingUtilities.TRAILING,
                                             horizontalTextPosition,
                                             tabRect,
                                             iconRect,
                                             textRect,
                                             textIconGap + 2);
          tabPane.putClientProperty("html", null);
          int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
          int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
          iconRect.x += xNudge;
          iconRect.y += yNudge;
          textRect.x += xNudge;
          textRect.y += yNudge;
       * A specific <code>MetalTabbedPaneUI</code>.
      class CloseableMetalTabbedPaneUI extends MetalTabbedPaneUI {
        * the horizontal position of the text
        private int horizontalTextPosition = SwingUtilities.LEFT;
         * Creates a new instance of <code>CloseableMetalTabbedPaneUI</code>
        public CloseableMetalTabbedPaneUI() {
         * Creates a new instance of <code>CloseableMetalTabbedPaneUI</code>
         * @param horizontalTextPosition the horizontal position of the text (e.g.
         * SwingUtilities.TRAILING or SwingUtilities.LEFT)
        public CloseableMetalTabbedPaneUI(int horizontalTextPosition) {
          this.horizontalTextPosition = horizontalTextPosition;
         * Layouts the label
         * @param tabPlacement the placement of the tabs
         * @param metrics the font metrics
         * @param tabIndex the index of the tab
         * @param title the title of the tab
         * @param icon the icon of the tab
         * @param tabRect the tab boundaries
         * @param iconRect the icon boundaries
         * @param textRect the text boundaries
         * @param isSelected true whether the tab is selected, false otherwise
        protected void layoutLabel(int tabPlacement, FontMetrics metrics,
                                   int tabIndex, String title, Icon icon,
                                   Rectangle tabRect, Rectangle iconRect,
                                   Rectangle textRect, boolean isSelected) {
          textRect.x = textRect.y = iconRect.x = iconRect.y = 0;
          javax.swing.text.View v = getTextViewForTab(tabIndex);
          if (v != null) {
            tabPane.putClientProperty("html", v);
          SwingUtilities.layoutCompoundLabel((JComponent) tabPane,
                                             metrics, title, icon,
                                             SwingUtilities.CENTER,
                                             SwingUtilities.CENTER,
                                             SwingUtilities.CENTER,
                                             //SwingUtilities.TRAILING,
                                             horizontalTextPosition,
                                             tabRect,
                                             iconRect,
                                             textRect,
                                             textIconGap + 2);
          tabPane.putClientProperty("html", null);
          int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
          int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
          iconRect.x += xNudge;
          iconRect.y += yNudge;
          textRect.x += xNudge;
          textRect.y += yNudge;
    }The Listener:
    import java.util.EventListener;
    * The listener that's notified when an tab should be closed in the
    * <code>CloseableTabbedPane</code>.
    public interface CloseableTabbedPaneListener extends EventListener {
       * Informs all <code>CloseableTabbedPaneListener</code>s when a tab should be
       * closed
       * @param tabIndexToClose the index of the tab which should be closed
       * @return true if the tab can be closed, false otherwise
      boolean closeTab(int tabIndexToClose);
    }

  • How to switch between pages in a JTabbedPane

    I hava form with a JTabbedPane whit 5 "pages" om page 1 there is a button that when pressed i want to switch to page 5 and display that content
    I have tried the setSelectedIndex method but i does not work.. Any tips?

    How about the source code?
    It must be buggy somewhere! There is no problem with those methods in my example.
    Try this one:
    package tabs;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * <p>�berschrift: </p>
    * <p>Beschreibung: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Organisation: </p>
    * @author Florian Fray
    * @version 1.0
    public class TabExample extends JFrame {
    private JPanel root = new JPanel();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JButton jButton1 = new JButton();
    JPanel jPanel2 = new JPanel();
    JButton jButton2 = new JButton();
    FlowLayout flowLayout1 = new FlowLayout();
    public TabExample() throws HeadlessException {
    try {
    jbInit();
    pack();
    show();
    catch(Exception e) {
    e.printStackTrace();
    public static void main(String[] args) throws HeadlessException {
    TabExample tabExample1 = new TabExample();
    private void jbInit() throws Exception {
    setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
    this.setState(Frame.NORMAL);
    this.setTitle("Tabbing around");
    setContentPane(root);
    jButton1.setText("to Tab 2");
    jButton1.addActionListener(new TabExample_jButton1_actionAdapter(this));
    jButton2.setText("back to Tab 1");
    jButton2.addActionListener(new TabExample_jButton2_actionAdapter(this));
    jTabbedPane1.setMinimumSize(new Dimension(155, 83));
    jTabbedPane1.setPreferredSize(new Dimension(155, 83));
    root.add(jTabbedPane1, null);
    jTabbedPane1.add(jPanel1, "jPanel1");
    jPanel1.add(jButton1, null);
    jTabbedPane1.add(jPanel2, "jPanel2");
    jPanel2.add(jButton2, null);
    void jButton1_actionPerformed(ActionEvent e) {
    jTabbedPane1.setSelectedIndex(1);
    void jButton2_actionPerformed(ActionEvent e) {
    jTabbedPane1.setSelectedIndex(0);
    class TabExample_jButton1_actionAdapter implements java.awt.event.ActionListener {
    TabExample adaptee;
    TabExample_jButton1_actionAdapter(TabExample adaptee) {
    this.adaptee = adaptee;
    public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
    class TabExample_jButton2_actionAdapter implements java.awt.event.ActionListener {
    TabExample adaptee;
    TabExample_jButton2_actionAdapter(TabExample adaptee) {
    this.adaptee = adaptee;
    public void actionPerformed(ActionEvent e) {
    adaptee.jButton2_actionPerformed(e);
    }

  • Changing Colors of selected tab in JTabbedPane.

    Do someone has some code that can show how to
    change the color of the selected tab with JTabbedPane.
    I can change the other tabs colors with setBackground and setForeground, setBackgroundAt........ but it is the selected
    tab that will not change from the default grey color.
    thanks

    try this code, it works.
    public class TabBackgroundChange extends JFrame {
    private JTabbedPane tabPane = null;
    public static final Color selTabColor = Color.red;
    Color nonSelectedTabColor = null;
    public TabBackgroundChange() {
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch(Exception ex) {
    ex.printStackTrace();
    tabPane = new JTabbedPane();
    tabPane.add("One", new JPanel());
    tabPane.add("Two", new JPanel());
    tabPane.add("Three", new JPanel());
    this.getContentPane().add(tabPane);
    this.setSize(200, 200);
    this.setVisible(true);
    tabPane.addChangeListener(new TabChangeListener());
    tabPane.setSelectedIndex(1);
    tabPane.setSelectedIndex(0);
    public static void main(String[] args) {
    TabBackgroundChange tabBackgroundChange1 = new TabBackgroundChange();
    private class TabChangeListener implements ChangeListener {
    public void stateChanged(ChangeEvent ce) {
    int iSelTab = tabPane.getSelectedIndex();
    Color unSelectedBackground = tabPane.getBackgroundAt(iSelTab);
    for(int i=0; i<tabPane.getTabCount(); i++) {
    tabPane.setBackgroundAt(i, unSelectedBackground);
    tabPane.setBackgroundAt(iSelTab, Color.red);
    }

  • Exception occurred during event dispatching:java.security.AccessControlExce

    Hi,
    I' m getting an error while connecting to database ORACLE 9i.
    I'm using JDK 1.6.0
    Actually the code is about how an Japplet connects to database ORACLE 9i
    when i was connecting using normal program i had got the connection easily .
    When i used this JApplet ,i'm getting this error.
    CODE:
    import java.awt.*;
    import javax.swing.* ;
    import java.sql.*;
    import java.awt.event.*;
    import java.util.*;
    /*<applet code="jln" width=400 height=400></applet>*/
    public class jln extends JApplet
    public void init()
    JTabbedPane jtp=new JTabbedPane();
    jtp.addTab("View Marks",new VmPanel());
    getContentPane().add(jtp);
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    } catch (Exception e)
    {              e.printStackTrace();
    System.out.println("Failed to load driver.");
    class VmPanel extends JPanel implements ActionListener
    JButton b1,b2;
    TextArea ta1;
    JTextField jtf1;
    Connection con=null;
    public VmPanel()
    b1=new JButton("ok!");
    b2=new JButton("clear");
    ta1=new TextArea();
    jtf1=new JTextField(10);
    add(jtf1);
    add(b1);
    add(b2);
    add(ta1);
    b1.addActionListener(this);
    b2.addActionListener(this);
    public void actionPerformed(ActionEvent ae)
    String str1=ae.getActionCommand();
    if(str1=="ok!")
    try
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:jlngbldb", "scott", "tiger");
    Statement stmt = con.createStatement ();
    String ht=jtf1.getText();
    System.out.println("\nHello\n");
    ResultSet rs = stmt.executeQuery("SELECT * FROM jln WHERE ht='"+ht+"'");
    while(rs.next())
    ta1.setText ("");
    ta1.setText("Name:"+rs.getObject("name")+"HallTicket:"+rs.getObject("ht")+"C.G:"+rs.getObject("cg")+"C.D:"+rs.getObject("cd")+"UNIX:"+rs.getObject("unix")+" S.T.M:"+rs.getObject("stm")+"N.N:"+rs.getObject("nn")+"I.S:"+rs.getObject("ins"));
    rs.close();
    stmt.close();
    con.close();
    catch(SQLException ex)
    System.err.println("SQLException: " + ex.getMessage());
    if(str1=="clear")
    ta1.setText("");
    jtf1.setText("");
    if(str1==null)
    ta1.setText ("");
    ta1.setText("Please enter Hall Ticket Number above....");
    }//action performed close
    }//panel closed
    AND THE ERROR IS:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.util.PropertyPermissio
    n oracle.jserver.version read)
    at java.security.AccessControlContext.checkPermission (AccessControlConte
    xt.java:321)
    at java.security.AccessController.checkPermission(AccessController.java:
    546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12
    85)
    at java.lang.System.getProperty(System.java:627)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:433)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
    at java.sql.DriverManager.getConnection(DriverManager.java:548)
    at java.sql.DriverManager.getConnection(DriverManager.java :180)
    at VmPanel.actionPerformed(jln.java:60)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
    63)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2183)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased (BasicButtonL
    istener.java:234)
    at java.awt.Component.processMouseEvent(Component.java:5921)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3316)
    at java.awt.Component.processEvent (Component.java:5686)
    at java.awt.Container.processEvent(Container.java:1960)
    at java.awt.Component.dispatchEventImpl(Component.java:4360)
    at java.awt.Container.dispatchEventImpl(Container.java :2018)
    at java.awt.Component.dispatchEvent(Component.java:4194)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4222
    at java.awt.LightweightDispatcher.processMouseEvent (Container.java:3886)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3816)
    at java.awt.Container.dispatchEventImpl(Container.java:2004)
    at java.awt.Component.dispatchEvent (Component.java:4194)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:592)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
    ad.java:270)
    at java.awt.EventDispatchThread.pumpEventsForFilter (EventDispatchThread.
    java:198)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:171)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:166)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:119)
    I'm getting this error when i pressed the OK! JButton.
    PLEASE ! help me by correcting this error.
    Thank You.

    Presumably you are running this via a browser where the applet is served from the server.
    Applets can only connect back to the origination server and using the name that the origination server was accessed with.
    And that has nothing to do with JDBC, all connections work that way.
    Your driver uses a connection thus it will not work unless it attempts to connect to the server that originated the applet.
    Solutions
    1. Connect to the server
    2. Sign the applet
    3. Modify the policy file of each client that will run the applet. This is not a good idea in an unsecure network.
    Note as well that in an unsecure network is most often a bad policy to have an applet directly accessing a database regardless.

  • JTabbedPane selection color

    is it possible to change the default JTabbedPane selection color? (light gray)
    It doesnt seem to give you the ability to set a Renderer

    If altering the UI for your JTabbedPane is an option for you then this becomes pretty easy, just override the "paintTabBackground" method of BasicTabbedPaneUI. This isn't an option for a lot of people though... since that would pretty much limit you to one UI.
    Otherwise you will have set the background of the tab manually... the following code is an example of how to do this... unfortunatly... MetalTabbedPaneUI overrides the paintTabBackground method and DOESN'T use the manual backgrounds for selected tabs, it ALWAYS uses the default selectedColor from the UIManager... looks like an oversite to me... anyway... this code works fine with the Windows Look and Feel...
    import javax.swing.*;
    import javax.swing.event.ChangeListener;
    import javax.swing.event.ChangeEvent;
    import java.awt.*;
    * <pre>
    * SBTabbedPane
    * </pre>
    public class SBTabbedPane extends JTabbedPane {
         private Color tback;
         private int tsel = -1;
         private Color sback;
         public SBTabbedPane() {
              addChangeListener(new ChangeListener() {
                   public void stateChanged(ChangeEvent e) {
                        redoback();
         public void setSelectionBackground(Color c) {
              sback = c;
              redoback();
         private void redoback() {
              if (tsel >= 0) {
                   setBackgroundAt(tsel, tback);
              int i = getSelectedIndex();
              if (sback != null && i >= 0) {
                   tback = getBackgroundAt(i);
                   tsel = i;
                   System.out.println("SET BACK: " + tsel + ": " + sback);
                   setBackgroundAt(tsel, sback);
         public static final void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {}
              SBTabbedPane test = new SBTabbedPane();
              test.setSelectionBackground(new Color(255,0,0));
              test.add("Tab 1", new JLabel("HELLO"));
              test.add("Tab 2", new JLabel("WORLD"));
              JFrame testframe = new JFrame("Test Window");
              testframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              testframe.getContentPane().setLayout(new BorderLayout(0, 0));
              testframe.getContentPane().add(test);
              testframe.pack();
              testframe.setVisible(true);
    }Hope this helps a little...
    Josh Castagno
    http://www.jdc-software.com

  • Ctrl PgUp / CtrlPgDown in JTables vs JTabbedPanes

    Hi there, another wee JTable problem.
    I want Ctrl PageUp and Ctrl PageDown to move between JTabbedPanes. This normally works, except when the focus is currently in a JTable. I want it to also work if the focus is in a JTable.
    I have tried to stop the JTable from handling the keys by setting the inputmap to "none" but this has no effect (you can see my code for this below).
    Here is a test program that shows the bad behaviourimport java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.InputMap;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
    public class TestTable extends JTable {
         public TestTable(Object[][] data, Object[] headings) {
              super(data, headings);
              setFocusTraversalPolicyProvider(true);
              // Turn off Ctrl PgUp and Ctrl PgDown handling so tab navigation works.
              InputMap inputs = getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
              KeyStroke ctrlPgUpKey = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_DOWN_MASK);
              inputs.put(ctrlPgUpKey, "None");
              KeyStroke ctrlPgDownKey = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_DOWN_MASK);
              inputs.put(ctrlPgDownKey, "None");
         public boolean isCellEditable(int row, int column) {
              return false;
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test table");
              JTabbedPane pane = new JTabbedPane();
              frame.add(pane);
              JPanel panel = new JPanel();
              JTextField field = new JTextField("Key Ctrl PgDown or Ctrl PgUp");
              panel.add(field);
              pane.add("test1", panel);
              pane.add("test2", new JScrollPane(new TestTable(new String[][] {{"hello", "me"}}, new String[]{"H1", "H2"})));
              pane.add("test3", new JPanel());
              frame.setBounds(100, 100, 300, 300);
              frame.setVisible(true);
    }Thanks,
    Tim

    i had a similiar problem, had some UIs that had a Tabbed pane and
    ScrollBars, and some tabs had JTables in them, anyhow, I just wanted
    Control-Page_up/Down to work for the JTabbedPane all the the time so
    I did this in my windows look and feel applications and all was well, just posting so maybe this will help someone down the road
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    UIDefaults uiDefaults = UIManager.getDefaults();
    // ginny wants Control-Page-Up and Control-Page-Down to work for tabbed
    // panes, which it does by default, however, it also works for JTable
    // and JScrollPane, and those components grab the keystroke 1st if they are
    // all in the same screen, so disabling it for JTable and JScrollPane
    // see WindowsLookAndFeel.java
    uiDefaults.remove("ScrollPane.ancestorInputMap");
    uiDefaults.put("ScrollPane.ancestorInputMap",
    new UIDefaults.LazyInputMap(new Object[] {
    "RIGHT", "unitScrollRight",
    "KP_RIGHT", "unitScrollRight",
    "DOWN", "unitScrollDown",
    "KP_DOWN", "unitScrollDown",
    "LEFT", "unitScrollLeft",
    "KP_LEFT", "unitScrollLeft",
    "UP", "unitScrollUp",
    "KP_UP", "unitScrollUp",
    "PAGE_UP", "scrollUp",
    "PAGE_DOWN", "scrollDown",
    "ctrl PAGE_UP", "None", //"scrollLeft",
    "ctrl PAGE_DOWN", "None",//"scrollRight",
    "ctrl HOME", "scrollHome",
    "ctrl END", "scrollEnd"
    uiDefaults.remove("Table.ancestorInputMap");
    uiDefaults.put("Table.ancestorInputMap",
    new UIDefaults.LazyInputMap(new Object[] {
    "ctrl C", "copy",
    "ctrl V", "paste",
    "ctrl X", "cut",
    "COPY", "copy",
    "PASTE", "paste",
    "CUT", "cut",
    "RIGHT", "selectNextColumn",
    "KP_RIGHT", "selectNextColumn",
    "LEFT", "selectPreviousColumn",
    "KP_LEFT", "selectPreviousColumn",
    "DOWN", "selectNextRow",
    "KP_DOWN", "selectNextRow",
    "UP", "selectPreviousRow",
    "KP_UP", "selectPreviousRow",
    "shift RIGHT", "selectNextColumnExtendSelection",
    "shift KP_RIGHT", "selectNextColumnExtendSelection",
    "shift LEFT", "selectPreviousColumnExtendSelection",
    "shift KP_LEFT", "selectPreviousColumnExtendSelection",
    "shift DOWN", "selectNextRowExtendSelection",
    "shift KP_DOWN", "selectNextRowExtendSelection",
    "shift UP", "selectPreviousRowExtendSelection",
    "shift KP_UP", "selectPreviousRowExtendSelection",
    "PAGE_UP", "scrollUpChangeSelection",
    "PAGE_DOWN", "scrollDownChangeSelection",
    "HOME", "selectFirstColumn",
    "END", "selectLastColumn",
    "shift PAGE_UP", "scrollUpExtendSelection",
    "shift PAGE_DOWN", "scrollDownExtendSelection",
    "shift HOME", "selectFirstColumnExtendSelection",
    "shift END", "selectLastColumnExtendSelection",
    "ctrl PAGE_UP", "None", //"scrollLeftChangeSelection",
    "ctrl PAGE_DOWN", "None", //"scrollRightChangeSelection",
    "ctrl HOME", "selectFirstRow",
    "ctrl END", "selectLastRow",
    "ctrl shift PAGE_UP", "scrollRightExtendSelection",
    "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
    "ctrl shift HOME", "selectFirstRowExtendSelection",
    "ctrl shift END", "selectLastRowExtendSelection",
    "TAB", "selectNextColumnCell",
    "shift TAB", "selectPreviousColumnCell",
    "ENTER", "selectNextRowCell",
    "shift ENTER", "selectPreviousRowCell",
    "ctrl A", "selectAll",
    "ESCAPE", "cancel",
    "F2", "startEditing"
    }));

Maybe you are looking for

  • Internal Order Settlement-urgent

    Hi Gurus I have an internal order balance of -160$ USD. USD is the Controlling Area Curr. But when viewed in local Curr (CAD) it has a balance of zero. I checked the controlling area settings, and it is set to update local aswell as contr. area curr.

  • Table text frame width adjustment by script

    Hi, I have to capture my table cells within 'Text Frame Width' option with 'Distribute Column Evenly' , when it's going to beyond the 'Text Frame Width'. Is this possible by script? by hasvi

  • Uninstall CS6?

    After I confirm that all my CC applications are working correctly is it Ok to use the un-istallers on all the CS6 programs?

  • Please help with iOS 7.1.1 and iPad Mini

    We loved our iPad mini until we accepted the upgrade to iOS 7.  Since upgrading and now most recently to 7.1.1, the applications are jerky -- games are not usable -- and there seems to be a 'phantom' touching controls when we're not.   Is there anywa

  • Dual Core Intel - can I install non-universal software?

    Can I install the non-universal version of Adobe Creative Suite onto my new G5 dual-core duo?