Button painted twice

We have in a JSP two selectOneChoice and a button.
Values of the second selectOneChoice depends on the value of the first selectOneChoice.
The values of both selectOneChoice are loaded from a bean called Bean.
The first time the JSP is loaded, only the first selectOneChoice is rendered. Once the user select a value of the first selectOneChoice and press the button, two things happen:
1. The valueChangeListener method of the first selectOneChoice is executed. This method updates the values of the second selectOneChoice.
2. The action method of the button is executed. This method just set a boolean field of the bean called 'renderList2' to true and set the outcome to null. This will cause to navigate to the same JSP.
Because the field called 'renderList2' is true, the second selectOneChoice is rendered.
But the button is painted twice. Why?
We are developing with JDeveloper 10.1.3.4.
The JSP is the next one:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<f:view>
<afh:html>
<afh:head title="rendering">
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
</afh:head>
<afh:body>
<h:form>
<af:panelGroup>
<af:selectOneChoice id="category1" valuePassThru="true"
valueChangeListener="#{Bean.updateList2}"
unselectedLabel="-- select one --">
<af:forEach items="#{Bean.list1}" var="row">
<af:selectItem label="#{row.label}" value="#{row.value}"/>
</af:forEach>
</af:selectOneChoice>
</af:panelGroup>
<af:panelGroup rendered="#{Bean.renderList2}">
<af:selectOneChoice id="category2" valuePassThru="true"
unselectedLabel="-- select one --">
<af:forEach items="#{Bean.list2}" var="row">
<af:selectItem label="#{row.label}" value="#{row.value}"/>
</af:forEach>
</af:selectOneChoice>
</af:panelGroup>
<af:commandButton text="Next" action="#{Bean.next}"/>
</h:form>
</afh:body>
</afh:html>
</f:view>
The code of the bean is:
package com.ieci.pruebas;
import java.util.ArrayList;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
public class Bean
private ArrayList list1 = null;
private ArrayList list2 = null;
private boolean renderList2 = false;
public void setList1(ArrayList list1)
this.list1 = list1;
public ArrayList getList1()
this.list1 = new ArrayList ();
this.list1.add(new SelectItem ("ONE", "ONE"));
this.list1.add(new SelectItem ("TWO", "TWO"));
return this.list1;
public void setList2(ArrayList list2)
this.list2 = list2;
public ArrayList getList2()
return list2;
public void updateList2(ValueChangeEvent valueChangeEvent)
String list1Value = (String) valueChangeEvent.getNewValue();
this.list2 = new ArrayList ();
if (list1Value.equals("ONE"))
this.list2.add(new SelectItem ("VALUE 1", "VALUE 1"));
this.list2.add(new SelectItem ("VALUE 2", "VALUE 2"));
else
this.list2.add(new SelectItem ("VALUE 3", "VALUE 3"));
this.list2.add(new SelectItem ("VALUE 4", "VALUE 4"));
public String next ()
String command = null;
renderList2 = true;
return command;
public void setRenderList2(boolean renderList2)
this.renderList2 = renderList2;
public boolean isRenderList2()
return renderList2;
Thanks

Yes, I logged a SR yesterday.
Yesterday I solved it defining a navigatorion rule to the same JSP. I don't know why it paints the button twice when the method return a null as outcome.
I haven't test what you suggest about adding an "id" property to all componentes. Is it a JSF requirement when using a foreach tag?
Thanks

