Some abnormality between java 1.5 and 1.4 swings code

Hi
my requirement: i need to show the popup size of a combo box(whose size is preffered size) to be as large as largest item in the combobox items. so i have written a popupmenu listener. which works fine in java 1.4 but in 1.5 the popup is shown abnormally.
abnormality is combobox list content is centered in the popup and also shows the list content incompletely.
below is the fragment of code for popup listener
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
public class ComboBoxPopupMenuListener implements PopupMenuListener{
     public void popupMenuCanceled(PopupMenuEvent e) {
     public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
     public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
          JComboBox box = (JComboBox) e.getSource();
          Object comp = box.getUI().getAccessibleChild(box, 0);
          if (!(comp instanceof JPopupMenu)) {
               return;
          JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
          if (scrollPane instanceof JScrollPane) {
               JScrollPane sp = (JScrollPane) scrollPane;
               Dimension size = scrollPane.getPreferredSize();
               Component []comps = ((JScrollPane) scrollPane).getComponents();
               for (int i = 0; i < comps.length; i++) {
                    if(comps[i] instanceof JViewport)
                         JViewport view = (JViewport) comps;
                         size.width = (int) (view).getViewSize().getWidth();
               sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
               scrollPane.setPreferredSize(size);
i have an alternative to this as providing tool tips or changing combo box to list. but can you please tell me where i am doin wrong                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

below is the fragment of code for popup listenerand what do you expect us to do with that?

Similar Messages

  • Differences between Java Virtual Machine and Java HotSpot ??

    I am little bit confused between Java Virtual Machine and Java HotSpot.
    My understanding is:
    Java Virtual Machine is the environment to execute Java programs. I think I could understand this part.
    However, the description says, "The Java HotSpot product line consists of a server-side and a client-side virtual machine that share the Java HotSpot runtime environment, but have different compilers suited to the different performance characteristics of clients and servers."
    I am confused with server-side virtual machine. what is that?? Does it mean the environment to execute Java programs remotely through network?? For example, Java plug-in.?? Please advise.

    Hotspot is a JVM.
    Hotspot has different configuration settings. Some of those settings are better suited for a client application. Some are better suited to server applications.

  • Difference between Java 1.2 and 1.4

    Can Anyone tell me the Difference between Java 1.2 and 1.4

    Hi,
    Well to start with, a hell lot of classes have been added, and others have been altered. The only change in the language is that the assert statement was added.
    An application written in 1.2 will most likely run under 1.4.
    /Kaj

  • I there any dependcy between Java Enterprise Edition and Java standard Edit

    Hi Friends,
    Is J2EE 1.4 uses Java SDK 1.4 or 1.5.Please reply as earlier as possible.It is urgent
    Thanks
    Bye

    Each version of the Java EE platform must be able to run on the associated version of the Java SE platform. So, J2EE 1.4 must be able to run on J2SE 1.4 , Java EE 5 must be able to run on Java SE 5, etc. Note that this doesn't mean a particular implementation of Java EE can't be run with a more recent version of the JDK. For example, the J2EE 1.4 SDK can be run with J2SE 1.4 or Java SE 5. The key is that both the implementation of the Java EE platform and the applications written to that particular release of the platform must write to the corresponding Java SE version API. In other words, neither a J2EE 1.4 implementation nor a J2EE 1.4 application should make use of an API that was added in Java SE 5.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Difference between Java Server Faces and Apache Struts

    Hi ,
    I'm quite new to Java Server Faces and Apache Struts. I wonder are they two comparable Frameworks for web presentation?
    And can anybody elaborate please, if they differ in what aspects?
    Thanks
    Jaffar Shaikh

    Here are slides from a presentation by Craig McClanahan that compares them (I believe you can search for other articles on this topic): http://www.baychi.org/calendar/files/Struts-And-Faces/Struts-And-Faces.pdf

  • Difference between java plug in and JRE

    Hi,
    as Internet Explorer uses a JVM to run applets, I would like to know if there is a difference between the java plug-in you download for your IE, with the JRE you install on your computer to run java programs.
    Thanks in advance, Fred.

    hi,
    as Internet Explorer uses a JVM to run applets, I
    would like to know if there is a difference between
    the java plug-in you download for your IE, with the
    JRE you install on your computer to run java
    programs.ya, they are different in a few aspects.
    The plugin, for the HTML client (eg IE) usually is capable of executing the applets -a subset of java applications. whereas, the standard JVM executes the standalone applications and some network applications developed using RMI feature of Java. It is not capable of executing applets.
    It would be inappropriate to go into the details of the differences in the implementations of the two versions.
    cheers
    kalpesh

  • Differences in optimizations during compilation between java 1.4 and 1.5

    Hi
    I have an application which frequently runs into out of memory error. After doing some profiling, I found that it has more to do with the throughput of the application. Because which, messages that have to be polled from a queue are not being dequeued. This application has been compiled in java 1.5. But when I compiled the same in java 1.4, I didn't get into this problem.
    When I de-compiled the class files, I found that in 1.5, for every string concatenation, the compiler replaces it with StringBuilder() and appends the string. To check whether this object instantiation might be causing the trouble, I wrote a small snippet:
    private static void doWithConcatenationOperator() {
    for (int idx = 0; idx < fNumIterations; idx++) {
    String result = "Does" + "StringBuilder()" + "reduce"
    + "ThroughPut" + "of the" + "Application";
    private static void doWithStringBuilder() {
    for (int idx = 0; idx < fNumIterations; idx++) {
    (new StringBuilder()).append("Does").append("StringBuilder()")
    .append("reduce").append("ThroughPut").append("of the")
    .append("Application").toString();
    When I iterate through these loops( 1 million iterations), the concatenation operation takes less than 16 milliseconds whereas the StringBuilder takes upwards of 512 milliseconds.
    My question being; are there any other so called optimizations that can reduce the throughput when compiled in 1.5.
    Thanks
    Edited by: Incubus on Jan 18, 2009 11:00 PM

    Incubus wrote:
    say I have a code that does:
    public void StringConcat(){
    int noOfIter = 10000;
    for(int i = 0; i < noOfIter; i++){
    String s = "String " + i + " Being " + i + "concatenated " + i + "using " + i + "String" + i + "Builder";
    If I compile this in 1.4 ( i.e using javac -source 1.4); the decompiled code looks the same.
    But if I do so in 1.5 ( i.e if I decompile the same code compiled using javac -source 1.5), this is how it looks:
    public void StringConcat(){
    int noOfIter = 10000;
    for(int i = 0; i < noOfIter; i++){
    String s = (new StringBuilder).append("String ").append( i).append( " Being ").append( i).append( "concatenated ").append( i).append( "using ").append( i).append( "String").append( i).append( "Builder").toString();
    The above was the compile time optimization I was talking about.What makes you think that the decompiler is not the problem?
    The ONLY difference between 1.5 and 1.4 in that case is that one uses StringBuilder and one uses StringBuffer. And StringBuffer is faster.
    Just wanted to know, are there any other differences in compile time optimizations between 1.4 and 1.5.I suggest that you go look at the read me. And I also suggest that you become familar with byte codes and stop assuming that a decompiler is going to tell you anything.

  • Some questions about Java deployment steps and techniques

    All my java experience is coding and testing in my local machine (where, of course, a jre is available), but ... when I deploy to other people, they may not have a jre or they may have a different version of it than the one needed to run my application. I've read different stuff online including jars and java web start but still I have many questions.
    (1) first one first, Sun contradicts common sense, when it says that i can redistribute my own customized light version of their jre by taking out some files (java.sun.com/j2se/1.5.0/jre/README). there are two ways for me to get a jre: Way one is by downloading one from Sun, the download comes as an *.exe file and I don't see how I can take files out of it, so do you know how?. Way two would be by simply copying the set of files i choose (according to that Readme) from my current jre installation (the one on my \java\jdk\jre directory), does this make sense?, (if you're under windows) doesn't an installed version of a jre need a couple of dlls plus some new registry entries?, this contradicts common sense, if I'm not wrong, that Readme is a nonsense, but since that readme is at each of us jre installation \java\jdk1.x\jre\Readme, it can't be a nonsense, therefore I'm wrong, therefore the answer is either Way 1 or Way 2, HOW? ... or maybe there's a Way 3?
    (2) Say I never read that Readme so I download the jre (as an exe) to bundle it along with my application in a jar ... now I'll give my neighbor either a jar with two exes or two exes jars ... is there a way to make a jar so that two files get executed? ... if the answer is No and I have competition from a second neighbor, then I believe I'm asking my first neighbor to choose my application based on our friendship, that's not reasonable if we are doing business, so Java loses.
    (3) Say that my application is a single executable file like this,
    class X{
    public static void main(String[]$$$){
    System.out.println("Console, where are you?");
    At this point, say that my neighbor accepted the two executables, he executed the jre.exe and has jre6 in his system, now he double clicks on my X.jar ... it's a console application and jar files are not associated with the java.exe launcher since java 5, but with javaw which doesn't open any console ... how do i make it so a console opens and prints "Console, where are you?" ... do I ask my neighbor-customer to add a couple of lines to his path and open his console and (please) enter java -jar jarfile.jar? ... isn't it too much? ... i hope i'm wrong cause this is kind of discouraging
    (4) I've read that by installing a more recent version of a jre on a system that has an older jre (there to help other applications work), I might be causing a problem for the other applications to run ... I guess that's the reason why that Readme kind of encourage to redistribute a "private" version of a jre (one that doesn't come with a java.exe launcher ... any feedback on this?
    (5) I'm reading a lot of hype about Java Web Start ... it looks better than the traditional jar/jre deployment ... but setting up a MIME type to *.jnlp, it doesn't come with some free hosting I've checked ... somebody can recommend a free hosting service that allows to set a *.jnlp MIME? (I'll appreciate a suggestion here, cause I would like to test Web Start)... and, anyhow, how you people compare it with the paradigm of the single executable file?.
    Thanks. Your feedback is highly appreciated.

    jorgelbanda wrote:
    ..(5) I'm reading a lot of hype about Java Web Start ... It's gratifying to think that someone who wants to deploy apps., has the common sense to search first! You would not guess how I often I hear "I wanna' make an EXE" shortly followed by "What's webstart?".
    ...it looks better than the traditional jar/jre deployment ... but setting up a MIME type to .jnlp, it doesn't come with some free hosting I've checked ... OK. You cannot define new mime types, but perhaps the site already has it defined. An easy way to check is to upload 'any old file' that ends in .jnlp and use the [mime type checker|http://pscode.org/mime/] to see what content type it is served as.
    ..somebody can recommend a free hosting service that allows to set a .jnlp MIME? (I'll appreciate a suggestion here, cause I would like to test Web Start)... I'm pretty sure the Google based sites offer it.
    Note that I edited the asterisks out of your post, to avoid the forum software parsing half the reply as bold.

  • Performance difference between java.beans.Expression and Java Reflection

    What is the Performance difference between using java.beans.Expression class and Java Reflection classes like Class,Method ??

    negligible

  • Differences in JCE policy files between java 1.4 and 1.5?

    I'm using a app that needs JCE unlimited strength policy files to start. Attempting to start with limited strength policy files with Java 1.4 installed will give:
    java.security.InvalidKeyException: InitVerify error: java.lang.RuntimeException: engineGetKeySize() is not supported by this cipher!
    however, running the same app on java 1.5 with limited strength policy files does not give this problem. I've checked http://java.sun.com/j2se/1.5.0/docs/guide/security/jce/JCERefGuide.html#AppE and http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html#AppE and the maximum allowed keysizes are identical. Has something else changed in the JCE policy files between these java versions? Can anyone tell me what's going on?

    Incubus wrote:
    say I have a code that does:
    public void StringConcat(){
    int noOfIter = 10000;
    for(int i = 0; i < noOfIter; i++){
    String s = "String " + i + " Being " + i + "concatenated " + i + "using " + i + "String" + i + "Builder";
    If I compile this in 1.4 ( i.e using javac -source 1.4); the decompiled code looks the same.
    But if I do so in 1.5 ( i.e if I decompile the same code compiled using javac -source 1.5), this is how it looks:
    public void StringConcat(){
    int noOfIter = 10000;
    for(int i = 0; i < noOfIter; i++){
    String s = (new StringBuilder).append("String ").append( i).append( " Being ").append( i).append( "concatenated ").append( i).append( "using ").append( i).append( "String").append( i).append( "Builder").toString();
    The above was the compile time optimization I was talking about.What makes you think that the decompiler is not the problem?
    The ONLY difference between 1.5 and 1.4 in that case is that one uses StringBuilder and one uses StringBuffer. And StringBuffer is faster.
    Just wanted to know, are there any other differences in compile time optimizations between 1.4 and 1.5.I suggest that you go look at the read me. And I also suggest that you become familar with byte codes and stop assuming that a decompiler is going to tell you anything.

  • Differences between Java Studio Creator and any other JSF IDE

    Hi Guys,
    I found that JSF code created when we use Studio Creator is Rave
    while as if we use Bea Workshop Studio/Any Other Eclipse IDE for JSF is MyFaces ( whatever it may be).
    What are the differences between these two? which one is better ?
    I get confused why there are two different framework of JSF?
    And I dont think there is any other IDE who supports Rave other than Java Studio Creator?
    Thx.

    Apologies for the late reply, but currently what exists generally for MyFaces integration with Creator is on this blog:
    http://wiki.java.net/bin/view/Javatools/CustomComponentLibraries
    You might also want to post the same question on the nbusers alias on netbeans.org, referencing Visual Web Pack
    Regards,
    -Brad Mayer

  • Differences between Java Web Start and HTML-Applets???

    Hi,
    I'm trying to get information about the differences between JWS-Applets and 'normal' HTML-embedded Applets.
    Is it possible to develop both simultaneously in one project???
    Is there a Programming-documentation that describes the differences between JWS and HTML-Applets???
    Thanx!
    Rembrand

    Check out the link shown below:
    http://java.sun.com/products/javawebstart/1.2/docs/developersguide.html
    All you need really is to create a JNLP file to launch your applet/application.
    ;o)
    V.V.

  • Difference between java page flow and java process definition

    I have joined a BEA WebLogic Integration project as an entry level BEA developer. I have a big question on the real difference between a jpf and a jpd. My co-workers say there is actually no difference, but I don't believe so. I think a jpd is more like a back-end process and it may or may not not need a View(MVC). While a jpf is the Controller(MVC) and is closely related to a web-based application where all the navigation logic(and only navigation logic) resides. A jpf normally should have a View(rendered on browser or other terminals) to present data from Model. I strongly believe this is true. But my project manager and my team lead, both are very technical guys, fiercely object to my understanding. I am extremely curious to have input from the BEA community on this fundamental concept.

    I find it hard to believe your team lead really believes there is no difference between a JPF and a JPD. There are numerous differences, both conceptually and technically.
    I believe your understanding of the differing roles of the two is correct. A JPF would represent the view of an application, and a JPD would represent callable services of an application, and server-side business logic.
    From the technical point of view, a JPF, assuming it avoided certain features, can be deployed on Tomcat. The core of it is a pure servlet application. A JPD is an EJB, either a SLSB or a SFSB.

  • Differences between Java 1.3 and 1.4

    Hi,
    I have a Java Applet which works fine with Java 1.4 but with Java 1.3 I get the following error:
    ava.lang.NoClassDefFoundError: javax/xml/parsers/DocumentBuilderFactory
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Can anybody help me?
    Thanks

    Hello,
    very simple: JAXP is part of the JRE only since 1.4 and is not included in 1.3. You can download JAXP at http://java.sun.com/webservices/jaxp/ and include the JARs in your classpath to get the XML functionality for Java 1.3.
    Nick.

  • Difference between Java 1.2 and Java1.4 Certification

    I am planning to take the Java programmer's certification soon but I am not sure whether I have to take Java 1.4 or Java 1.2. Please I need someone to explain.

    Take 1.4 or, even better, be the first to take 1.5 -:)

Maybe you are looking for