Similar Messages

  • Button tregers twice

    hi...
    i have a button inside a movie clip.I want to open a site in
    a browser window when i clicks the button so i write the script
    inside the button .But when i click the button two windows are
    opening with the same url...[the movie clip has animation]
    can u help me...?

    Yes, I logged a SR yesterday.
    Yesterday I solved it defining a navigatorion rule to the same JSP. I don't know why it paints the button twice when the method return a null as outcome.
    I haven't test what you suggest about adding an "id" property to all componentes. Is it a JSF requirement when using a foreach tag?
    Thanks

  • InfoPath 2010 and REST web services, custom code button firing twice and second click fires error

    Hi,
    I have two supposing simple issues which I'm having problems correcting.
    If a add a button to the form and write some custom code (See below) to submit some data via a REST Web Service data connection. The code runs but somehow fires the URL twice to the web service.
    I've also recreated similar functionality using Rules on a button and some concat formulas and exactly the same thing happens when I the run the data using the Query Data Action, it fires the URL twice at the web service.
    How can I stop this.
    Secondly, if I use the custom code route, it work correctly the first time it pressed except for the double fire issue, but the second time I click the button the InfoPath internal system throws up an issue. See screen shot below.
    Any help would be appreciated.
    Rob
    namespace SubmitTest
    public partial class FormCode
    // Member variables are not supported in browser-enabled forms.
    // Instead, write and read these values from the FormState
    // dictionary using code such as the following:
    // private object _memberVariable
    // get
    // return FormState["_memberVariable"];
    // set
    // FormState["_memberVariable"] = value;
    // NOTE: The following procedure is required by Microsoft InfoPath.
    // It can be modified using Microsoft InfoPath.
    public void InternalStartup()
    //EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
    ((ButtonEvent)EventManager.ControlEvents["SaveDataPoint"]).Clicked += new ClickedEventHandler(SaveDataPoint_Clicked);
    /*public void FormEvents_Submit(object sender, SubmitEventArgs e)
    // If the submit operation is successful, set
    // e.CancelableArgs.Cancel = false;
    // Write your code here.
    MessageBox.Show("Submit Function Start");
    //SaveDataPoint_Clicked(sender);
    MessageBox.Show("Submit Function End");
    public void SaveDataPoint_Clicked(object sender, ClickedEventArgs e)
    try
    FileQueryConnection fqcConnection = (FileQueryConnection)this.DataConnections["TestREST"];
    string fqcFileLocation = fqcConnection.FileLocation;
    MessageBox.Show("fqcFileLocation " + fqcFileLocation);
    fqcFileLocation = fqcFileLocation + "?TestName='HugeArse'";
    fqcConnection.FileLocation = fqcFileLocation;
    fqcConnection.Execute();
    catch (Exception ex)
    MessageBox.Show("NewDataPoint_Clicked: Error " + ex);

    Hi Phillip6653,
    Did you check the similar
    thread to uninstall the windows update KB2756920 which was published on day 1/10? After auto install the update, on day 1/11, the same error occur when I open site using designer, after I uninstall it, it works for me, please have a check.
    For more information, see
    http://consultingblogs.emc.com/shailensukul/archive/2010/09/17/sharepoint-designer-error.aspx
    http://daniyar-tech.blogspot.com/2012/01/sharepoint-designer-2010-error.html
    Best Regards.
    Kelly Chen
    TechNet Community Support

  • Powermac g4 cube, power button blinks twice

    hello,
         i have a powermac g4 cube, i plugged it in and it turned on (i could here it) and i went to go turn on the apple display and i pressed the button as normal, and when i pressed it, it lites up and when i let go the light goes out. it is a yellow light on the display. so i grabbed a differnt display that i had laying around and plugged that in and it went right into standby mode, i then looked at the mac and saw that it was blinking twice. i went online and read the it was a incompatible ram issue, first off, i just took out the ram and that would show a 1 blink, and second, would no ram cause the display issue? i just want to know if it is the graphics card or if im just not doing somthing correctly. one other thing, i opened it up and noticed that it was missing a few screws and it was wiggley, so i replaced the missing screws and it made it secure, but this still did not resolve the issue.
    thanks

    would no ram cause the display issue?
    Yes. No RAM, bad RAM, incompatible RAM are all contrary to function.
    If you don't have compatible RAM, the machine will not move to logic. If there is no logic function, the machine will not move to graphics initiation.
    One must reach successful logic before one can have graphics.
    Deal with the RAM issue first.
    Install known good, guaranteed Mac compatible RAM.
    Standard PC RAM almost never works.
    http://eshop.macsales.com/MyOWC/Upgrades.cfm?sort=pop&model=128&type=Memory

  • Touch Pad Button Paint or Coating coming off

    Hey all,
    I just got  brand new T410 about two weeks ago and I love it except I have just recently noticed that the paint or coating on the touchpad buttons is already wearing off. What is my course of action, I dont really feel like shipping the computer in to lenovo to get fixed cause I use it for work and dont feel like risking any shipping mishaps, is this something that can replaced easily by myself and lenovo can send me the two buttons, or does the whole touchpad  unit need to be replaced? Thanks for the help

    can you post a picture of this? There shouldn't be any paints as such that can wear off on the Touchpad buttons.
    If it is in need of replacement, it has to be done at the depot or onsite by a technician (if you have onsite warranty), since the T410 palmrest is one fixed unit with the keyboard bezel.... 
    Regards,
    Jin Li
    May this year, be the year of 'DO'!
    I am a volunteer, and not a paid staff of Lenovo or Microsoft

  • Tree Table buttons displaying twice

    I have an issue in ADF applicationsTreeTable button bar, If I select a row, button's area shuffles and we can see the button twice. This would be replicated only for the first time, On save/reload, it will not reproduce. If I clear the cookies and restore the page, this issue reoccurs. Please suggest some ways to avoid this. I have a selection listener, on select I have some if else conditions, based on that, I am disabling & enabling the buttons.

    Hi,
    Have you got any solution of this issue as I am also facing similar issue.
    In my case I am enabling disabling the delete icon based on certain conditions. In the initial load of the object icons are getting disabled as expected but later if I add any new node in tree table and delete it the code will written the correct value of the disable variable but the icon will not be disabled.
    Any inputs will be appreciated.
    Thanks.

  • Who knows why a JPanel is automatically painted twice? Please look at my co

    // "Raw Problem": Start this as Application or in Appletviewer
    // <applet code= ZaehlePaintAufrufe width=400 height=250>
    // </applet>
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Zeichnung extends JPanel
    private int calls = 0;
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    calls++;
    int breite = getWidth();
    int hoehe = getHeight();
    g.drawString("Width: " + breite + " Height: " + hoehe + " Resize Me!", breite/4, hoehe/2);
    g.drawString("Paint-Calls: " + calls, breite/4, hoehe/2+30);
    public class ZaehlePaintAufrufe extends JApplet
    Zeichnung z = new Zeichnung();
    public void init()
    Container cp = getContentPane();
    cp.add(z);
    public static void main(String[] args)
    JApplet applet = new ZaehlePaintAufrufe();
    JFrame frame = new JFrame("ZaehlePaintAufrufe");
    frame.addWindowListener(new WindowAdapter()
    { public void windowClosing(WindowEvent e) {  System.exit(0);  } } );
    frame.getContentPane().add(applet);
    frame.setSize(400,250);
    applet.init();
    applet.start();
    frame.setVisible(true);

    Hello and sorry for that long time passed,
    thank you for your answer!
    If you are still interested at all:
    I found that with 1.4 the "redundant" repainting of the panel's whole contents
    takes place only when diagonally shrinking the application- or browser-window.
    All other cases are drawn just once.
    Frank

  • Backspace button registers twice on honeycomb

    The backspace key registers twice, even when only pressed once when using the current Firefox 4 beta for android. This is happening on the honeycomb verion of android on a Motorola Xoom device.

    This bug has been fixed in our latest development versions: https://bugzilla.mozilla.org/show_bug.cgi?id=637892
    The fix will be included in the next update through the Android Market. Or you can test the fix now by downloading a nightly development build from: https://wiki.mozilla.org/Mobile/Platforms/Android

  • Power button blink twice each time, video included. Laptop won't turn on. help please!

    Hi guys,I opened up my laptop - HP Pavilion dv6 because the fan was full with dust.I cleaned it up and followed the youtube instructions. I know I assembled the laptop correctly, each part in his place, every step went smoothly.When i tried to power up the laptop, it didnt turn on. At the beginning i had 2 blinks in the power button with the f12, i did a hard reset and now i got just 2 blinks on power button. here is the video i took, please help me!!!http://youtu.be/JjRhWZw4W8Ithanks!   

    Rebuild the unit from scratch..... There may be a shorting part

  • Iphone 4s power button jammed twice

    I Purchased the Iphone4s in Nov. 2011. The power button jammed in August 2012. They replaced it for free and 5 months later it jammed again. They said since it is out of warrenty that I had to pay for a new one. They showed me how to use AssistiveTouch. It very annoying because I  waste battery because I can't lock the phone and sometimes the phone does not automatically go off beause it is  in my pocket.
    I understand it is out of warranty, but the power button is a well known defect in the Iphone.
    I really like the IPhone 4S but this is the 2nd phone that barley made it halfway through the intended warranty. I want to get another Iphone when my upgrade is avalaible, but I can't see bying another Iphone and having the same issue.
    What should I do?

    If your upgrade is to another 4S, then you get free replacements for 2 years with the AppleCare if the button dies. So, even if your luck is on the bad side again, you'll pay for that AppleCare in two replacements. You can always get the $69 AppleCare which does the same thing, except it doesn't include provisions for accidental damage.
    Anyway, you're luck with it happening to two phones isn't good, but it's also unusual. If the phone was a refurb that might have something to do with it.
    I mean, I would say go for it, cause even if the lock button does jam, you get a hardware coverage for the first year, which means you don't pay to fix it, just take it to an Apple store for exchange. You pay $69 when you upgrade, then you get that perk for two years. I say it's worth it.

  • Adding Radio Button dynamically, twice - Error #2025: The supplied DisplayObject must be a child of

    Hello
    I am having some trouble adding UI controls dynamically. Mostly with radio buttons.
    Here is an example that demonstrates my problem:
    <s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx"
        creationPolicy="all"
        >
        <fx:Script>
            <![CDATA[ 
                import mx.containers.Form;
                import mx.containers.Panel;
                import mx.controls.Label;
                import mx.controls.NumericStepper;
                import mx.controls.RadioButton;
                private var theChar:String = "B";
                protected function btnAdd_clickHandler(event:MouseEvent):void
                    var theForm:Form = new Form();               
                    theForm.label = theChar;
                    //1. Label
                    var myLabel:Label = new Label();
                    myLabel.text = "My Label";
                    myLabel.width=120;
                    theForm.addChild(myLabel);
                    //2. Numeric Stepper
                    var myNumStepper:NumericStepper = new NumericStepper();
                    myNumStepper.id = "numPointHigh" + theChar;
                    myNumStepper.name = "numPointHigh" + theChar;
                    myNumStepper.minimum = 0;
                    myNumStepper.maximum = 120;
                    myNumStepper.width = 50;
                    myNumStepper.height = 30;
                    theForm.addChild(myNumStepper);
                    //3. radio button
                    var myRadioButton:RadioButton = new RadioButton;
                    myRadioButton.id = "myRadioButton" + theChar;
                    myRadioButton.name = "myRadioButton" + theChar;
                    myRadioButton.label = "my radio button";
                    myRadioButton.selected = true;
                    theForm.addChild(myRadioButton);
                    //4. Panel
                    var thePanel:Panel = new Panel();
                    thePanel.width = 300;
                    thePanel.height = 475;
                    thePanel.name=theChar;
                    thePanel.title = "My Profile Panel";
                    thePanel.setStyle("backgroundColor", "blue");
                    //add the form to the panel
                    thePanel.addChild(theForm);
                    //add the Panel to the list control
                    myList.addChild(thePanel);
                protected function btnClear_clickHandler(event:MouseEvent):void
                    var numChildren:Number = myList.numChildren;
                    for(var i:Number=numChildren - 1; i > -1; i--){
                        myList.removeChildAt(i);
            ]]>
        </fx:Script>
        <mx:VBox width="100%">
            <mx:List id="myList" />
            <mx:Button id="btnAdd" label="Add a panel" click="btnAdd_clickHandler(event)" color="black"/>
            <mx:Button id="btnClear" label="Clear" click="btnClear_clickHandler(event)" color="black" />
        </mx:VBox>
    </s:Application>
    ^ Run that. Click the "Add a panel" button. Then click "Clear". Then click the "Add a panel" button again. You will see the error:
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
        at flash.display::DisplayObjectContainer/getChildIndex()
        at mx.core::Container/getChildIndex()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core \Container.as:2833]
        at mx.containers::Panel/getChildIndex()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co ntainers\Panel.as:1174]
        at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\controls\RadioButtonGroup.as:600]
        at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\controls\RadioButtonGroup.as:611]
        at mx.controls::RadioButtonGroup/breadthOrderCompare()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\controls\RadioButtonGroup.as:611]
        at Array$/_sort()
        at Array/http://adobe.com/AS3/2006/builtin::sort()
        at mx.controls::RadioButtonGroup/http://www.adobe.com/2006/flex/mx/internal::addInstance()[E:\dev\4.0.0\frameworks\projects \framework\src\mx\controls\RadioButtonGroup.as:465]
        at mx.controls::RadioButton/addToGroup()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\c ontrols\RadioButton.as:574]
        at mx.controls::RadioButton/commitProperties()[E:\dev\4.0.0\frameworks\projects\framework\sr c\mx\controls\RadioButton.as:514]
        at mx.core::UIComponent/validateProperties()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:7772]
        at mx.managers::LayoutManager/validateProperties()[E:\dev\4.0.0\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:572]
        at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:730]
        at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]
    I do not understand why I cannot re-add the radio button? If you comment out the code for the radio button (comment section #3.) you can re-add the panels easily. It is only happening when I have radio buttons being added to the form/panel.
    Why is this happening and how do I fix it? Why is this only happening to radio buttons? I thought I had this fixed

    ^ well, okay, but that's not the problem.
    here, i removed list and replaced with Panel. same problem on the radio buttons.
    <s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:containers="com.dougmccune.containers.*"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        creationPolicy="all"
        >
        <fx:Script>
            <![CDATA[ 
                import mx.containers.Form;
                import mx.containers.Panel;
                import mx.controls.Label;
                import mx.controls.NumericStepper;
                import mx.controls.RadioButton;
                private var theChar:String = "B";
                protected function btnAdd_clickHandler(event:MouseEvent):void
                    var theForm:Form = new Form();               
                    theForm.label = theChar;
                    //1. Label
                    var myLabel:Label = new Label();
                    myLabel.text = "My Label";
                    myLabel.width=120;
                    theForm.addChild(myLabel);
                    //2. Numeric Stepper
                    var myNumStepper:NumericStepper = new NumericStepper();
                    myNumStepper.id = "numPointHigh" + theChar;
                    myNumStepper.name = "numPointHigh" + theChar;
                    myNumStepper.minimum = 0;
                    myNumStepper.maximum = 120;
                    myNumStepper.width = 50;
                    myNumStepper.height = 30;
                    theForm.addChild(myNumStepper);
                    //3. radio button
                    var myRadioButton:RadioButton = new RadioButton;
                    myRadioButton.id = "myRadioButton" + theChar;
                    myRadioButton.name = "myRadioButton" + theChar;
                    myRadioButton.label = "my radio button";
                    myRadioButton.selected = true;
                    theForm.addChild(myRadioButton);
                    //4. Panel
                    var thePanel:Panel = new Panel();
                    thePanel.width = 300;
                    thePanel.height = 475;
                    thePanel.name=theChar;
                    thePanel.title = "My Profile Panel";
                    thePanel.setStyle("backgroundColor", "blue");
                    //add the form to the panel
                    thePanel.addChild(theForm);
                    //add the Panel to the list control
                    myContainer.addChild(thePanel);
                protected function btnClear_clickHandler(event:MouseEvent):void
                    var numChildren:Number = myContainer.numChildren;
                    for(var i:Number=numChildren - 1; i > -1; i--){
                        myContainer.removeChildAt(i);
            ]]>
        </fx:Script>
        <mx:VBox width="100%">
            <mx:Panel id="myContainer" />
            <mx:Button id="btnAdd" label="Add a panel" click="btnAdd_clickHandler(event)" color="black"/>
            <mx:Button id="btnClear" label="Clear" click="btnClear_clickHandler(event)" color="black" />
        </mx:VBox>
    </s:Application>
    Any idea why radio buttons causing this to happen? If I comment out the radio button, this works fine. This is really baffling me.
    The exception is thrown when the dynamically created panel (thePanel) is added to the main Panel (myContainer):
    myContainer.addChild(thePanel); <--- causes the exception!
    ^ Why would radio buttons make a difference on "thePanel"?? How can I enforce parent-child relationship, explicitly? .parent is read-only

  • My ipod shuffle voice over button does not list the song/artist or give battery status.  I am following direions but it doesn't respond wether I push it once or twice.  Any ideas?

    ?The voice over button does not work per directions (press once for title/artist; press twice for battery status.  Any ideas how to make this work?

    I discovered that if I push the button quickly (twice), I get the battery status.  But I still do not have any title artist data.  The music get quieter but no info.

  • Interactive PDF button functions go beserk after export

    Mac OS 10. 6.8. - InDesign 7.5.3
    I have 21 page InDesign doc that is designed as an interactive PDF. The left hand nav is a simple page navigation via bookmarks that allows the user to navigate to any page of the document. Most pages are just copy but on two pages I also have a cascading list of items that the user can click on and reveal the additional information about the topic (see http://i47.tinypic.com/whmupv.jpg ). One of these cascading lists has 11 topics. These topics are stacked on 11 layers to allow the user to seamlessly navigate all the topics and additional information seamlessly on one page. The topics are all buttons that show/hide the relevant layer of information.
    However, when I export the PDF, the last 3 topics (or bottom three layers of topics) simply do not work. When you click on any button in the top eight layers, they perform as programmed. But the bottom three on any layer are hopelessly broken, turning on/off the wrong layers and buttons. I've redone all the button interactions twice now, once from the top of the series of layers down and once from the bottom of the series of layers to the top. I can't make the bottom three layers work right. I even tried changing the layer order, but those bottom three layers continue to break.
    I also tried downloading the Indd 6.0.1 trial and exporting from that but I get the same broken buttons. Is there a possible fix in Acrobat that I could try? We've done interactive PDFs like this before with up to 8 topics in a list and that one worked fine, although we discovered other bugs with layers of buttons like this.
    Thank you.

    If you look at where the red circles are you can see the very slight increase in object scale.  The 2nd image is a comparison of a spread without any use of buttons.

  • Button in JTabbedPane Title

    Hi all
    I am Using JTabbedPane I need to include button for close within every tab. How I Do this one using swings

    hi!
    for that you need to use the javax.swing.plaf.basic.BasicTabbedPaneUI class. i wrote
    package una.common.file.vc.gui.control;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Event;
    import java.awt.Font;
    import java.awt.FontMetrics;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Insets;
    import java.awt.LayoutManager;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.Shape;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ContainerEvent;
    import java.awt.event.ContainerListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.image.BufferedImage;
    import java.util.EventListener;
    import java.util.Hashtable;
    import java.util.Vector;
    import javax.swing.AbstractAction;
    import javax.swing.ActionMap;
    import javax.swing.Icon;
    import javax.swing.InputMap;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    import javax.swing.JTabbedPane;
    import javax.swing.JViewport;
    import javax.swing.KeyStroke;
    import javax.swing.SwingConstants;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.border.Border;
    import javax.swing.border.SoftBevelBorder;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import javax.swing.plaf.ActionMapUIResource;
    import javax.swing.plaf.ComponentUI;
    import javax.swing.plaf.InputMapUIResource;
    import javax.swing.plaf.UIResource;
    import javax.swing.plaf.basic.BasicArrowButton;
    import javax.swing.plaf.basic.BasicHTML;
    import javax.swing.plaf.basic.BasicTabbedPaneUI;
    import javax.swing.text.View;
    import una.common.file.vc.gui.VCResource;
    * UI for <code>VCTabbedPane</code>.
    * <p>
    * Credits to:
    public class VCTabPaneUI extends BasicTabbedPaneUI implements ActionListener
         // Instance variables initialized at installation
         private ContainerListener          containerListener;
         private Vector                         htmlViews;
         private Hashtable                    mnemonicToIndexMap;
          * InputMap used for mnemonics. Only non-null if the JTabbedPane has
          * mnemonics associated with it. Lazily created in initMnemonics.
         private InputMap                    mnemonicInputMap;
         // For use when tabLayoutPolicy = SCROLL_TAB_LAYOUT
         protected ScrollableTabSupport     tabScroller;
         private int                              tabCount;
         protected MyMouseMotionListener     motionListener;
         // UI creation
         private static final int          INACTIVE                    = 0;
         private static final int          OVER                         = 1;
         private static final int          PRESSED                         = 2;
         protected static final int          BUTTONSIZE                    = 15;
         protected static final int          WIDTHDELTA                    = 5;
         private static final Border          PRESSEDBORDER               = new SoftBevelBorder(
                                                                                         SoftBevelBorder.LOWERED);
         private static final Border          OVERBORDER                    = new SoftBevelBorder(
                                                                                         SoftBevelBorder.RAISED);
         private BufferedImage               closeImgB;
         private BufferedImage               closeImgI;
         private JButton                         closeB;
         private int                              overTabIndex               = -1;
         private int                              closeIndexStatus          = INACTIVE;
         private int                              maxIndexStatus               = INACTIVE;
         private boolean                         mousePressed               = false;
         private boolean                         isCloseButtonEnabled     = true;
         private JPopupMenu                    actionPopupMenu               = null;
         private JMenuItem                    closeItem                    = null;
         private JMenuItem                    closeOthers                    = null;
         private JMenuItem                    closeAll                    = null;
         public VCTabPaneUI()
              super();
              closeImgB = new BufferedImage(BUTTONSIZE, BUTTONSIZE,
                        BufferedImage.TYPE_4BYTE_ABGR);
              closeImgI = new BufferedImage(BUTTONSIZE, BUTTONSIZE,
                        BufferedImage.TYPE_4BYTE_ABGR);
              closeB = new JButton("X");
              closeB.setSize(BUTTONSIZE, BUTTONSIZE);
              actionPopupMenu = new JPopupMenu();
              closeItem = new JMenuItem(VCResource.getString("CLOSE"));
              closeOthers = new JMenuItem(VCResource.getString("CLOSE_OTHERS"));
              closeAll = new JMenuItem(VCResource.getString("CLOSE_ALL"));
              actionPopupMenu.add(closeItem);
              actionPopupMenu.add(closeOthers);
              actionPopupMenu.add(closeAll);
              closeItem.addActionListener(this);
              closeOthers.addActionListener(this);
              closeAll.addActionListener(this);
         protected boolean isOneActionButtonEnabled()
              return isCloseButtonEnabled;
         public boolean isCloseEnabled()
              return isCloseButtonEnabled;
         public void setCloseIcon(boolean b)
              isCloseButtonEnabled = b;
         protected int calculateTabWidth(int tabPlacement, int tabIndex,
                   FontMetrics metrics)
              int delta = 2;
              if (!isOneActionButtonEnabled())
                   delta += 6;
              else
                   if (isCloseButtonEnabled)
                        delta += BUTTONSIZE + WIDTHDELTA;
              return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + delta;
         protected int calculateTabHeight(int tabPlacement, int tabIndex,
                   int fontHeight)
              return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight) + 5;
         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;
              View v = getTextViewForTab(tabIndex);
              if (v != null)
                   tabPane.putClientProperty("html", v);
              SwingUtilities.layoutCompoundLabel((JComponent) tabPane, metrics,
                        title, icon, SwingUtilities.CENTER, SwingUtilities.LEFT,
                        SwingUtilities.CENTER, SwingUtilities.CENTER, tabRect,
                        iconRect, textRect, textIconGap);
              tabPane.putClientProperty("html", null);
              iconRect.x = tabRect.x + 8;
              textRect.x = iconRect.x + iconRect.width + textIconGap;
         protected MouseListener createMouseListener()
              return new MyMouseHandler();
         protected ScrollableTabButton createScrollableTabButton(int direction)
              return new ScrollableTabButton(direction);
         protected Rectangle newCloseRect(Rectangle rect)
              int dx = rect.x + rect.width;
              int dy = (rect.y + rect.height) / 2 - 6;
              return new Rectangle(dx - BUTTONSIZE - WIDTHDELTA, dy, BUTTONSIZE,
                        BUTTONSIZE);
         protected Rectangle newMaxRect(Rectangle rect)
              int dx = rect.x + rect.width;
              int dy = (rect.y + rect.height) / 2 - 6;
              if (isCloseButtonEnabled)
                   dx -= BUTTONSIZE;
              return new Rectangle(dx - BUTTONSIZE - WIDTHDELTA, dy, BUTTONSIZE,
                        BUTTONSIZE);
         protected void updateOverTab(int x, int y)
              if (overTabIndex != (overTabIndex = getTabAtLocation(x, y)))
                   tabScroller.tabPanel.repaint();
         protected void updateCloseIcon(int x, int y)
              if (overTabIndex != -1)
                   int newCloseIndexStatus = INACTIVE;
                   Rectangle closeRect = newCloseRect(rects[overTabIndex]);
                   if (closeRect.contains(x, y))
                        newCloseIndexStatus = mousePressed ? PRESSED : OVER;
                   if (closeIndexStatus != (closeIndexStatus = newCloseIndexStatus))
                        tabScroller.tabPanel.repaint();
    //     protected void updateMaxIcon(int x, int y)
    //          if (overTabIndex != -1)
    //               int newMaxIndexStatus = INACTIVE;
    //               Rectangle maxRect = newMaxRect(rects[overTabIndex]);
    //               if (maxRect.contains(x, y))
    //                    newMaxIndexStatus = mousePressed ? PRESSED : OVER;
    //               if (maxIndexStatus != (maxIndexStatus = newMaxIndexStatus))
    //                    tabScroller.tabPanel.repaint();
         private void setTabIcons(int x, int y)
              // if the mouse isPressed
              if (!mousePressed)
                   updateOverTab(x, y);
              if (isCloseButtonEnabled)
                   updateCloseIcon(x, y);
         public static ComponentUI createUI(JComponent c)
              return new VCTabPaneUI();
          * Invoked by <code>installUI</code> to create a layout manager object to
          * manage the <code>JTabbedPane</code>.
          * @return a layout manager object
          * @see TabbedPaneLayout
          * @see javax.swing.JTabbedPane#getTabLayoutPolicy
         protected LayoutManager createLayoutManager()
              return new TabbedPaneScrollLayout();
          * In an attempt to preserve backward compatibility for programs which have
          * extended BasicTabbedPaneUI to do their own layout, the UI uses the
          * installed layoutManager (and not tabLayoutPolicy) to determine if
          * scrollTabLayout is enabled.
          * Creates and installs any required subcomponents for the JTabbedPane.
          * Invoked by installUI.
          * @since 1.4
         protected void installComponents()
              if (tabScroller == null)
                   tabScroller = new ScrollableTabSupport(tabPane.getTabPlacement());
                   tabPane.add(tabScroller.viewport);
                   tabPane.add(tabScroller.scrollForwardButton);
                   tabPane.add(tabScroller.scrollBackwardButton);
          * Removes any installed subcomponents from the JTabbedPane. Invoked by
          * uninstallUI.
          * @since 1.4
         protected void uninstallComponents()
              tabPane.remove(tabScroller.viewport);
              tabPane.remove(tabScroller.scrollForwardButton);
              tabPane.remove(tabScroller.scrollBackwardButton);
              tabScroller = null;
         protected void installListeners()
              if ((propertyChangeListener = createPropertyChangeListener()) != null)
                   tabPane.addPropertyChangeListener(propertyChangeListener);
              if ((tabChangeListener = createChangeListener()) != null)
                   tabPane.addChangeListener(tabChangeListener);
              if ((mouseListener = createMouseListener()) != null)
                   tabScroller.tabPanel.addMouseListener(mouseListener);
              if ((focusListener = createFocusListener()) != null)
                   tabPane.addFocusListener(focusListener);
              // PENDING(api) : See comment for ContainerHandler
              if ((containerListener = new ContainerHandler()) != null)
                   tabPane.addContainerListener(containerListener);
                   if (tabPane.getTabCount() > 0)
                        htmlViews = createHTMLVector();
              if ((motionListener = new MyMouseMotionListener()) != null)
                   tabScroller.tabPanel.addMouseMotionListener(motionListener);
         protected void uninstallListeners()
              if (mouseListener != null)
                   tabScroller.tabPanel.removeMouseListener(mouseListener);
                   mouseListener = null;
              if (motionListener != null)
                   tabScroller.tabPanel.removeMouseMotionListener(motionListener);
                   motionListener = null;
              if (focusListener != null)
                   tabPane.removeFocusListener(focusListener);
                   focusListener = null;
              // PENDING(api): See comment for ContainerHandler
              if (containerListener != null)
                   tabPane.removeContainerListener(containerListener);
                   containerListener = null;
                   if (htmlViews != null)
                        htmlViews.removeAllElements();
                        htmlViews = null;
              if (tabChangeListener != null)
                   tabPane.removeChangeListener(tabChangeListener);
                   tabChangeListener = null;
              if (propertyChangeListener != null)
                   tabPane.removePropertyChangeListener(propertyChangeListener);
                   propertyChangeListener = null;
         protected ChangeListener createChangeListener()
              return new TabSelectionHandler();
         protected void installKeyboardActions()
              InputMap km = getMyInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
              SwingUtilities.replaceUIInputMap(tabPane,
                        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, km);
              km = getMyInputMap(JComponent.WHEN_FOCUSED);
              SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, km);
              ActionMap am = createMyActionMap();
              SwingUtilities.replaceUIActionMap(tabPane, am);
              tabScroller.scrollForwardButton.setAction(am
                        .get("scrollTabsForwardAction"));
              tabScroller.scrollBackwardButton.setAction(am
                        .get("scrollTabsBackwardAction"));
         InputMap getMyInputMap(int condition)
              if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
                   return (InputMap) UIManager.get("TabbedPane.ancestorInputMap");
              } else if (condition == JComponent.WHEN_FOCUSED)
                   return (InputMap) UIManager.get("TabbedPane.focusInputMap");
              return null;
         ActionMap createMyActionMap()
              ActionMap map = new ActionMapUIResource();
              map.put("navigateNext", new NextAction());
              map.put("navigatePrevious", new PreviousAction());
              map.put("navigateRight", new RightAction());
              map.put("navigateLeft", new LeftAction());
              map.put("navigateUp", new UpAction());
              map.put("navigateDown", new DownAction());
              map.put("navigatePageUp", new PageUpAction());
              map.put("navigatePageDown", new PageDownAction());
              map.put("requestFocus", new RequestFocusAction());
              map.put("requestFocusForVisibleComponent",
                        new RequestFocusForVisibleAction());
              map.put("setSelectedIndex", new SetSelectedIndexAction());
              map.put("scrollTabsForwardAction", new ScrollTabsForwardAction());
              map.put("scrollTabsBackwardAction", new ScrollTabsBackwardAction());
              return map;
         protected void uninstallKeyboardActions()
              SwingUtilities.replaceUIActionMap(tabPane, null);
              SwingUtilities.replaceUIInputMap(tabPane,
                        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
              SwingUtilities
                        .replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, null);
          * Reloads the mnemonics. This should be invoked when a memonic changes,
          * when the title of a mnemonic changes, or when tabs are added/removed.
         private void updateMnemonics()
              resetMnemonics();
              for (int counter = tabPane.getTabCount() - 1; counter >= 0; counter--)
                   int mnemonic = tabPane.getMnemonicAt(counter);
                   if (mnemonic > 0)
                        addMnemonic(counter, mnemonic);
          * Resets the mnemonics bindings to an empty state.
         private void resetMnemonics()
              if (mnemonicToIndexMap != null)
                   mnemonicToIndexMap.clear();
                   mnemonicInputMap.clear();
          * Adds the specified mnemonic at the specified index.
         private void addMnemonic(int index, int mnemonic)
              if (mnemonicToIndexMap == null)
                   initMnemonics();
              mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK),
                        "setSelectedIndex");
              mnemonicToIndexMap.put(new Integer(mnemonic), new Integer(index));
          * Installs the state needed for mnemonics.
         private void initMnemonics()
              mnemonicToIndexMap = new Hashtable();
              mnemonicInputMap = new InputMapUIResource();
              mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane,
                        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
              SwingUtilities
                        .replaceUIInputMap(tabPane,
                                  JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
                                  mnemonicInputMap);
         // UI Rendering
         public void paint(Graphics g, JComponent c)
              int tc = tabPane.getTabCount();
              if (tabCount != tc)
                   tabCount = tc;
                   updateMnemonics();
              int selectedIndex = tabPane.getSelectedIndex();
              int tabPlacement = tabPane.getTabPlacement();
              ensureCurrentLayout();
              // Paint content border
              paintContentBorder(g, tabPlacement, selectedIndex);
         protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects,
                   int tabIndex, Rectangle iconRect, Rectangle textRect)
              Rectangle tabRect = rects[tabIndex];
              int selectedIndex = tabPane.getSelectedIndex();
              boolean isSelected = selectedIndex == tabIndex;
              boolean isOver = overTabIndex == tabIndex;
              Graphics2D g2 = null;
              Shape save = null;
              boolean cropShape = false;
              int cropx = 0;
              int cropy = 0;
              if (g instanceof Graphics2D)
                   g2 = (Graphics2D) g;
                   // Render visual for cropped tab edge...
                   Rectangle viewRect = tabScroller.viewport.getViewRect();
                   int cropline;
                   cropline = viewRect.x + viewRect.width;
                   if ((tabRect.x < cropline)
                             && (tabRect.x + tabRect.width > cropline))
                        cropx = cropline - 1;
                        cropy = tabRect.y;
                        cropShape = true;
                   if (cropShape)
                        save = g2.getClip();
                        g2
                                  .clipRect(tabRect.x, tabRect.y, tabRect.width,
                                            tabRect.height);
              paintTabBackground(g, tabPlacement, tabIndex, tabRect.x, tabRect.y,
                        tabRect.width, tabRect.height, isSelected);
              paintTabBorder(g, tabPlacement, tabIndex, tabRect.x, tabRect.y,
                        tabRect.width, tabRect.height, isSelected);
              String title = tabPane.getTitleAt(tabIndex);
              Font font = tabPane.getFont();
              FontMetrics metrics = g.getFontMetrics(font);
              Icon icon = getIconForTab(tabIndex);
              layoutLabel(tabPlacement, metrics, tabIndex, title, icon, tabRect,
                        iconRect, textRect, isSelected);
              paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect,
                        isSelected);
              paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
              paintFocusIndicator(g, tabPlacement, rects, tabIndex, iconRect,
                        textRect, isSelected);
              if (cropShape)
                   paintCroppedTabEdge(g, tabPlacement, tabIndex, isSelected, cropx,
                             cropy);
                   g2.setClip(save);
              } else if (isOver || isSelected)
                   int dx = tabRect.x + tabRect.width - BUTTONSIZE - WIDTHDELTA;
                   int dy = (tabRect.y + tabRect.height) / 2 - 6;
                   if (isCloseButtonEnabled)
                        paintCloseIcon(g2, dx, dy, isOver);
         protected void paintCloseIcon(Graphics g, int dx, int dy, boolean isOver)
              paintActionButton(g, dx, dy, closeIndexStatus, isOver, closeB,
                        closeImgB);
              g.drawImage(closeImgI, dx, dy + 1, null);
         protected void paintActionButton(Graphics g, int dx, int dy, int status,
                   boolean isOver, JButton button, BufferedImage image)
              button.setBorder(null);
              if (isOver)
                   switch (status)
                   case OVER:
                        button.setBorder(OVERBORDER);
                        break;
                   case PRESSED:
                        button.setBorder(PRESSEDBORDER);
                        break;
              button.setBackground(tabScroller.tabPanel.getBackground());
              button.paint(image.getGraphics());
              g.drawImage(image, dx, dy, null);
          * This method will create and return a polygon shape for the given tab
          * rectangle which has been cropped at the specified cropline with a torn
          * edge visual. e.g. A "File" tab which has cropped been cropped just after
          * the "i": ------------- | ..... | | . | | ... . | | . . | | . . | | . . |
          * The x, y arrays below define the pattern used to create a "torn" edge
          * segment which is repeated to fill the edge of the tab. For tabs placed on
          * TOP and BOTTOM, this righthand torn edge is created by line segments
          * which are defined by coordinates obtained by subtracting xCropLen[i] from
          * (tab.x + tab.width) and adding yCroplen[i] to (tab.y). For tabs placed on
          * LEFT or RIGHT, the bottom torn edge is created by subtracting xCropLen[i]
          * from (tab.y + tab.height) and adding yCropLen[i] to (tab.x).
         private static final int     CROP_SEGMENT     = 12;
         private void paintCroppedTabEdge(Graphics g, int tabPlacement,
                   int tabIndex, boolean isSelected, int x, int y)
              g.setColor(shadow);
              g.drawLine(x, y, x, y + rects[tabIndex].height);
         private void ensureCurrentLayout()
              if (!tabPane.isValid())
                   tabPane.validate();
               * If tabPane doesn't have a peer yet, the validate() call will silently
               * fail. We handle that by forcing a layout if tabPane is still invalid.
               * See bug 4237677.
              if (!tabPane.isValid())
                   TabbedPaneLayout layout = (TabbedPaneLayout) tabPane.getLayout();
                   layout.calculateLayoutInfo();
          * Returns the bounds of the specified tab in the coordinate space of the
          * JTabbedPane component. This is required because the tab rects are by
          * default defined in the coordinate space of the component where they are
          * rendered, which could be the JTabbedPane (for WRAP_TAB_LAYOUT) or a
          * ScrollableTabPanel (SCROLL_TAB_LAYOUT). This method should be used
          * whenever the tab rectangle must be relative to the JTabbedPane itself and
          * the result should be placed in a designated Rectangle object (rather than
          * instantiating and returning a new Rectangle each time). The tab index
          * parameter must be a valid tabbed pane tab index (0 to tab count - 1,
          * inclusive). The destination rectangle parameter must be a valid
          * <code>Rectangle</code> instance. The handling of invalid parameters is
          * unspecified.
          * @param tabIndex
          *            the index of the tab
          * @param dest
          *            the rectangle where the result should be placed
          * @return the resulting rectangle
          * @since 1.4
         protected Rectangle getTabBounds(int tabIndex, Rectangle dest)
              try{
                   dest.width = rects[tabIndex].width;
                   dest.height = rects[tabIndex].height;
                   Point vpp = tabScroller.viewport.getLocation();
                   Point viewp = tabScroller.viewport.getViewPosition();
                   dest.x = rects[tabIndex].x + vpp.x - viewp.x;
                   dest.y = rects[tabIndex].y + vpp.y - viewp.y;
              }catch(Throwable a_th){}
              return dest;
         private int getTabAtLocation(int x, int y)
              ensureCurrentLayout();
              int tabCount = tabPane.getTabCount();
              for (int i = 0; i < tabCount; i++)
                   if (rects.contains(x, y))
                        return i;
              return -1;
         public int getOverTabIndex()
              return overTabIndex;
         * Returns the index of the tab closest to the passed in location, note that
         * the returned tab may not contain the location x,y.
         private int getClosestTab(int x, int y)
              int min = 0;
              int tabCount = Math.min(rects.length, tabPane.getTabCount());
              int max = tabCount;
              int tabPlacement = tabPane.getTabPlacement();
              boolean useX = (tabPlacement == TOP || tabPlacement == BOTTOM);
              int want = (useX) ? x : y;
              while (min != max)
                   int current = (max + min) / 2;
                   int minLoc;
                   int maxLoc;
                   if (useX)
                        minLoc = rects[current].x;
                        maxLoc = minLoc + rects[current].width;
                   } else
                        minLoc = rects[current].y;
                        maxLoc = minLoc + rects[current].height;
                   if (want < minLoc)
                        max = current;
                        if (min == max)
                             return Math.max(0, current - 1);
                   } else if (want >= maxLoc)
                        min = current;
                        if (max - min <= 1)
                             return Math.max(current + 1, tabCount - 1);
                   } else
                        return current;
              return min;
         * Returns a point which is translated from the specified point in the
         * JTabbedPane's coordinate space to the coordinate space of the
         * ScrollableTabPanel. This is used for SCROLL_TAB_LAYOUT ONLY.
         private Point translatePointToTabPanel(int srcx, int srcy, Point dest)
              Point vpp = tabScroller.viewport.getLocation();
              Point viewp = tabScroller.viewport.getViewPosition();
              dest.x = srcx + vpp.x + viewp.x;
              dest.y = srcy + vpp.y + viewp.y;
              return dest;
         // BasicTabbedPaneUI methods
         // Tab Navigation methods
         // REMIND(ADC,7/29/98): This method should be made
         // protected in the next release where
         // API changes are allowed
         boolean requestMyFocusForVisibleComponent()
              Component visibleComponent = getVisibleComponent();
              if (visibleComponent.isFocusTraversable())
                   visibleComponent.requestFocus();
                   return true;
              } else if (visibleComponent instanceof JComponent)
                   if (((JComponent) visibleComponent).requestDefaultFocus())
                        return true;
              return false;
         private static class RightAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.navigateSelectedTab(EAST);
         private static class LeftAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.navigateSelectedTab(WEST);
         private static class UpAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.navigateSelectedTab(NORTH);
         private static class DownAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.navigateSelectedTab(SOUTH);
         private static class NextAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.navigateSelectedTab(NEXT);
         private static class PreviousAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.navigateSelectedTab(PREVIOUS);
         private static class PageUpAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   int tabPlacement = pane.getTabPlacement();
                   if (tabPlacement == TOP || tabPlacement == BOTTOM)
                        ui.navigateSelectedTab(WEST);
                   } else
                        ui.navigateSelectedTab(NORTH);
         private static class PageDownAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   int tabPlacement = pane.getTabPlacement();
                   if (tabPlacement == TOP || tabPlacement == BOTTOM)
                        ui.navigateSelectedTab(EAST);
                   } else
                        ui.navigateSelectedTab(SOUTH);
         private static class RequestFocusAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   pane.requestFocus();
         private static class RequestFocusForVisibleAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.requestMyFocusForVisibleComponent();
         * Selects a tab in the JTabbedPane based on the String of the action
         * command. The tab selected is based on the first tab that has a mnemonic
         * matching the first character of the action command.
         private static class SetSelectedIndexAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = (JTabbedPane) e.getSource();
                   if (pane != null && (pane.getUI() instanceof VCTabPaneUI))
                        VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                        String command = e.getActionCommand();
                        if (command != null && command.length() > 0)
                             int mnemonic = (int) e.getActionCommand().charAt(0);
                             if (mnemonic >= 'a' && mnemonic <= 'z')
                                  mnemonic -= ('a' - 'A');
                             Integer index = (Integer) ui.mnemonicToIndexMap
                                       .get(new Integer(mnemonic));
                             if (index != null && pane.isEnabledAt(index.intValue()))
                                  pane.setSelectedIndex(index.intValue());
         private static class ScrollTabsForwardAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = null;
                   Object src = e.getSource();
                   if (src instanceof JTabbedPane)
                        pane = (JTabbedPane) src;
                   } else if (src instanceof ScrollableTabButton)
                        pane = (JTabbedPane) ((ScrollableTabButton) src).getParent();
                   } else
                        return; // shouldn't happen
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.tabScroller.scrollForward(pane.getTabPlacement());
         private static class ScrollTabsBackwardAction extends AbstractAction
              public void actionPerformed(ActionEvent e)
                   JTabbedPane pane = null;
                   Object src = e.getSource();
                   if (src instanceof JTabbedPane)
                        pane = (JTabbedPane) src;
                   } else if (src instanceof ScrollableTabButton)
                        pane = (JTabbedPane) ((ScrollableTabButton) src).getParent();
                   } else
                        return; // shouldn't happen
                   VCTabPaneUI ui = (VCTabPaneUI) pane.getUI();
                   ui.tabScroller.scrollBackward(pane.getTabPlacement());
         * This inner class is marked "public" due to a compiler bug. This
         * class should be treated as a "protected" inner class.
         * Instantiate it only within subclasses of BasicTabbedPaneUI.
         private class TabbedPaneScrollLayout extends TabbedPaneLayout
              protected int preferredTabAreaHeight(int tabPlacement, int width)
                   return calculateMaxTabHeight(tabPlacement);
              protected int preferredTabAreaWidth(int tabPlacement, int height)
                   return calculateMaxTabWidth(tabPlacement);
              public void layoutContainer(Container parent)
                   int tabPlacement = tabPane.getTabPlacement();
                   int tabCount = tabPane.getTabCount();
                   Insets insets = tabPane.getInsets();
                   int selectedIndex = tabPane.getSelectedIndex();
                   Component visibleComponent = getVisibleComponent();
                   calculateLayoutInfo();
                   if (selectedIndex < 0)
                        if (visibleComponent != null)
                             // The last tab was removed, so remove the component
                             setVisibleComponent(null);
                   } else
                        Component selectedComponent = tabPane
                                  .getComponentAt(selectedIndex);
                        boolean shouldChangeFocus = false;
                        // In order to allow programs to use a single component
                        // as the display for multiple tabs, we will not change
                        // the visible compnent if the currently selected tab
                        // has a null component. This is a bit dicey, as we don't
                        // explicitly state we support this in the spec, but since
                        // programs are now depending on this, we're making it work.
                        if (selectedComponent != null)
                             if (selectedComponent != visibleComponent
                                       && visibleComponent != null)
                                  if (SwingUtilities.findFocusOwner(visibleComponent) != null)
                                       shouldChangeFocus = true;
                             setVisibleComponent(selectedComponent);
                        int tx, ty, tw, th; // tab area bounds
                        int cx, cy, cw, ch; // content area bounds
                        Insets contentInsets = getContentBorderInsets(tabPlacement);
                        Rectangle bounds = tabPane.getBounds();
                        int numChildren = tabPane.getComponentCount();
                        if (numChildren > 0)
                             // calculate tab area bounds
                             tw = bounds.width - insets.left - insets.right;
                             th = calculateTabAreaHeight(tabPlacement, runCount,
                                       maxTabHeight);
                             tx = insets.left;
                             ty =

  • Grey Screen - stuck in paint()???

    Hi all,
    I'm at the late stages of a java front-end project and I have just started having a recurring problem:
    when the application starts up it appears to be getting stuck in the initial paint which leaves a frame with a plain grey background. When the application is resized or any other event which would cause a repaint it is ok but is getting stuck until then. Adding a repaint()/validate()/revalidate() etc after the show() call doesn't seem to solve the problem.
    One thing that makes this more mystifying is that it only happens in 1 of 5 times the application is started and not at all on some PC's so I can't debug it.
    Has anyone else seen this problem or got a solution?
    Any help wpuld be greatly appreciated as I've run out of ideas
    Cheers
    Phil

    I got this problem when i was doing my project last year...
    i tried alot of ways but i can't really recall which methods works..
    1 way i will try is to paint all controls in the paint() method.
    public void paint()
    //do all the things
    button.paint();
    repaint();
    try and see if it works.. because i can't really recall my solutions..
    :�

Maybe you are looking for

  • How to move a file from one internal drive to another

    I have a Mac Pro with 10.6. My main drive is a 240 GB SSD. I would like to move files from it to another internal drive to free up space on the SSD. The only way I can figure out to do it is to copy a file to the other internal drive and then move it

  • Buttons in ALV Grid cell need focus to be clicked :-(

    Hi, I have an ALV Grid with single cells displayed as buttons (dependend on the data in the corresponding row). Unfortunatelly the button-cells need focus to be clicked. So you need two clicks: one to get the focus to the desired cell and one to real

  • Clearing a open item via FM: FKK_CREATE_DOC_AND_CLEAR

    Hi, I have a requirement where i need to post a debit item which will clear the open items posted to a Contract Account (SAP IS-U). I have found the FM as stated in the subject line which will be used to to clear the open items. I would like to know

  • How to make symblos in smart forms...

    Hi abapers,           In smart foms i like to have small ckeck box ie , small square box 1*1 size ...how to do ... thanks in advance , reagads , veera

  • How to Display Data from Oracle E Business Suite tables in ADF

    Hi, I am new to ADF. I have a requirement to Create an ADF page for Search Results Screen. However the result data is from one of the Oracle E Business Suite Tables. ie I need to create a Screen where user will enter a Purchase Order Number and Click