Swing setRolloverIcon/setWhateverIcon not working

I've got a test program here to see if various Icon states actually work in Swing.
Under windows, the only icon state that seems to work is setIcon()...
Anyone know what I am doing wrong?
Here is the code:
package unittest;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.ImageIcon;
public class MenuTest2
     extends JFrame
     public MenuTest2 () {
          addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
               System.exit(0);
          JMenuBar menuBar = new JMenuBar();
          JMenu menu = new JMenu("A Menu");
          menuBar.add(menu);
          JMenuItem menuItem = new JMenuItem("A text-only menu item");
          menuItem.setIcon(new ImageIcon("test.gif"));
          menuItem.setRolloverIcon(new ImageIcon("test1.gif"));
          menuItem.setPressedIcon(new ImageIcon("test1.gif"));
          menu.add(menuItem);
          setJMenuBar(menuBar);
     public static void main(String[] args) {
MenuTest2 window = new MenuTest2();
window.setTitle("MenuTest");
     window.setSize(300, 200);
          window.setVisible(true);
}

cont = new JButton(new ImageIcon("normal.gif"));
cont.setPressedIcon(new ImageIcon("pressed.gif"));
cont.setRolloverIcon(new ImageIcon("roll.gif"));
cont.setFocusPainted(false);
cont.setBorderPainted(false);
cont.setContentAreaFilled(false);
cont.setMargin(new Insets(0,0,0,0));
this works
guaranteed :)

Similar Messages

  • Swing applet does not work in IE using java plugin

    I am using applet-servlet communication in my Applet and also using java plugin 1.3 to open that applet in browser.It is working fine in Netscape 4.7 but not in IE 5.0.
    Problem is It could not get any data from the database.
    If you have any solutions it will be appriciated.
    thanks

    did you find your problem with the IE 6.0
    Java problem.Java(TM) Plug-in: Version 1.4.2_01
    Using JRE version 1.4.2_01 Java HotSpot(TM) Client VM
    I have something simular and was looking for a fix.
    .yavs: Yet Another Vertical Scroller, version 1.2
    (c) 1998 Steve Bassler http://www.westol.com/~bassmstr
    yavs: Yet Another Vertical Scroller, version 1.2
    (c) 1998 Steve Bassler http://www.westol.com/~bassmstr
    yavs: Yet Another Vertical Scroller, version 1.2
    (c) 1998 Steve Bassler http://www.westol.com/~bassmstr
    load: class xms.EntryApplet.class not found.
    java.lang.ClassNotFoundException: xms.EntryApplet.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(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)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more

  • JNLP - Swing application compiled in jdk1.5 not working in jdk1.6

    I have one swing application, compiled in jdk 1.5 and deployed in JNLP with jdk 1.5. When client machine try to access the application and having jre 1.5 then it works fine. but if client machine having jre 1.6 or version greater than 1.5 then application does not work properly.
    Please help me, i got stuck and not able to solve the problem.
    this is my JNLP
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://10.1.1.145:8080/uttimesheet" href="launch.jnlp">
    <information>
    <title>TimeSheet Portal</title>
    <vendor>Geometric Global</vendor>
    <description>A simple java desktop application based on Swing Application Framework</description>
    <description kind="short">TimeSheet Portal</description>
    <homepage href="http://appframework.dev.java.net"/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+" />
    <jar href="UTTimeSheet.jar" main="true" download="eager"/>
    <jar href="lib/antlr-2.7.5H3.jar" download="eager"/>
    <jar href="lib/appframework-1.0.3.jar" download="eager"/>
    <jar href="lib/asm.jar" download="eager"/>
    <jar href="lib/cglib-2.1.jar" download="eager"/>
    <jar href="lib/commons-collections-2.1.1.jar" download="eager"/>
    <jar href="lib/commons-logging-1.0.4.jar" download="eager"/>
    <jar href="lib/dom4j-1.6.jar" download="eager"/>
    <jar href="lib/hibernate3.jar" download="eager"/>
    <jar href="lib/jta.jar" download="eager"/>
    <jar href="lib/log4j-1.2.9.jar" download="eager"/>
    <jar href="lib/poi-3.0.2.jar" download="eager"/>
    <jar href="lib/postgresql-8.3-603.jdbc3.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    <jar href="lib/swing-worker-1.1.jar" download="eager"/>
    <jar href="lib/swingx-0.9.2.jar" download="eager"/>
    </resources>
    <application-desc main-class="timesheetproject.TimeSheetProjectApp">
    </application-desc>
    </jnlp>
    Thanks in Advance.

    Thanks Luca for your time,
    we have deployed application in tomcat and changed the home page of tomcat to our application home page(html page). and url is http://10.1.1.145:8080/
    Application home page contain link to jnlp. so whenever user click on link (in home page) then jnlp will execute and launch the swing application.
    do you need some more clarification?
    below is the home page(html).
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Launch TimeSheet Portal via JNLP</title>
    </head>
    <body>
         <center>
              <br>
              <img src="images/Geo-logo.JPG" />          
              <br>
              <hr width="70%" />
              <br>
              <table width="70%">
                   <tr><td> </td></tr>
                   <tr>
                        <td colspan="2" align="center">
                             <align="center">
                                  <h2>Welcome to TimeSheet Portal.</h3>
                             </align>
                        </td>
                   </tr>
                   <tr><td> </td></tr>
                   <tr><td> </td></tr>
                   <tr>
                        <td align="center">
                             <align="center">
                                  <h3><u>Live Sites:</u></h3>
                             </align>
                        </td>
                        <td align="center">
                             <align="center">
                                  <h3><u>Demo Sites:</u></h3>
                             </align>
                        </td>
                   </tr>
                   <tr>
                        <td width="50%" align="center">
                             <img src="images/launchPortal.png" onmouseover="this.src='images/launchPortalMouseOver.png';" onmouseout="this.src='images/launchPortal.png';" border="0"/>          
                             <br><br>
                             <img src="images/launchAdminPortal.png" onmouseover="this.src='images/launchAdminPortalMouseOver.png';" onmouseout="this.src='images/launchAdminPortal.png';" border="0"/>          
                        </td>
                        <td width="50%" align="center">
                             <img src="images/demoPortal.png" onmouseover="this.src='images/demoPortalMouseOver.png';" onmouseout="this.src='images/demoPortal.png';" border="0"/>
                             <br><br>
                             <img src="images/demoAdminPortal.png" onmouseover="this.src='images/demoAdminPortalMouseOver.png';" onmouseout="this.src='images/demoAdminPortal.png';" border="0"/>
                        </td>
                   </tr>
                   <tr><td> </td></tr>
                   <tr><td> </td></tr>
         </table>
         <table width="70%">
              <tr><td> </td></tr>
              <tr><td> </td></tr>
              <tr><td align="center">
                   FAQ   |  
                   Help   |  
                   Why Timesheet   |  
                   Report a bug   |  
                   Contact Us   |  
    Subtask Mapping   
              </td></tr>
         </table>
         <br><br><br><br>
         <table width="70%" bgcolor="#C0C0C0" style="vertical-align: bottom">
              <tr>
                   <td colspan="2" align="center" style="vertical-align: bottom" bgcolor="#C0C0C0">
                        ©<font size="1.5" face="Verdana"> 2008 Geometric Ltd. All rights reserved.<br>
                             Best optimized for a resolution of 1024 and above. JRE 1.5 is a pre-requisite                          for using these applications.
                        </font>
                   </td>
              </tr>
         </table>
         </center>
    </body>
    </html>
    Thanks.

  • Swing components in applet not working in web browser

    Hi Guys,
    I've created an applet which makes use of some swing components, but unfortunately, not all of them function properly in my web browser (internet explorer or Mozilla Firefox). Its mainly the buttons; the last buttons works and displays the correct file within the broswer, but the first 5 buttons do not work...
    any help please on how I can sort this problem out?
    Heres the code for my applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.*;
    public class MainAppWindow extends JApplet
    int gapBetweenButtons = 5;
    final JPanel displayPanel = new JPanel(new BorderLayout());
    public void init()
       //Panel for overall display in applet window.
       JPanel mainPanel = new JPanel(new BorderLayout());
       mainPanel.add(new JLabel(new ImageIcon(getClass().getResource("images/smalllogo2.gif"))),BorderLayout.NORTH);
       //sub mainPanel which holds all mainPanels together.
       JPanel holdingPanel = new JPanel(new BorderLayout());
       //Panel for displaying all slide show and applications in.
       displayPanel.setBackground(Color.white);
       displayPanel.add(new JLabel(new ImageIcon(getClass().getResource("images/IntroPage.jpg"))),BorderLayout.CENTER);
       displayPanel.setPreferredSize(new Dimension(590,400));
       JPanel buttonPanel = new JPanel(new GridLayout(6,1,0,gapBetweenButtons));
       buttonPanel.setBackground(Color.white);
       JButton button1 = new JButton("User guide");
       button1.addActionListener(
         new ActionListener() {
              public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll(); // If there are any components in the mainPanel, remove them and then add label
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/UserGuide.jpg")));
                   displayPanel.revalidate(); // Validates displayPanel to allow changes to occur onto it, allowing to add different number images/applicaions to it.
       JButton button2 = new JButton("What is a Stack?");
       button2.addActionListener(
       new ActionListener() {
               public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/WhatIsAStack.jpg")));
                   displayPanel.revalidate();
       JButton button3 = new JButton("STACK(ADT)");
       button3.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/StackADT.jpg")));
                   displayPanel.revalidate();
       JButton button4 = new JButton("Stacks in the Real World");
       button4.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/StacksInTheRealWorld.jpg")));
                   displayPanel.revalidate();
       JButton button5 = new JButton("DEMONSTRATION");
       button5.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                 if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                 Demonstration app = new Demonstration();
                 JPanel appPanel = app.createComponents();//gets the created components from Demonstration application.
                 appPanel.setBackground(Color.pink);
               displayPanel.add(appPanel);
               displayPanel.revalidate();
       JButton button6 = new JButton("Towers Of Hanoi");
       button6.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                     if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                     TowerOfHanoi app = new TowerOfHanoi();
                     JPanel appPanel = app.createComponents();//gets the created components from Towers of Hanoi
                     JPanel mainPanel = new JPanel();//panel used to centralise the application in center
                     mainPanel.add(appPanel);
                     mainPanel.setBackground(Color.pink); //sets mainPanel's background color for 'Towers Of Hanoi'
                     displayPanel.add(mainPanel);
                     displayPanel.revalidate();
       //adding buttons to the buttonPanel.
       buttonPanel.add(button1);
       buttonPanel.add(button2);
       buttonPanel.add(button3);
       buttonPanel.add(button4);
       buttonPanel.add(button5);
       buttonPanel.add(button6);
       JPanel p = new JPanel(); // Used so that the buttons maintain their default shape
       p.setBackground(Color.white);
       p.add(buttonPanel);
       holdingPanel.add(p,BorderLayout.WEST);
       holdingPanel.add(displayPanel,BorderLayout.CENTER);
       //Positioning of holdingPanel in mainPanel.
       mainPanel.add(holdingPanel,BorderLayout.CENTER);
       //indent mainPanel so that its not touching the applet window frame.
       mainPanel.setBorder(BorderFactory.createEmptyBorder(10,20,10,20));
       mainPanel.setBackground(Color.white);
       mainPanel.setPreferredSize(new Dimension(850,600)); //size of applet window
       mainPanel.setOpaque(false); // Needed for Applet
       this.setContentPane(mainPanel);
    }

    Thanks for the response. I don't quite understand what you're talking about though. I have, in my humble knowledge, done nothing with packages. I have put the applet class (WiaRekenToolActiz.class is the applet class) in the jar file wia_actiz_archive.jar. From what I read on the tutorial, java looks for the applet class in all the jar files specified. Since I put my CODEBASE as the main url, I thought it baiscally didn't matter where you out the html file.
    I shall include the complete html page complete with applet tag to perhaps illuminate a bit more what I mean...
    <html>
    <head>
    <title>Wia Rekenmodule hello!</title>
    </head>
    <body bgcolor="#C0C0C0">
    <applet
    CODEBASE= "http://www.creativemathsolutions.nl/test"
    ARCHIVE= "Actiz/wia_actiz_archive.jar, Generic/wia_archive.jar"
    CODE="WiaRekenToolActiz.class" 
    WIDTH=915 HEIGHT=555
    >
    <PARAM NAME = naam VALUE = "Piet Janssen">
    <PARAM NAME = gebdag VALUE = "01">
    <PARAM NAME = gebmaand VALUE = "06">
    <PARAM NAME = gebjaar VALUE = "1970">
    <PARAM NAME = geslacht VALUE = "man">
    <PARAM NAME = dienstjaren VALUE = "10">
    <PARAM NAME = salaris VALUE = "56500">
    <PARAM NAME = deeltijdpercentage VALUE = "100">
    <PARAM NAME = accountnaam VALUE = "Zorginstelling 'De Zonnebloem'">
    </applet>
    </body>
    </html>

  • Dj native swing work in 10.8 but not work on 10.7.5

    hallo..
    this a problem..
    first i build java program on eclipse use swt-3.8M5-cocoa-macosx-x86
    in mac 10.8.. it's work fine..
    but when i try to run in 10.7.5 this not working..
    and i build again in 10.7.5 it's work fine..
    how can i handle this problem...
    the message error show
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/eclipse/swt/SWT
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.initialize_(SWTNativeInt erface.java:208)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.initialize(NativeInterface.java: 71)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface .java:332)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
    it's the path problem or something else???
    thanks...

    The last Java update disabled Java plug-in and removed Java Preferences.app from your Utilities folder. This is because Apple is no longer supporting Java, if you need it follow these instructions...
    You can re-enable Java 6 by following this support article
    http://support.apple.com/kb/HT5559
    Or, you can update to Oracle's Java 7 here
    http://www.java.com/en/download/mac_download.jsp?locale=en

  • Not sure why line break is not working

    Hi all,
    Here is part of my simple Swing application:
    String text1 = "hello";
    String text2 = "world";
    String text3 = text1+"\n"+text2;
    // have also tried (String text3 = text1+"\n\r"+text2;)
    displayField.setText(text3);I supposed that the text3 in the label field (displayField) would display like this:
    hello
    world
    But not, the text3 just displayed in the same line like this instead: helloworld.
    I am not sure why the line break is not working.

    Use HTML for a multiline JLabel.// String text3 = text1+"\n"+text2;
    String text3 = "<html>" + text1 + "<br/>" + text2 + "</html>";db

  • Button not working in browser

    I am coding a video player in Netbeans 6.8. just find two problems:
    1. the browser button not working in browser when I run the project from Netbeans under "run in browser" mode. however under "standard execution" mode, everything is fine.
    2. can not run the jar file in the project's dist directory directly. in other word, I can not run the jar file outside of Netbeans.
    I appreciate any help. thanks.
    Main.fx:
    package gui;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.paint.Color.*;
    * @author Jethro
    var face=Face{};
    function run(){
        Stage{
            title: "player"
            resizable:false
            scene: Scene{
                width:800
                height:600
                fill:DARKBLUE
                content: [face]
    }Face.fx:
    package gui;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.control.Button;
    import javafx.scene.layout.VBox;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.MediaError;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.media.MediaView;
    import javafx.scene.control.ProgressBar;
    * @author Jethro
    public class Face extends CustomNode {
        public var lbf=LBF{};
        public var enable=true;
        public var mark="play";
        public var sourceOfMedia:String;
        public def player=MediaPlayer {
            repeatCount:MediaPlayer.REPEAT_FOREVER
            onError:function(e:MediaError){
                var er=e.message;
         media : bind Media {
              source: sourceOfMedia
        public def view=MediaView {
                mediaPlayer:bind player
                preserveRatio: true                    
        public def bar=ProgressBar {
                height:10
                width:bind scene.width
                progress: bind
                    if(player.media !=null){
                        player.currentTime.toMillis()
                            /player.media.duration.toMillis();
                    }else{
                        0.0
        public var play=Button {      
            onMousePressed:function(e:MouseEvent){
                if(enable and player.media != null){
                            mark="pause"; println("playing...");                       
                            sourceOfMedia=lbf.uri;
                            player.play();
                            enable=false;
                }else{
                    mark="play";
                    player.pause();println("paused...");
                    enable=true;
         text: bind mark       
        public override function create(): Node {
            return Group {
                content: [
                    VBox{
                        content: [
                            lbf,
                            bar,
                            play,
                            view,
    }LBF.fx:
    package gui;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.control.TextBox;
    import javafx.scene.layout.HBox;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.scene.Node;
    import javafx.geometry.HPos;
    import javafx.geometry.VPos;
    import javafx.scene.control.Button;
    import javax.swing.JFileChooser;
    * @author Jethro
    public class LBF extends CustomNode{
        public var uri:String;
        public var whereis=Text {
            fill:Color.BLUE
         font : Font {
              size: 20
         x: 10, y: 30
         content: "location: "
        public var location=TextBox{
            text:"the song's location"
            columns:40
            selectOnFocus:true
        public var browser=Button {
         text: "Browser"
         action: function() {
                    var jfc=new JFileChooser();               
              jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                    var val = jfc.showOpenDialog(null);
                    if(val == JFileChooser.APPROVE_OPTION) {                   
                        location.text = jfc.getSelectedFile().getAbsolutePath();
                        uri=jfc.getSelectedFile().toURI().toString();
                        println(location.text);
        public var face=Group {
         content: [
              Rectangle {
                        x: 0, y: 0
                        width: 800, height: 50
                        fill: Color.SILVER
                     HBox{
                         width:800
                         height:50
                         hpos:HPos.CENTER
                         vpos:VPos.CENTER
                         spacing:5
                         content: [whereis,location,browser]
        public override function create():Node{
            return face;
    }

    thanks for your reply but I need more specific operation.
    maybe I am not very clear about the problem one. I mean when I run the code in standard mode, if I click the browse button, a window will pop out and I can choose a video file from my local harddisk. but if I run it in "web start execution" mode and "run in browser" mode. the browse button make no response when I click it.
    Edited by: Phoenix2006 on Feb 8, 2010 2:35 PM
    Edited by: Phoenix2006 on Feb 8, 2010 2:37 PM
    Edited by: Phoenix2006 on Feb 8, 2010 2:42 PM

  • Why keyboard and mouse right click not working in Solaris and Linux?

    Hi all,
    I have two problems:
    1) I am working on AWT/Swing application and its working fine in window enviornment,but while running on solaris and linux mouse right-click option window not poping up.
    2) Ctrl+c,Ctrl+v,Home and End keyboard key are not working in solaris and linux OS for same application.
    Pls provide me some solution for these problem.
    -Dinesh

    Hi Nik,
    Thanks for reply. I found some solution for the above problem.
    For mouse right click there was problem in my source code.I have not implemented the mousePressed() method
    In case of keyboard Home, End and arrow key working fine after exporting AWTUSE_TYPE4_PATCH=false; in solaris and linux
    But still Ctrl-c and Ctrl-v not working.
    I am using JDK1.5.0_07+Eclipse IDE 3.1
    -Dinesh

  • I did write a simple java program but it is not working please help me.....

    This is the program I wrote LineRect just to draw a line a rectangle etc...... Y it is not working How can i used the same program to run without using applet that is by using awt and swing.........Pls Help me.............
    import java.awt.*;
    import java.io.*;
    public class LineRect
    {public void paint(Graphics g)
         {g.drawLine(10,10, 50,50);
         g.drawRect(10, 60, 40,30);
         g.fillRect(60,10,30,80);
         g.drawRoundRect(10,100,80,50,10,10);
         g.fillRoundRect(20,110,60,30,5,5);
         g.drawLine(100,10,230,140);
         g.drawLine(100,140,230,10);
    <APPLET
    CODE =LineRect.class
    WIDTH=250
    HEIGHT=200>
    </APPLET>

    There are many significant errors here for instance you are using a class file as if it were an applet yet you do not subclass applet. Your code has no init method (if it is to be an applet). Your best bet is to go through the tutorials one step at a time. One thing to consider is to subclass a JPanel and draw on the jpanel overriding the paintComponent method. This can then be added to a JFrame or a JApplet's contentPane and would allow the same graphics in both. But again, please study the tutorials on all of this, otherwise you will be doing hit-or-miss programming, and that is no way to learn.
    Much luck!
    Addendum: Also, if you are just beginning in Java programming, I suggest you start with the basics and not with Swing / AWT / graphics programming. Otherwise you will just end up bruised and disappointed. You have to learn to walk before you can run.
    Edited by: Encephalopathic on Dec 26, 2007 5:09 AM

  • SetUncaughtExceptionHandler() not working

    Hi there,
    using java 1.5... and using setDefaultUncaughtExcepion!handler() and setUncaughtExceptionHandler() to trap all uncaught exception in my (big) program. I'm observing that my 2 handlers are correctly called when a uncaught exception happens... in most cases !!!!
    I have one specific example where the handler is not called when the exception occurs. I checked carefully the properties on the thread and threadgroup to ensure all is correclty set... and everything sounds ok:
    here the part where the code is throwing an exception (volunteer in this case); this is executed in the EDT (when the user press a "submit" button):
       public void submit() {
            CUtils.trace(LOG_PRIORITY_INFO, LOG_PANEL, LOG_PANELCREATETESTCASE_LABEL, "submit pressed");      
            String testcaseIndex = createTestcaseForm.getFormItemValue(0);
            System.out.println(" **************** " + Thread.currentThread().getName());
            System.out.println(" **************** " + Thread.currentThread().getId());
            System.out.println(" **************** " + Thread.currentThread().getUncaughtExceptionHandler().toString());
            int toto = Integer.parseInt("p");
            System.out.println(" toto = " + toto);With this code and a handler that displays a JDialog containing the stacktrace etc... I'm getting the following traces:
        [main           ] [AWT-EventQueue-0#13] [CDefaultExceptionHandler] [form          ]  form constructed
        [main           ] [AWT-EventQueue-0#13] [CDefaultExceptionHandler] [form          ]  form contains 3 items
        [main           ] [AWT-EventQueue-0#13] [CDefaultExceptionHandler] [panel         ]  getting core...
    Exception occurred during event dispatching:
    java.lang.NumberFormatException: For input string: "p"
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:447)
         at java.lang.Integer.parseInt(Integer.java:497)
         at com.xqual.xstudio.gui.module.editing.create.CPanel_CreateTestcase.submit(CPanel_CreateTestcase.java:110)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
        [main           ] [AWT-EventQueue-0#13] [CDefaultExceptionHandler] [controlbar    ]  actionPerformed(javax.swing.JButton[,163,5,85x25,alignmentX=0.0,alignmentY=0.5,border=com.sun.java.swing.plaf.windows.XPStyle$XPEmptyBorder@19977bd,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.ImageIcon@842d9a,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Submit,defaultCapable=true])
        [main           ] [AWT-EventQueue-0#13] [CDefaultExceptionHandler] [panel crt case]  submit pressed
    **************** AWT-EventQueue-0
    **************** 13
    **************** com.xqual.xstudio.gui.CMain$CDefaultExceptionHandler@1c20611The handler's uncaughtException() method is not called at all !
    Additional point#1: the handler works well in all the other cases (main thread, EDT events etc...) just this case is not working
    Additional point#2: I used setDefaultUncaughtExceptionHandler() (used for all classes) but it sounds I needed to use a setUncaughtExceptionHandler() on the EDT to have it working for awt.
    any ideas ? or someone got the same problem ?
    Cheers,
    Eg\\

    Hi there,
    using java 1.5... and using
    setDefaultUncaughtExcepion!handler() and
    setUncaughtExceptionHandler() to trap
    all uncaught exception in my (big) program. I'm
    observing that my 2 handlers are correctly called
    when a uncaught exception happens... in most cases
    I have one specific example where the handler is not
    called when the exception occurs. I checked carefully
    the properties on the thread and threadgroup to
    ensure all is correclty set... and everything sounds
    ok:
    here the part where the code is throwing an exception
    (volunteer in this case); this is executed in the EDT
    (when the user press a "submit" button):
       public void submit() {
    CUtils.trace(LOG_PRIORITY_INFO, LOG_PANEL,
    G_PANEL, LOG_PANELCREATETESTCASE_LABEL, "submit
    pressed");      
    String testcaseIndex =
    eIndex = createTestcaseForm.getFormItemValue(0);
    System.out.println(" **************** " +
    **** " + Thread.currentThread().getName());
    System.out.println(" **************** " +
    **** " + Thread.currentThread().getId());
    System.out.println(" **************** " +
    **** " +
    Thread.currentThread().getUncaughtExceptionHandler().t
    oString());
    int toto = Integer.parseInt("p"); //NOT "p" USE "123" or any integer number
    System.out.println(" toto = " +
    to = " + toto);With this code and a handler that displays a JDialog
    containing the stacktrace etc... I'm getting the
    following traces:
        [main           ] [AWT-EventQueue-0#13]
    [CDefaultExceptionHandler] [form          ]  form
    constructed
    [main           ] [AWT-EventQueue-0#13]
    #13] [CDefaultExceptionHandler] [form          ]
    form contains 3 items
    [main           ] [AWT-EventQueue-0#13]
    #13] [CDefaultExceptionHandler] [panel         ]
    getting core...
    Exception occurred during event dispatching:
    java.lang.NumberFormatException: For input string:
    "p"
    at
    t
    java.lang.NumberFormatException.forInputString(NumberF
    ormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:447)
         at java.lang.Integer.parseInt(Integer.java:497)
    at
    t
    com.xqual.xstudio.gui.module.editing.create.CPanel_Cre
    ateTestcase.submit(CPanel_CreateTestcase.java:110)
    at
    t
    java.awt.EventDispatchThread.pumpEvents(EventDispatchT
    hread.java:157)
    at
    t
    java.awt.EventDispatchThread.pumpEvents(EventDispatchT
    hread.java:149)
    at
    t
    java.awt.EventDispatchThread.run(EventDispatchThread.j
    ava:110)
    [main           ] [AWT-EventQueue-0#13]
    #13] [CDefaultExceptionHandler] [controlbar    ]
    actionPerformed(javax.swing.JButton[,163,5,85x25,alig
    nmentX=0.0,alignmentY=0.5,border=com.sun.java.swing.pl
    af.windows.XPStyle$XPEmptyBorder@19977bd,flags=296,max
    imumSize=,minimumSize=,preferredSize=,defaultIcon=java
    x.swing.ImageIcon@842d9a,disabledIcon=,disabledSelecte
    dIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,
    left=14,bottom=2,right=14],paintBorder=true,paintFocus
    =true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,
    rolloverSelectedIcon=,selectedIcon=,text=Submit,defaul
    tCapable=true])
    [main           ] [AWT-EventQueue-0#13]
    #13] [CDefaultExceptionHandler] [panel crt case]
    submit pressed
    **************** AWT-EventQueue-0
    **************** 13
    com.xqual.xstudio.gui.CMain$CDefaultExceptionHandler@1
    c20611The handler's uncaughtException() method
    is not called at all !
    Additional point#1: the handler works well in
    all the other cases (main thread, EDT events etc...)
    just this case is not working
    Additional point#2: I used
    setDefaultUncaughtExceptionHandler()(used for all classes) but it sounds I needed to use
    a setUncaughtExceptionHandler() on the
    EDT to have it working for awt.
    any ideas ? or someone got the same problem ?
    Cheers,
    Eg\\May be you need more array index than you decleare.

  • Command button not working

    Hi,
    I have a
    <h:panelGrid><td><h:commandButton id="aButton" value="Add" action="#{hubreceivingbean.createRecord}" /></td></h:panelGrid> this is not working, I'm not sure what wrong I'm doing, my code is
    ============ hubReceiving.jsp=======================
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <tiles:importAttribute scope="request"/>
    <f:view>
    <f:loadBundle basename="com.fcpa.him.columnheading" var="chdr"/>
    <f:loadBundle basename="com.fcpa.him.Messages" var="msg"/>
    <div id="location"></div>
    <div class="bfrm" style="width: 720px;" >
    <div style="height: 600px" class="cv_c">
    <h:form id="rcvTxn">
    <h:panelGroup>
    <h:panelGrid columns="1">
    <h:panelGrid>
    <h:dataTable >
    <h:column>
    <f:facet name="header">
    <td> <h:outputFormat style="width: 730px;" value="Receiving"/></td>
    </f:facet>
    </h:column>
    </h:dataTable>
    </h:panelGrid>
    <h:panelGrid columns="3">
    <h:panelGrid columns="5" style="width: 560px">
    <h:column>
    <h:panelGrid><td><h:outputText id="errorMessage" value="#{hubreceivingbean.errorMessage}" style="color: red; font-weight: bold;" /></td></h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText id="hRcvDate" value="Receiving Date:" style="width: 90px" /></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hHubName" value="Receiving At:" style="width: 90px" /></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hPackageType" value="Package Type:" style="width: 90px" /></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hPackageValue" value="Scan / Enter:" style="width: 90px" /></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText id="vRcvDate" value="#{hubreceivingbean.date}" style="width: 130px"/></td></h:panelGrid>
    <h:panelGrid><td><h:selectOneMenu id="vHubName" value="#{hubreceivingbean.hubName}" style="width: 130px">
    <f:selectItems value="#{hubreceivingbean.hubList}"/>
    </h:selectOneMenu></td></h:panelGrid>
    <h:panelGrid><td><h:selectOneMenu id="vPackageType" value="#{hubreceivingbean.sourceType}" style="width: 130px" onchange="submit()" >
    <f:selectItems value="#{hubreceivingbean.sourceTypeList}" />
    </h:selectOneMenu></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vPackageValue" value="#{hubreceivingbean.sourceValue}" style="width: 130px" /></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText style="width: 80px"/></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hTxnNum" value="Txn ID:" style="width: 80px"/></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hPartNumber" value="Part Number:" style="width: 80px; #{hubreceivingbean.componetEnableDisableStyle};"/></td></h:panelGrid>
    <h:panelGrid><td><h:outputText id="hQty" value="Quantity:" style="width: 80px; #{hubreceivingbean.componetEnableDisableStyle};"/></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    <h:column>
    <h:panelGrid>
    <h:panelGrid><td><h:outputText style="width: 130px" /></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vTxnNum" value="#{hubreceivingbean.rcvTxnHeaderID}" style="width: 130px" /></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vPartNum" value="#{hubreceivingbean.partNumber}" style="width: 130px; #{hubreceivingbean.componetEnableDisableStyle};" /></td></h:panelGrid>
    <h:panelGrid><td><h:inputText id="vQty" value="#{hubreceivingbean.quantity}" style="width: 130px; #{hubreceivingbean.componetEnableDisableStyle};" /></td></h:panelGrid>
    </h:panelGrid>
    </h:column>
    </h:panelGrid>
    <h:panelGrid>
    <f:subview id="rtMenu">
    <tiles:insert definition="mainMenu" flush="false"/>
    </f:subview>
    </h:panelGrid>
    </h:panelGrid>
    <h:panelGrid><td><h:commandButton id="aButton" value="Add" action="#{hubreceivingbean.createRecord}" /></td></h:panelGrid>
    <h:panelGrid>
    <h:dataTable styleClass="standard">
    <h:column >
    <f:facet name="header">
    <td> <h:outputFormat style="width: 70px; " value="#{chdr.rcvRefType}"/></td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 80px;" value="#{chdr.rcvRefTypeValue}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 80px;" value="#{chdr.palletNumber}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 175px;" value="#{chdr.partNumber}"/></td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 75px;" value="#{chdr.asnQty}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 75px;" value="#{chdr.rcvQty}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 100px;" value="#{chdr.remarks}"/> </td>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <td> <h:outputText style="width: 50px;" value="#{chdr.delete}"/> </td>
    </f:facet>
    </h:column>
    </h:dataTable>
    </h:panelGrid>
    <h:panelGrid styleClass="scrollPane" columns="1" style="width: 720px;">
    <h:panelGroup>
    <f:verbatim><DIV STYLE="overflow: auto; height: 170px;" styleClass="standard"></f:verbatim>
    <h:dataTable value="#{hubreceivingbean.rcvDataArray}" var="databean" styleClass="standard">
    <h:column>
    <h:outputText style="width: 70px;" value="#{databean.referenceType}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 80px;" value="#{databean.referenceValue}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 80px;" value="#{databean.palletNumber}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 175px;" value="#{databean.partNumber}"/>
    </h:column>
    <h:column>
    <h:outputText style="width: 75px;" value="#{databean.asnQuantity}" />
    </h:column>
    <h:column>
    <h:inputText id="rcvQty" style="width: 75px;" value="#{databean.rcvQuantity}" required="true"/>
    <h:message for="rcvQty" errorClass="errors" />
    <f:attribute name="rcvQty" value="Please Enter" />
    </h:column>
    <h:column>
    <h:inputText style="width: 100px;" value="#{databean.rcvComments}" />
    </h:column>
    </h:dataTable>
    <f:verbatim></DIV></f:verbatim>
    </h:panelGroup>
    </h:panelGrid>
    </h:panelGrid>
    </h:panelGroup>
    </h:form>
    </div>
    </div>
    </f:view>
    ====================HubReceivingBean.java=================
    * HubReceivingBean.java
    * Created on February 1, 2006, 6:09 PM
    * To change this template, choose Tools | Options and locate the template under
    * the Source Creation and Management node. Right-click the template and choose
    * Open. You can then make changes to the template in the Source Editor.
    package com.fcpa.him;
    * @author vburla
    import java.sql.*;
    import java.util.*;
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import javax.faces.model.SelectItem;
    import javax.faces.application.*;
    import javax.faces.context.FacesContext;
    import java.util.Locale;
    import javax.servlet.jsp.jstl.sql.ResultSupport;
    import javax.servlet.jsp.jstl.sql.Result;
    import javax.faces.component.UIComponent;
    import javax.faces.component.UIComponentBase;
    import javax.faces.component.UIInput;
    import javax.faces.component.UIViewRoot;
    import javax.faces.validator.*;
    import javax.faces.el.ValueBinding;
    import java.io.Serializable;
    import javax.swing.JOptionPane;
    import java.net.*;
    import com.fcpa.reportal.*;
    import com.fcpa.eapps.*;
    public class HubReceivingBean {
    private String sourceType;
    private String sourceValue;
    private String rcvTxnHeaderID;
    private Date date = new Date();
    private static ArrayList sourceList;
    private static ArrayList hubList;
    private SysLogger log;
    private JDBCConnPool db;
    private String hubName;
    private boolean hubNameEditable =true;
    private ArrayList rcvDataArray = new ArrayList();
    private String componetEnableDisableStyle = "display:none";
    private String txnRefEnableDisable = "display:none";
    private String partNumber;
    private String quantity;
    private String useDataSource = "Y";
    private String errorMessage;
    //private static final String[] SOURCE_TYPE = { "CARTON", "PALLET", "INVOICE","IO"};
    //private static final String[] COLUMN_NAMES = {"Ref_Type","Ref_Value","Part_Number","ASN_Qty","RCV_Qty","Notes"};
    /**Create connection */
    public void setJdbcConnPoolClass(JDBCConnPool j) {
    this.db = j;
    public JDBCConnPool getJdbcConnPoolClass() {
    return this.db;
    public void setSysLoggerClass(SysLogger s) {
    this.log = s;
    public SysLogger getSysLoggerClass() {
    return this.log;
    /** Creates a new instance of HubReceivingBean */
    public HubReceivingBean(){
    private void fillRcvDataArray() throws Exception{
    if ( (getRcvTxnHeaderID()!="") && (getRcvTxnHeaderID()!=null) ){
    String strSQLstr = "SELECT lines.txn_line_id Txn_Line_ID, lines.reference_type Ref_Type,lines.reference_value Ref_Value,"+
    " lines.pallet_number Pallet_Number, lines.part_number Part_Number,lines.asn_quantity ASN_Qty,"+
    " lines.received_quantity RCV_Qty,lines.comments Notes "+
    " FROM hif_rcv_txn_headers headers, hif_rcv_txn_lines lines "+
    " WHERE headers.txn_header_id = lines.txn_header_id "+
    " AND headers.txn_header_id = "+getRcvTxnHeaderID()+
    " AND nvl(headers.txn_complete_flag,'N') = 'N' "+
    " ORDER BY lines.txn_line_id desc";
    System.out.println("Inside fill data-strSQLstr: "+strSQLstr);
    ResultSet rs = db.getResultSet(strSQLstr);
    while (rs.next()){
    RcvTableDataBean bean = new RcvTableDataBean();
    bean.setTxnLineID(rs.getString("Txn_Line_ID"));
    bean.setReferenceType(rs.getString("Ref_Type"));
    bean.setReferenceValue(rs.getString("Ref_Value"));
    bean.setPalletNumber(rs.getString("Pallet_Number"));
    bean.setPartNumber(rs.getString("Part_Number"));
    bean.setAsnQuantity(rs.getString("ASN_Qty"));
    bean.setRcvQuantity(rs.getString("RCV_Qty"));
    bean.setRcvComments(rs.getString("Notes"));
    rcvDataArray.add(bean);
    public ArrayList getRcvDataArray()throws Exception {
    rcvDataArray.clear();
    fillRcvDataArray();
    return rcvDataArray;
    // PROPERTY: current date
    public void setDate(Date newValue) { date = newValue; }
    public String getDate() {
    Date now = new Date();
    DateFormat df = DateFormat.getDateInstance();
    String s = df.format(now);
    System.out.println("Today is " + s);
    return s;
    // PROPERTY: Hub Name
    public void setHubName(String newValue) {
    // System.out.println("Inside setSourceType");
    hubName = newValue; }
    public String getHubName() {
    //System.out.println("Inside getSourceType");
    return hubName; }
    // PROPERTY: source type
    public void setSourceType(String newValue) {
    // System.out.println("Inside setSourceType");
    sourceType = newValue; }
    public String getSourceType() {
    //System.out.println("Inside getSourceType");
    return sourceType; }
    // PROPERTY: source value
    public void setSourceValue(String newValue) {
    //System.out.println("Inside setSourceValue");
    sourceValue = newValue; }
    public String getSourceValue() {
    //System.out.println("Inside getSourceValue");
    return sourceValue; }
    // PROPERTY: source type
    public void setRcvTxnHeaderID(String newValue) {
    // System.out.println("Inside setSourceType");
    rcvTxnHeaderID = newValue; }
    public String getRcvTxnHeaderID() {
    //System.out.println("Inside getSourceType");
    return rcvTxnHeaderID; }
    // PROPERTY: Enable Disable
    public void setComponetEnableDisableStyle(String newValue) {
    // System.out.println("Inside setSourceType");
    componetEnableDisableStyle = newValue; }
    public String getComponetEnableDisableStyle() {
    //System.out.println("Inside getSourceType");
    return componetEnableDisableStyle; }
    // PROPERTY: Enable Disable Txn Ref
    public void setTxnRefEnableDisable(String newValue) {
    // System.out.println("Inside setSourceType");
    txnRefEnableDisable = newValue; }
    public String getTxnRefEnableDisable() {
    //System.out.println("Inside getSourceType");
    return txnRefEnableDisable; }
    // PROPERTY: part Number
    public void setPartNumber(String newValue) {
    // System.out.println("Inside setSourceType");
    partNumber = newValue; }
    public String getPartNumber() {
    //System.out.println("Inside getSourceType");
    return partNumber; }
    // PROPERTY: Quantity
    public void setQuantity(String newValue) {
    // System.out.println("Inside setSourceType");
    quantity = newValue; }
    public String getQuantity() {
    //System.out.println("Inside getSourceType");
    return quantity; }
    // PROPERTY: UseData Source
    public void setUseDataSource(String newValue) {
    // System.out.println("Inside setSourceType");
    useDataSource = newValue; }
    public String getUseDataSource() {
    //System.out.println("Inside getSourceType");
    return useDataSource; }
    // PROPERTY: Error Message
    public void setErrorMessage(String newValue) {
    // System.out.println("Inside setSourceType");
    errorMessage = newValue; }
    public String getErrorMessage() {
    //System.out.println("Inside getSourceType");
    return errorMessage; }
    // PROPERTY: User ID
    public String getUserID() {
    // System.out.println("Inside setSourceType");
    return("1048"); }
    // PROPERTY: Hub Name Editable
    public boolean isHubNameEditable() {
    return hubNameEditable; }
    public void setHubNameEditable(boolean newValue) {
    hubNameEditable = newValue; }
    //PROPERTY: Hub List
    public Collection getHubList() throws Exception {
    log.general("Inside getSourceTypeList");
    String strSQLstr = " SELECT hub_name hubName "+
    " FROM eaf_hub_master "+
    " WHERE nvl(enabled_flag,'N') = 'Y' "+
    " AND nvl(end_date_active,sysdate+1) > sysdate";
    ResultSet sl = db.getResultSet(strSQLstr);
    hubList = new ArrayList();
    int hubCt = 0;
    while (sl.next()){
    hubCt = hubCt + 1;
    hubList.add(new SelectItem(sl.getString("hubName")));
    //System.out.println("hubCt: "+hubCt);
    if (hubCt > 1) {
    setHubNameEditable(true);
    // System.out.println("Setting setHubNameEditable as true");
    } else{
    setHubNameEditable(false);
    // System.out.println("Setting setHubNameEditable as false");
    setHubName("One Hub");
    return(hubList);
    //PROPERTY: source List
    public Collection getSourceTypeList() throws Exception {
    System.out.println("Inside getSourceType:"+getSourceType());
    String sourceType = getSourceType();
    System.out.println("sourceType:"+sourceType);
    if (sourceType != null){
    if (sourceType.equals("OTHERS")){
    System.out.println("Inside getSourceType for OTHERS");
    setComponetEnableDisableStyle("");
    setUseDataSource("N");
    }else {
    System.out.println("Inside getSourceType for not OTHERS");
    setComponetEnableDisableStyle("display:none");
    setUseDataSource("Y");
    }else{
    System.out.println("Source Type is null");
    setComponetEnableDisableStyle("display:none");
    setUseDataSource("Y");
    setErrorMessage(null);
    log.general("Inside getSourceTypeList");
    String strSQLstr =" SELECT lookup_code sourceType "+
    " FROM hif_lookup_values "+
    " WHERE lookup_type = 'RCV_SOURCE_TYPE' "+
    " AND nvl(enabled_flag,'N') = 'Y' "+
    " AND nvl(end_date_active,sysdate+1) > sysdate ";
    ResultSet sl = db.getResultSet(strSQLstr);
    sourceList = new ArrayList();
    while (sl.next()){
    sourceList.add(new SelectItem(sl.getString("sourceType")));
    return(sourceList);
    //PROPERTY: validate and insert data
    public void createRecord() throws Exception{
    updateTxn();
    System.out.println("Inside createRecord");
    System.out.println("getSourceValue()"+getSourceValue());
    if ( !(getSourceValue()!="")){
    System.out.println("getSourceValue()"+getSourceValue());
    //JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please Scan / Enter value for "+getSourceType());
    } else if ((getUseDataSource()=="N") &&
    (!(getPartNumber()!="")||!(getQuantity()!=""))) {
    System.out.println( "Please Enter Part Number and Quantity");
    //JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Please Enter Part Number and Quantity" );
    else{
    Connection con = db.getConnection();
    try{
    try{
    System.out.println("SourceValue: "+sourceValue);
    System.out.println("Hub Name"+getHubName());
    String insertQuery = "begin "+
    " hif_rcv_pkg.create_record(?,?,?,?,?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(insertQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.registerOutParameter(3,Types.VARCHAR);
    cs.setString(3,getRcvTxnHeaderID());
    cs.setString(4,getIP());
    cs.setString(5,getUserID());
    cs.setString(6,getHubName());
    cs.setString(7,getSourceType());
    cs.setString(8, getSourceValue());
    cs.setString(9,getUseDataSource());
    cs.setString(10,getPartNumber());
    cs.setString(11,getQuantity());
    cs.execute();
    con.commit();
    String txnHeaderID = cs.getString(3);
    String errorCode = cs.getString(1);
    String errorMessage = cs.getString(2);
    if (errorMessage != null) {
    setErrorMessage(errorMessage);
    } else{
    if (txnHeaderID != null ){
    setRcvTxnHeaderID(txnHeaderID);
    txnRefEnableDisable= " ";
    setComponetEnableDisableStyle("display:none");
    setUseDataSource("Y");
    setSourceValue(null);
    setPartNumber(null);
    setQuantity(null);
    }catch (Exception e) {
    System.out.println("Error "+ e);
    } finally {
    con.close();
    public void updateRcvQty() throws Exception{
    System.out.println("Inside updateRcvQty");
    //System.out.println("RcvRecord: "+rcvRecord.toString());
    updateTxn();
    Connection con = db.getConnection();
    try{
    try{
    System.out.println("SourceValue: "+sourceValue);
    System.out.println("getRcvTxnHeaderID: "+getRcvTxnHeaderID());
    System.out.println("");
    String insertQuery = "begin "+
    " hif_rcv_pkg.update_rcv_qty (?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(insertQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(3,getRcvTxnHeaderID());
    cs.setString(4,getIP());
    cs.setString(5,getUserID());
    cs.setString(6,getSourceType());
    cs.setString(7,getSourceValue());
    cs.executeUpdate();
    con.commit();
    //setSourceValue(null);
    }catch (Exception e) {
    System.out.println("Error "+ e);
    } finally {
    con.close();
    public void deleteRecord() throws Exception{
    updateTxn();
    System.out.println("Inside deleteRecord");
    //System.out.println("RcvRecord: "+rcvRecord.toString());
    Connection con = db.getConnection();
    try{
    try{
    System.out.println("SourceValue: "+sourceValue);
    System.out.println("");
    String insertQuery = "begin "+
    " hif_rcv_pkg.delete_record (?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(insertQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(3,getRcvTxnHeaderID());
    cs.setString(4,getIP());
    cs.setString(5,getUserID());
    cs.setString(6,getSourceType());
    cs.setString(7, getSourceValue());
    cs.executeUpdate();
    con.commit();
    setSourceValue(null);
    }catch (Exception e) {
    System.out.println("Error "+ e);
    } finally {
    con.close();
    public void updateTxn()throws Exception{
    System.out.println("Inside updateTxn");
    int len = rcvDataArray.size();
    Connection con = db.getConnection();
    try{
    for (int i = 0; i < len; i++) {
    RcvTableDataBean bean = (RcvTableDataBean)rcvDataArray.get(i);
    try{
    System.out.println("Updateing Reference Value: "+ bean.getReferenceValue());
    System.out.println("Updateing Comment Value: "+ bean.getRcvComments());
    System.out.println("Updateing Receiving Qty: "+ bean.getRcvQuantity());
    System.out.println("Updateing Receiving Qty: "+ bean.getRcvQuantity());
    String updateQuery = "begin "+
    " hif_rcv_pkg.update_txn(?,?,?,?,?,?,?,?,?);"+
    "end; ";
    CallableStatement cs = con.prepareCall(updateQuery);
    cs.registerOutParameter(1,Types.VARCHAR);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.setString(3,getIP());
    cs.setString(4,getUserID());
    cs.setString(5,getRcvTxnHeaderID());
    cs.setString(6,bean.getTxnLineID());
    cs.setString(7,bean.getReferenceValue());
    cs.setString(8,bean.getRcvQuantity());
    cs.setString(9,bean.getRcvComments());
    cs.execute();
    con.commit();
    }catch (Exception e) {
    System.out.println("Error "+ e

    1) Please use code tags in the future. Lengthy, unformatted code isn't likely to read be most people here who are trying to help you for free.
    2) Next time, please use a short, compilable example that demonstrates your problem. Again, that is a lot of code to expect a volunteer to debug.
    3) This does not appear to be a Swing question. Perhaps you should have posted this in one of the web-based forums.
    Good luck.

  • Java - Write And Read From memory Like CheatEngine ( Writing not working?)

    Hello Oracle Forum
    I came here some time ago to ask about javaFX , i solved all my issues and im right now waiting for javaFx tot ake over swing and hmm, im working on learning LIBGDX to create games in java.
    However, im in need to create an app to change values of memory to fix a bug in an old program that i have, and the only way until now is using cheatEngine, So i decided to take a tutorial and learn how to do that in java.
    Well, im able to read from the memory but the write isnt working somehow... Im posting the code here, if anyone can give me a hint, i would thank and a lot, because theres a community that really needs this app to automate the fix without using cheat engine.
    package MainStart;
    import com.br.HM.User32;
    import com.br.kernel.Kernel32;
    import com.sun.jna.Memory;
    import com.sun.jna.Native;
    import com.sun.jna.Pointer;
    import com.sun.jna.ptr.IntByReference;
    public class Cheater {
        static Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
        static User32 user32 = (User32) Native.loadLibrary("user32", User32.class);
        static int readRight = 0x0010;
        static int writeRight = 0x0020;
        //static int PROCESS_VM_OPERATION = 0x0008;
        public static void main(String[] args) {
            //Read Memory
            //MineSweeper = Campo Minado
            int pid = getProcessId("Campo Minado"); // get our process ID
            System.out.println("Pid = " + pid);
            Pointer readprocess = openProcess(readRight, pid); // open the process ID with read priviledges.
            Pointer writeprocess = openProcess(writeRight, pid);
            int size = 4; // we want to read 4 bytes
            int address = 0x004053C8;
            //Read Memory
            Memory read = readMemory(readprocess, address, size); // read 4 bytes of memory starting at the address 0x00AB0C62.
            System.out.println(read.getInt(0)); // print out the value!      
            //Write Memory
            int writeMemory = writeMemory(writeprocess, address, new short[0x22222222]);
            System.out.println("WriteMemory :" + writeMemory);
            Memory readM = readMemory(readprocess, address, size);
            System.out.println(readM.getInt(0));
        public static int writeMemory(Pointer process, int address, short[] data) {
            IntByReference written = new IntByReference(0);
            Memory toWrite = new Memory(data.length);
            for (long i = 0; i < data.length; i++) {
                toWrite.setShort(0, data[new Integer(Long.toString(i))]);
            boolean b = kernel32.WriteProcessMemory(process, address, toWrite, data.length, written);
            System.out.println("kernel32.WriteProcessMemory : " + b); // Retorna false
            return written.getValue();
        public static Pointer openProcess(int permissions, int pid) {
            Pointer process = kernel32.OpenProcess(permissions, true, pid);
            return process;
        public static int getProcessId(String window) {
            IntByReference pid = new IntByReference(0);
            user32.GetWindowThreadProcessId(user32.FindWindowA(null, window), pid);
            return pid.getValue();
        public static Memory readMemory(Pointer process, int address, int bytesToRead) {
            IntByReference read = new IntByReference(0);
            Memory output = new Memory(bytesToRead);
            kernel32.ReadProcessMemory(process, address, output, bytesToRead, read);
            return output;
    package com.br.HM;
    import com.sun.jna.Native;
    import com.sun.jna.Pointer;
    import com.sun.jna.Structure;
    import com.sun.jna.platform.win32.WinDef.RECT;
    import com.sun.jna.ptr.ByteByReference;
    import com.sun.jna.ptr.IntByReference;
    import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
    import com.sun.jna.win32.W32APIOptions;
    * Provides access to the w32 user32 library. Incomplete implementation to
    * support demos.
    * @author Todd Fast, [email protected]
    * @author [email protected]
    public interface User32 extends W32APIOptions {
        User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);
        Pointer GetDC(Pointer hWnd);
        int ReleaseDC(Pointer hWnd, Pointer hDC);
        int FLASHW_STOP = 0;
        int FLASHW_CAPTION = 1;
        int FLASHW_TRAY = 2;
        int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY);
        int FLASHW_TIMER = 4;
        int FLASHW_TIMERNOFG = 12;
        public static class FLASHWINFO extends Structure {
            public int cbSize;
            public Pointer hWnd;
            public int dwFlags;
            public int uCount;
            public int dwTimeout;
        int IMAGE_BITMAP = 0;
        int IMAGE_ICON = 1;
        int IMAGE_CURSOR = 2;
        int IMAGE_ENHMETAFILE = 3;
        int LR_DEFAULTCOLOR = 0x0000;
        int LR_MONOCHROME = 0x0001;
        int LR_COLOR = 0x0002;
        int LR_COPYRETURNORG = 0x0004;
        int LR_COPYDELETEORG = 0x0008;
        int LR_LOADFROMFILE = 0x0010;
        int LR_LOADTRANSPARENT = 0x0020;
        int LR_DEFAULTSIZE = 0x0040;
        int LR_VGACOLOR = 0x0080;
        int LR_LOADMAP3DCOLORS = 0x1000;
        int LR_CREATEDIBSECTION = 0x2000;
        int LR_COPYFROMRESOURCE = 0x4000;
        int LR_SHARED = 0x8000;
        Pointer FindWindowA(String winClass, String title);
        int GetClassName(Pointer hWnd, byte[] lpClassName, int nMaxCount);
        public static class GUITHREADINFO extends Structure {
            public int cbSize = size();
            public int flags;
            Pointer hwndActive;
            Pointer hwndFocus;
            Pointer hwndCapture;
            Pointer hwndMenuOwner;
            Pointer hwndMoveSize;
            Pointer hwndCaret;
            RECT rcCaret;
        boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
        public static class WINDOWINFO extends Structure {
            public int cbSize = size();
            public RECT rcWindow;
            public RECT rcClient;
            public int dwStyle;
            public int dwExStyle;
            public int dwWindowStatus;
            public int cxWindowBorders;
            public int cyWindowBorders;
            public short atomWindowType;
            public short wCreatorVersion;
        boolean GetWindowInfo(Pointer hWnd, WINDOWINFO pwi);
        boolean GetWindowRect(Pointer hWnd, RECT rect);
        int GetWindowText(Pointer hWnd, byte[] lpString, int nMaxCount);
        int GetWindowTextLength(Pointer hWnd);
        int GetWindowModuleFileName(Pointer hWnd, byte[] lpszFileName, int cchFileNameMax);
        int GetWindowThreadProcessId(Pointer hWnd, IntByReference lpdwProcessId);
        interface WNDENUMPROC extends StdCallCallback {
             * Return whether to continue enumeration.
            boolean callback(Pointer hWnd, Pointer data);
        boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data);
        boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data);
        boolean FlashWindowEx(FLASHWINFO info);
        Pointer LoadIcon(Pointer hInstance, String iconName);
        Pointer LoadImage(Pointer hinst, // handle to instance
                String name, // image to load
                int type, // image type
                int xDesired, // desired width
                int yDesired, // desired height
                int load // load options
        boolean DestroyIcon(Pointer hicon);
        int GWL_EXSTYLE = -20;
        int GWL_STYLE = -16;
        int GWL_WNDPROC = -4;
        int GWL_HINSTANCE = -6;
        int GWL_ID = -12;
        int GWL_USERDATA = -21;
        int DWL_DLGPROC = 4;
        int DWL_MSGRESULT = 0;
        int DWL_USER = 8;
        int WS_EX_COMPOSITED = 0x20000000;
        int WS_EX_LAYERED = 0x80000;
        int WS_EX_TRANSPARENT = 32;
        int GetWindowLong(Pointer hWnd, int nIndex);
        int SetWindowLong(Pointer hWnd, int nIndex, int dwNewLong);
        int LWA_COLORKEY = 1;
        int LWA_ALPHA = 2;
        int ULW_COLORKEY = 1;
        int ULW_ALPHA = 2;
        int ULW_OPAQUE = 4;
        boolean SetLayeredWindowAttributes(Pointer hwnd, int crKey,
                byte bAlpha, int dwFlags);
        boolean GetLayeredWindowAttributes(Pointer hwnd,
                IntByReference pcrKey,
                ByteByReference pbAlpha,
                IntByReference pdwFlags);
         * Defines the x- and y-coordinates of a point.
        public static class POINT extends Structure {
            public int x, y;
         * Specifies the width and height of a rectangle.
        public static class SIZE extends Structure {
            public int cx, cy;
        int AC_SRC_OVER = 0x00;
        int AC_SRC_ALPHA = 0x01;
        int AC_SRC_NO_PREMULT_ALPHA = 0x01;
        int AC_SRC_NO_ALPHA = 0x02;
        public static class BLENDFUNCTION extends Structure {
            public byte BlendOp = AC_SRC_OVER; // only valid value
            public byte BlendFlags = 0; // only valid value
            public byte SourceConstantAlpha;
            public byte AlphaFormat;
        boolean UpdateLayeredWindow(Pointer hwnd, Pointer hdcDst,
                POINT pptDst, SIZE psize,
                Pointer hdcSrc, POINT pptSrc, int crKey,
                BLENDFUNCTION pblend, int dwFlags);
        int SetWindowRgn(Pointer hWnd, Pointer hRgn, boolean bRedraw);
        int VK_SHIFT = 16;
        int VK_LSHIFT = 0xA0;
        int VK_RSHIFT = 0xA1;
        int VK_CONTROL = 17;
        int VK_LCONTROL = 0xA2;
        int VK_RCONTROL = 0xA3;
        int VK_MENU = 18;
        int VK_LMENU = 0xA4;
        int VK_RMENU = 0xA5;
        boolean GetKeyboardState(byte[] state);
        short GetAsyncKeyState(int vKey);
    package com.br.kernel;
    import com.sun.jna.*;
    import com.sun.jna.win32.StdCallLibrary;
    import com.sun.jna.ptr.IntByReference;
    // by deject3d
    public interface Kernel32 extends StdCallLibrary
        // description from msdn
        //BOOL WINAPI WriteProcessMemory(
        //__in   HANDLE hProcess,
        //__in   LPVOID lpBaseAddress,
        //__in   LPCVOID lpBuffer,
        //__in   SIZE_T nSize,
        //__out  SIZE_T *lpNumberOfBytesWritten
        boolean WriteProcessMemory(Pointer p, int address, Pointer buffer, int size, IntByReference written);
        //BOOL WINAPI ReadProcessMemory(
        //          __in   HANDLE hProcess,
        //          __in   LPCVOID lpBaseAddress,
        //          __out  LPVOID lpBuffer,
        //          __in   SIZE_T nSize,
        //          __out  SIZE_T *lpNumberOfBytesRead
        boolean ReadProcessMemory(Pointer hProcess, int inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead);
        //HANDLE WINAPI OpenProcess(
        //  __in  DWORD dwDesiredAccess,
        //  __in  BOOL bInheritHandle,
        //  __in  DWORD dwProcessId
        Pointer OpenProcess(int desired, boolean inherit, int pid);
        /* derp */
        int GetLastError();
    http://pastebin.com/Vq8wfy39

    Hello there,
    this tutorial was exactly what I needed, so thank you.
    Your problem seems to be in this line:
    int writeMemory = writeMemory(writeprocess, address, new short[0x22222222]); 
    The problem is, you're creating a new short array with the length of 0x22222222. Which not only results in an java.lang.OutOfMemoryError: Java heap space
    but also, if it would work, would create an empty array with the length of 0x22222222.
    I think you want to write 0x22222222 as value in your address.
    Correctly stored the code you'd need to write would be:
    short[] sarray = new short[]{(short) 0x22222222};
    But because the value is too long for the short, the value stored in your array would be the number 8738.
    I think, what you want to do is to store the number 572662306, which would be the hex value, stored in an int variable.
    So first of all you need to strip down your hex-value to shorts:
    Short in Java uses 16 Bit = 2 Byte. 0x22222222 -> 0x2222 for your high byte and 0x2222 for your low byte
    So your array would be
    short[] sarray = new short[]{0x2222,0x2222};//notice, that sarray[0] is the lowbyte and sarray[1] the high byte, if you want to store 20 it would be new short[]{20,0} or if you use hex new short[]{0x14,0x00}
    The next part is your writeToMemory Method. If I'm right, the method in the tutorial is a little bit wrong. The right version should be this:
    public static int writeMemory(Pointer process, int address, short[] data) {
      IntByReference written = new IntByReference(0);
      int size = data.length*Short.SIZE/8;
      Memory toWrite = new Memory(size);
      for (int i = 0; i < data.length; i++) {
      toWrite.setShort(i*Short.SIZE/8,
      data[i]);
      boolean b = kernel32.WriteProcessMemory(process, address, toWrite,
      size, written);
      return written.getValue();
    You need to calculate your offset right. And the size of your memory. Maybe you could write this method not with shorts, but with integers. But this should work.
    If you pass your new array to this function, it should write 0x22222222 to your adress. If you read out your toWrite value with toWrite.getInt(0) you get the right value.
    And there is one more thing. In order to write data to a process, you need to grant two access rights:
    A handle to the process memory to be modified. The handle must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access to the process.
    You have to grant the right to write data: PROCESS_VM_WRITE: 0x0020 and PROCESS_VM_OPERATION: 0x0008
    So your writeProcess needs to get initialized this way:
    Pointer writeprocess = openProcess(0x0020|0x0008,pid);
    I hope this works for you. Let me know.
    Greetings
    Edit:
    Because every data you write will be 1 byte to whatever count of byte I think the best way is to use the following method to write data to the memory:
    public static void writeMemory(Pointer process, long address, byte[] data)
      int size = data.length;
      Memory toWrite = new Memory(size);
      for(int i = 0; i < size; i++)
      toWrite.setByte(i, data[i]);
      boolean b = kernel32.WriteProcessMemory(process, address, toWrite, size, null);
    You can see some changes. First I changed all address values from int to long, because some addresses are out of range. And with all, i mean all. Not only in writeMemory, but also in readMemory and in your kernel32 Class.
    Second I don't use the IntByReference anymore..
    To use this method you need to store your data the following way if you would write 4 Byte data:
    byte[] values = new byte[]{0x14,0x00,0x00,0x00};
    This value would be the number 20. Index 0 will be the lowest byte and index 3 will be the highest byte.
    And one more thing I wrote is an method which you can use to calculate your address if you have a baseAddress.
    If you restart your program/game your old addresses won't point at the same values of your game. With some research (I use CheatEngine) you can get the baseaddress. This one will alway be the same.
    To get from your baseaddress to the dynamic adress you use offsets.
    public static long findDynAddy(Pointer process, int[] offsets, long baseAddress)
      long pointer = baseAddress;
      int size = 4;
      Memory pTemp = new Memory(size);
      long pointerAddress = 0;
      for(int i = 0; i < offsets.length; i++)
      if(i == 0)
      kernel32.ReadProcessMemory(process, pointer, pTemp, size, null);
      pointerAddress = ((pTemp.getInt(0)+offsets[i]));
      if(i != offsets.length-1)
      kernel32.ReadProcessMemory(process, pointerAddress, pTemp, size, null);
      return pointerAddress;
    This methods gets a process, an array of offsets (hex-values) and your baseadress and returns the dynamic address.
    For Solitaire the following code would give you the address to the score:
    long baseAddr = 0x10002AFA8L;
      int[] offsets = new int[]{0x50,0x14};
      long addr = findDynAddy(process, offsets, baseAddr);
    If somebody wants to get the whole code (user32, kernel32 and the cheater) just pm me and I will give you a link.

  • Web Cam applet is not working in great consistency

    Hi... My video capturing applet is not working very well.
    The image stream is displayed on the web page in JPEG format with 0.5 quality. However, it crashes after a while and the it does not release the vfw resource.
    I have to restart my machine in order to execute it again.
    Can anyone please help?
    Thanks.
    Carter

    Ok. Thanks.
    Sender Applet
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    /*<applet code="myGUIApplet.class" width="300" height="300"></applet>*/
    public class myGUIApplet extends JApplet implements ActionListener
         private JPanel bottom=new JPanel();
         private JPanel centVisual=new JPanel();
         private JPanel connectionAddress=new JPanel();
         private JButton capture=new JButton("Start Capturing");
         private JButton stops=new JButton("Stop");
         private JMenuBar menubar=new JMenuBar();
         private JMenu file=new JMenu("file");     
         private JMenuItem fileItem1=new JMenuItem("Exit");
         private JLabel serverip=new JLabel("Server IP");
         private JTextField setIP=new JTextField();
         public static JTextField ServerInfo=new JTextField();
         private MyTransmitter mytrans;
         private String ip;
         public static final String DEFAULT_MULTICAST_IP="226.10.10.20";
         public static final String DEFAULT_PORT="80";
         public void init()
              //setSize(400,400);               
              setLayout(new BorderLayout());
              menubar.add(file);
              file.add(fileItem1);
              bottom.setLayout(new BorderLayout());
              bottom.setBackground(Color.black);
              bottom.add("West",capture);
              bottom.add("East",stops);
              connectionAddress.setLayout(new BorderLayout());
              connectionAddress.add("North",serverip);
              connectionAddress.add("South",setIP);
              ServerInfo.setEditable(false);
              connectionAddress.add("Center",ServerInfo);
              setIP.addActionListener(this);
              setIP.setText("");
              capture.setBackground(Color.lightGray);
              capture.addActionListener(this);
              stops.addActionListener(this);
              fileItem1.addActionListener(this);
              add("South",bottom);
              add("North",menubar);     
              add("Center",connectionAddress);          
         public void actionPerformed(ActionEvent ae){
              Object source=ae.getSource();
              if(source==capture){
              if(setIP.getText().equals(""))
                        ip=DEFAULT_MULTICAST_IP;
              else{
                   ip=setIP.getText();
                   if(mytrans!=null){
                        mytrans.stopTransmitter();
                        mytrans=null;                         
                   System.out.println(" - Connecting to "+ip+" port: "+DEFAULT_PORT);
                   ServerInfo.setText(" - Connecting to "+ip+" port: "+DEFAULT_PORT);
                   mytrans=new MyTransmitter(ip,DEFAULT_PORT,ServerInfo);
                   mytrans.start();               
              if(source==stops){
                   if(mytrans!=null)
                        mytrans.stopTransmitter();
                   System.exit(0);
              if(source==fileItem1){
                   if(mytrans!=null)
                        mytrans.stopTransmitter();     
                   System.exit(0);
         public void destroy(){
              if(mytrans!=null){
                   mytrans.stopTransmitter();
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.net.InetAddress;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.*;
    import javax.media.control.TrackControl;
    import javax.media.control.QualityControl;
    import javax.media.rtp.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.rtp.*;
    import java.io.InputStream;
    import javax.media.rtp.RTPManager;
    public class MyTransmitter extends Thread
         private MediaLocator videoLocator;
         private String ipAddress;
         private int basePort;
         private Integer stateLock=new Integer(0);
         private boolean failure;
         private Processor processor;
         private DataSource videoDataInput,videoDataOutput;
         private RTPManager rtpMgrs[];
         private VideoFormat JPEG_VIDEO=new VideoFormat(VideoFormat.JPEG_RTP);
         private SendStream sendStream;
         private SourceDescription descriptionList[];
         private JTextField infoField;
         public MyTransmitter(String ips,String ports,JTextField ServerInfo){
              infoField=ServerInfo;
              ipAddress=ips;
              Integer bPort=Integer.valueOf(ports);
              if(bPort!=null)
                   basePort=bPort.intValue();
         public void run()
              initializeVideo();
              if(videoLocator!=null){
                   createMyProcessor();
                   createMyManager();
              // May be should put inside the if..else statements
              //createMyTransmitter();
         // Initailize the video
         public void initializeVideo()
              // Stre the devices in a vector
              VideoFormat format=new VideoFormat(VideoFormat.RGB);
              Vector deviceList=CaptureDeviceManager.getDeviceList(format);
              CaptureDeviceInfo deviceInfo=null;
              // If there is more than one device detected
              if(deviceList.size()>0){
                   // Set the first device to device Info
                   // GEt the media locator of the devie
                   deviceInfo=(CaptureDeviceInfo)deviceList.elementAt(0);
                   videoLocator=deviceInfo.getLocator();
              }else{
                   System.out.println(" --X No device found...");
                   infoField.setText(" --X No device found...");
         public void createMyProcessor()
              boolean result=false;
              DataSource ds=null;
              // Check if the media locator is null
              if(videoLocator==null){
                   System.out.println(" --X No video locator..");
                   infoField.setText(" --X No video locator...");
              System.out.println(" - Trying to create a Processor..");
              infoField.setText(" - Trying to create a Processor..");
              // Attempt to create DataSource from media locator
              try{
                   ds=Manager.createDataSource(videoLocator);
              }catch(Exception ex){
                   System.out.println(" --X Unable to create dataSource : "+ex.getMessage());
              System.out.println(" - Video data source is created..");
              infoField.setText(" - Video data source is created..");
              // Try to create Processor from DataSource
              try{
                   processor=Manager.createProcessor(ds);
              }catch(NoProcessorException npe){
                   System.out.println(" --X Unable to create Processor: "+npe.getMessage());
                   infoField.setText(" --X Unable to create Processor: "+npe.getMessage());
              catch(IOException ioe){
                   System.out.println(" --X IOException creating Processor..");
                   infoField.setText(" --X IOException creating Processor..");
              // Wait for the processor to be configured
              result=waitForState(processor,Processor.Configured);
              if(result==false){
                   System.out.println(" --X Could not configure processor..");
                   infoField.setText(" --X Could not configure processor..");
              // Set the track controls for processor
              TrackControl []tracks=processor.getTrackControls();
              if(tracks==null || tracks.length<1){
                   System.err.println(" --X No track is found..");
                   infoField.setText(" --X No track is found..");
              // Set the content description of processor to RAW_RTP format
              // This will limit the supported formats to reported from
              // Track.getSupportedFormats() to valid RTP format
              ContentDescriptor cdes=new ContentDescriptor(ContentDescriptor.RAW_RTP);
              processor.setContentDescriptor(cdes);
              Format []supported;
              Format chosen=null;
              boolean atLeastOneTrack=false;
              for(int i=0;i<tracks.length;i++){
                   Format format=tracks.getFormat();
                   if(tracks[i].isEnabled()){
                        supported=tracks[i].getSupportedFormats();
                        // WE've set the output content to RAW_RTP.
                        // So, all the supporte formats should work with RAW_RTP.
                        // We will pick the first one.
                        if(supported.length>0){
                             if(supported[0] instanceof VideoFormat){                              
                                  chosen=checkVideoSize(tracks[i].getFormat(),supported[0]);
                             }else
                                  chosen=supported[0];
                             tracks[i].setFormat(chosen);
                             System.out.println(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             infoField.setText(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             atLeastOneTrack=true;
                        }else{
                             // If no format is suitable, track is disabled
                             tracks[i].setEnabled(false);
                   }else
                        tracks[i].setEnabled(false);          
              if(!atLeastOneTrack)
                   System.out.println("atLeastOneTrack: "+atLeastOneTrack);
                   System.out.println(" --X Could Not find track to RTP format..");
                   infoField.setText("atLeastOneTrack: "+atLeastOneTrack);
                   infoField.setText(" --X Could Not find track to RTP format..");
              result=waitForState(processor,Controller.Realized);
              if(result==false){
                   System.out.println(" --X Could NOT realize processor...");
                   infoField.setText(" --X Could NOT realize processor...");
              // Set the JPEG Quality to value 0.5
              setJPEGQuality(processor,0.5f);
              // Set the output Data Source
              videoDataOutput=processor.getDataOutput();
              //Start the processor
              processor.start();          
         public void setJPEGQuality(Processor p,float values)
              Control []cs=p.getControls();
              QualityControl qc=null;
              VideoFormat JPEGFmt=new VideoFormat(VideoFormat.JPEG);
              // Loop through the ocntrols to find the Quality control for the JPEG encoder
              for(int i=0;i<cs.length;i++){
                   if(cs[i] instanceof QualityControl && cs[i] instanceof Owned){
                        Object owner=((Owned)cs[i]).getOwner();
                        // Check if the owner is the Codec
                        // Check the format of output as well
                        if(owner instanceof Codec){
                             Format fmts[]=((Codec)owner).getSupportedOutputFormats(null);
                             // Loop through the supported format and set the quality to 0.5
                             for(int j=0;j<fmts.length;j++){
                                  qc=(QualityControl)cs[i];
                                  qc.setQuality(values);
                                  System.out.println(" - Quality is set to "+values+" on "+qc);
                                  infoField.setText(" - Quality is set to "+values+" on "+qc);
                                  break;
                   if(qc!=null)
                        break;
         public Format checkVideoSize(Format originalFormat,Format supported)
              int width,height;
              Dimension size=((VideoFormat)originalFormat).getSize();     
              Format jpegFormat=new Format(VideoFormat.JPEG_RTP);
              Format h263fmt=new Format(VideoFormat.H263_RTP);
              if(supported.matches(jpegFormat)){
                   width=(size.width%8 == 0 ? size.width:(int)(size.width%8)*8);
                   height=(size.height%8 == 0 ? size.height:(int)(size.height%8)*8);
              }else if(supported.matches(h263fmt)){
                   if(size.width<128){
                        width=128;
                        height=96;
                   }else if(size.width<176){
                        width=176;
                        height=144;
                   }else{
                        width=352;
                        height=288;
              }else{
                   // Unknown format, just return it.
                   return supported;
              return (new VideoFormat(null,new Dimension(width,height),Format.NOT_SPECIFIED,null,Format.NOT_SPECIFIED)).intersects(supported);
         public boolean waitForState(Processor p,Integer status)
              p.addControllerListener(new StateListener());
              failure=false;
              if(status==Processor.Configured){
                   p.configure();               
              }else if(status==Processor.Realized){
                   p.realize();
              //Wait until an event that confirms the success of the method, or failure of an event
              while(p.getState()<status && !failure){
                   synchronized(getStateLock()){
                        try{
                             // Wait
                             getStateLock().wait();
                        }catch(InterruptedException ie){
                             return false;
              if(failure)
                   return false;
              else
                   return true;
         public Integer getStateLock(){
              return stateLock;
         public void setFailure(){
              failure=true;
         public void createMyManager()
              SessionAddress destAddress;
              InetAddress ipAddr;
              int port;
              SourceDescription srcDesList[];
              PushBufferDataSource pbds=(PushBufferDataSource)videoDataOutput;
              PushBufferStream pbss[]=pbds.getStreams();          
              rtpMgrs=new RTPManager[pbss.length];          
              for(int a=0;a<pbss.length;a++){
              try{
                   // RTP Managers or RTP Manager?????
                   rtpMgrs[a]=RTPManager.newInstance();
                   port=basePort;
                   ipAddr=InetAddress.getByName(ipAddress);
                   SessionAddress localAddr=new SessionAddress(InetAddress.getLocalHost(),port+20);
                   destAddress=new SessionAddress(ipAddr,port,1);
                   Integer myipprefix=Integer.valueOf(ipAddress.substring(0,3));
                   if((myipprefix.intValue()>223) && (myipprefix.intValue()<240)){
                        rtpMgrs[a].initialize(destAddress);
                   }else{
                        rtpMgrs[a].initialize(localAddr);
                   rtpMgrs[a].addTarget(destAddress);
                   System.out.println(" Created RTP session: "+ipAddress+" "+port+" to "+destAddress);
                   infoField.setText(" Created RTP session: "+ipAddress+" "+port+" to "+destAddress);
                   if(videoDataOutput!=null){
                        sendStream=rtpMgrs[a].createSendStream(videoDataOutput,0);
                        sendStream.start();
                        System.out.println(" RTP stream is started..");
                        infoField.setText(" RTP stream is started..");
              }catch(UnsupportedFormatException ex){
                   System.out.println(" --X Unsupported Format : "+ex);
                   infoField.setText(" --X Unsupported Format : "+ex);
              catch(IOException ioe){
                   System.out.println(" --X IOException : "+ioe.getMessage());
                   infoField.setText(" --X IOException : "+ioe.getMessage());
              catch(Exception ex){
                   System.out.println(" --X Unable to create RTP Manager...");
                   System.out.println(ex.getMessage());
                   infoField.setText(" --X Unable to create RTP Manager..."+ex.getMessage());
         /*public void createMyTransmitter()
         try{
              if(videoDataOutput!=null){
                   sendStream=rtpMgrs[i].createSendStream(videoDataOutput,0);
                   sendStream.start();
         }catch(UnsupportedFormatException ex){
                   System.out.println(" --X Unsupported Format : "+ex);
                   infoField.setText(" --X Unsupported Format : "+ex);
         catch(IOException ioe){
                   System.out.println(" --X IOException : "+ioe.getMessage());
                   infoField.setText(" --X IOException : "+ioe.getMessage());
         public void stopTransmitter(){
              if(processor!=null){
                   processor.stop();
                   processor.close();
                   processor=null;
                   // Loop through RTP Managers and close all managers..
                   // Dispose them for garbage collection
                   for(int i=0;i<rtpMgrs.length;i++){
                        rtpmgrs[i].removeSendStream(this);
                        rtpMgrs[i].removeTargets("Session ended..");
                        rtpMgrs[i].dispose();
                   //rtpMgrs.removeTargets("Session ended..");
                   //rtpMgrs.dispose();
         * StateListener class to handle Controller events
         class StateListener implements ControllerListener{
              public void controllerUpdate(ControllerEvent ce){
                   if(ce instanceof ControllerClosedEvent){
                        processor.close();
                   /* Handle all controller events and notify all
                   waiting thread in waitForState method */
                   if(ce instanceof ControllerEvent){
                        synchronized(getStateLock()){
                             getStateLock().notifyAll();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Client Applet
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.control.BufferControl;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.rtp.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.rtp.event.*;
    import com.sun.media.rtp.RTPSessionMgr;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import java.net.URL;
    import java.net.Socket;
    /*<applet code="clientPlayerApplet.class" width="400" height="300">
         <param name=ServerIPS value="192.168.0.9">
         <param name=ServerPort value="80">
         <param name=TimeToLive value="1">
         <param name=archive value="clientPlayerApplet.jar">
    </applet> */
    public class clientPlayerApplet extends JApplet implements ControllerListener, ReceiveStreamListener,SessionListener
         String sessions[]=null;
         RTPManager rtpmgrs[]=null;     
         boolean dataReceived=false;
         Object myDataSync=new Object();
         private Player player;
         //private String serveripadd="226.10.10.20";
         //private int serverPort=2020;
         //private int timeToLive=1;
         private JPanel panel;
         private Vector currentParticipant;
         public void init()
              panel=new JPanel();
              setLayout(new BorderLayout());
              add("Center",panel);
              //String[] urls;
              /*urls[0]=getParameter("ServerIPS");
              urls[1]="/";
              urls[2]=getParameter("ServerPort");*/
              String []urls={new String(getParameter("ServerIPS")+"/"+getParameter("ServerPort")+"/"+getParameter("TimeToLive"))};
              sessions=urls;          
              initializePlayer();
         public void initializePlayer(){
              try{
                   InetAddress ipAddr;
                   SessionAddress localAddr=new SessionAddress();
                   SessionAddress destAddr;
                   rtpmgrs=new RTPManager[sessions.length];
                   currentParticipant=new Vector();
                   //rtpmgrs=new RTPManager();
                   SessionLabel session=null;
                   //Open RTP session
                   for(int i=0;i<sessions.length;i++){
                        try{
                             session=new SessionLabel(sessions[i]);
                             //session=new SessionLabel(sessions);
                        }catch(IllegalArgumentException iae){
                             System.out.println(" --X Unable to parse the sesion address given");     
                        System.out.println(" - Open RTP session for "+session.port);
                        rtpmgrs[i]=(RTPManager) RTPManager.newInstance();               
                        rtpmgrs[i].addSessionListener(this);
                        rtpmgrs[i].addReceiveStreamListener(this);
                        ipAddr=InetAddress.getByName(session.addr);
                        if(ipAddr.isMulticastAddress()){
                             localAddr=new SessionAddress(ipAddr,session.port,session.ttl);
                             destAddr=new SessionAddress(ipAddr,session.port,session.ttl);
                        }else{
                             localAddr=new SessionAddress(InetAddress.getLocalHost(),session.port);     
                             destAddr=new SessionAddress(ipAddr,session.port);
                        rtpmgrs[i].initialize(localAddr);
                        BufferControl bc=(BufferControl)rtpmgrs[i].getControl("javax.media.control.BufferControl");
                        if(bc!=null)
                             bc.setBufferLength(600);
                        rtpmgrs[i].addTarget(destAddr);
              }catch(Exception ex){
                   System.out.println(" --X Cannot create RTP Session "+ex.getMessage());
              long currentTime=System.currentTimeMillis();
              long waitingDuration=10000;
              try{
                   synchronized(myDataSync){
                        while(!dataReceived && (System.currentTimeMillis() - currentTime < waitingDuration)){
                             if(!dataReceived){
                                  myDataSync.wait(1000);
              }catch(Exception ex){
                   System.out.println(" --X myDataSync interrupted...");
              if(!dataReceived){
                   System.out.println(" No RTP Stream Data is received.." );               
         public void destroy()
              for(int i=0;i<currentParticipant.size();i++){
                   //if(player!=null)
                        ((MyPlayList)currentParticipant.elementAt(i)).close();
              // Loop through the RTP Managers
              // -> Remove the stream listener
              // -> Remove the target address
              // -> Dispose the RTP Manager for garbage collection
              currentParticipant.removeAllElements();
              for(int i=0;i<rtpmgrs.length;i++){
                   if(rtpmgrs[i]!=null){
                        rtpmgrs[i].removeReceiveStreamListener(this);
                        rtpmgrs[i].removeTargets(" Closing session..");
                        rtpmgrs[i].dispose();
                        rtpmgrs[i]=null;
         MyPlayList find(Player pl){
              for(int i=0;i<currentParticipant.size();i++){
                   MyPlayList mpl=(MyPlayList)currentParticipant.elementAt(i);
                   if(mpl.clientPlay==pl)
                        return mpl;
              return null;
         MyPlayList find(ReceiveStream rs){
              for(int i=0;i<currentParticipant.size();i++){
                   MyPlayList mpl=(MyPlayList)currentParticipant.elementAt(i);
                   if(mpl.stream==rs)
                        return mpl;
              return null;
         *     ReceiveStream Listener function                    *
         public synchronized void update(ReceiveStreamEvent rse)
              RTPManager mgr=(RTPManager)rse.getSource();
              ReceiveStream stream=rse.getReceiveStream();
              Participant participant=rse.getParticipant();
              if(rse instanceof RemotePayloadChangeEvent){
                   System.out.println(" -- Received Payload Change Event..");
                   System.out.println(" Sorry, no payload change is allowed.");               
              }else if(rse instanceof NewReceiveStreamEvent){
                   try{
                        // Once the new stream is detected, create the datasource
                        stream=((NewReceiveStreamEvent)rse).getReceiveStream();
                        DataSource outputDS=stream.getDataSource();
                        // Get RTP Controller to find the format
                        RTPControl rtpctl=(RTPControl)outputDS.getControl("javax.media.rtp.RTPControl");
                        if(rtpctl!=null){
                             System.out.println(" -> Received new rtP stream: "+rtpctl.getFormat());
                        }else
                             System.out.println(" -> Received new RTP stream");
                        if(participant!=null){
                             System.out.println(" -> New stream received from: "+participant.getCNAME());
                        }else{
                             System.out.println(" -> New stream detected... ");
                        player=Manager.createPlayer(outputDS);
                        if(player==null)
                             return;
                        System.out.println(" - Player is created...");
                        player.addControllerListener(this);
                        player.realize();
                        // Helper class to identify the player and stream
                        MyPlayList mpl=new MyPlayList(player,stream);
                        // Add the helper class object to Vector
                        currentParticipant.addElement(mpl);
                        // Notify initializePlayer() that a new stream has arrived
                        synchronized(myDataSync){
                             dataReceived=true;
                             myDataSync.notifyAll();
                   }catch(Exception ex){
                        System.out.println(" --X NewReceiveStream Exception: "+ex.getMessage());
                        return;
              }else if(rse instanceof ByeEvent){
                   System.out.println(" - BYE packet received from "+participant.getCNAME());
                   MyPlayList mpls=find(stream);
                   if(player!=mpls){
                        mpls.close();
                        currentParticipant.removeElement(mpls);
                   if(mgr!=null){
                        mgr.removeReceiveStreamListener(this);
                        mgr.removeTargets(" Closing session..");
                        mgr.dispose();
                        mgr=null;
              }else if(rse instanceof StreamMappedEvent){
                   if(stream!=null && stream.getDataSource()!=null){
                        DataSource myds=stream.getDataSource();
                        RTPControl rtpctrl=(RTPControl)myds.getControl("javax.media.rtp.RTPControl");
                        System.out.println(" -> The previously unidentified stream ");
                        if(rtpctrl!=null)
                             System.out.println(" "+rtpctrl.getFormat());
                        System.out.println(" has been identified as sent by :"+participant.getCNAME());
         *           Session Listener
         public void update(SessionEvent sesevt)
              if(sesevt instanceof NewParticipantEvent){
                   Participant part=((NewParticipantEvent)sesevt).getParticipant();
                   System.out.println(" -> A new partcipant has joined :"+part.getCNAME());
         *     ControllerListener for Players          
         public synchronized void controllerUpdate(ControllerEvent ce)
              Player p=(Player)ce.getSource();
              if(p==null)
                   return;
              if(ce instanceof RealizeCompleteEvent){
                   MyPlayList mpls=find(p);
                   if(mpls!=null){
                        p.start();
                        if(p.getVisualComponent()!=null){
                             panel.add(player.getVisualComponent());
                             panel.validate();
              if(ce instanceof ControllerErrorEvent){
                   p.removeControllerListener(this);
                   MyPlayList mpls=find(p);
                   if(mpls!=null){
                        // Close the player
                        // Remove the player helper class object from the list
                        p.close();
                        currentParticipant.removeElement(mpls);
                   System.out.println("Receiver internal error: "+ce);
         class SessionLabel{
              public String addr=null;
              public int port;
              public int ttl;
              SessionLabel(String session) throws IllegalArgumentException
                   int off;
                   String portStr=null;
                   String ttlStr=null;
                   if(session!=null && session.length() >0){
                        while(session.length()>1 && session.charAt(0)=='/')
                             session=session.substring(1);
                        off=session.indexOf('/');
                        if(off==-1){
                             if(!session.equals(""))
                                  addr=session;
                        }else{
                             addr=session.substring(0,off);
                             session=session.substring(off+1);
                             off=session.indexOf('/');
                             if(off==-1){
                                  if(!session.equals(""))
                                       portStr=session;
                             }else{
                                  portStr=session.substring(0,off);
                                  session=session.substring(off+1);
                                  off=session.indexOf('/');
                                  if(off==-1){
                                       if(!session.equals(""))
                                            ttlStr=session;
                                  }else{
                                       ttlStr=session.substring(0,off);
                   if(addr==null)
                        throw new IllegalArgumentException();
                   if(portStr!=null)
                        try{
                             Integer ints=Integer.valueOf(portStr);
                             if(ints!=null)
                                  port=ints.intValue();
                        }catch(Throwable t){
                             System.out.println(" --X PortStr Error..");
                             throw new IllegalArgumentException();
                   }else
                        throw new IllegalArgumentException();
                   if(ttlStr!=null){
                   try{
                        Integer intsttl=Integer.valueOf(ttlStr);
                        if(intsttl!=null)
                             ttl=intsttl.intValue();
                   }catch(Throwable t){
                             System.out.println(" --X PortStr Error..");
                             throw new IllegalArgumentException();
         class MyPlayList{
              Player clientPlay;
              ReceiveStream stream;
              MyPlayList(Player p,ReceiveStream rs){
                   clientPlay=p;
                   stream=rs;
              public void close()
                   clientPlay.close();

  • Function Key not work when using jre1.5

    My application was based on JDK1.3 to develop and JRE 1.3 is using in the client side.
    In the application, function keys are the shortcut and it is working fine based on the above setting.
    Since JRE 1.5 is encouraged to be used in the future, we try to use it to run our application. But we find that all function keys are not working.
    I am not sure the fact, but I get the following exception sometimes in the console:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
    at javax.swing.LayoutComparator.compare(LayoutComparator.java:61)
    at java.util.Arrays.mergeSort(Arrays.java:1307)
    at java.util.Arrays.mergeSort(Arrays.java:1296)
    at java.util.Arrays.mergeSort(Arrays.java:1296)
    at java.util.Arrays.mergeSort(Arrays.java:1295)
    at java.util.Arrays.sort(Arrays.java:1223)
    at java.util.Collections.sort(Collections.java:159)
    at javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycle(Sorting
    FocusTraversalPolicy.java:119)
    at javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocu
    sTraversalPolicy.java:425)
    at javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusT
    raversalPolicy.java:148)
    at javax.swing.SortingFocusTraversalPolicy.getDefaultComponent(SortingFo
    cusTraversalPolicy.java:502)
    at javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultComponent(Legacy
    GlueFocusTraversalPolicy.java:131)
    at java.awt.FocusTraversalPolicy.getInitialComponent(FocusTraversalPolic
    y.java:149)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFoc
    usManager.java:318)
    at java.awt.Component.dispatchEventImpl(Component.java:3841)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Window.dispatchEventImpl(Window.java:1766)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.SequencedEvent.dispatch(SequencedEvent.java:93)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:234)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    I try to compile my code using JDK 1.3 and 1.5. Actually, there is no compilation error.
    Please help me if you know the fact or solution.
    Thanks a lot!

    The supported Software in iPlanet's Portal Server is JDK/JRE 1.2.2_07 and JDK 1.2.2_09(in SP4). Starting with JDK1.3.1_01, applets are handled somewhat differently. Enable Java and look at the error messages in Java Console to find why the Netlet is not loading in JDK1.3.1_02. The issue might be with two JRE's or with your cache setting. Hope this helps you.
    Thanks,
    Raj_indts
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Why table getWidth and setWidth is not working when resize column the table

    hi all,
    i want to know why the setWidth is not working in the following code,
    try to uncomment the code in columnMarginChanged method and run it wont resize the table.
    i cont set width(using setWidth) of the other table column using getWidth of the main table column.
    and i want to resize the right side columns only (you can check when you resize the any column the left and right side columns also resizing)
    any suggestions could be helpful.
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.TableColumnModelEvent;
    import javax.swing.event.TableColumnModelListener;
    import javax.swing.table.TableColumnModel;
    public class SynTableResize extends JFrame implements TableColumnModelListener, ActionListener
        JTable  table1       = new JTable(5, 5);
        JTable  table2       = new JTable(5, 5);
        JTable  table3       = new JTable(5, 5);
        JButton btn          = new JButton("refresh");
        JPanel  pnlcontainer = new JPanel();
        public SynTableResize()
            setLayout(new BorderLayout());
            pnlcontainer.setLayout(new BoxLayout(pnlcontainer, BoxLayout.Y_AXIS));
            pnlcontainer.add(table1.getTableHeader());
            pnlcontainer.add(Box.createVerticalStrut(5));
            pnlcontainer.add(table2);
            pnlcontainer.add(Box.createVerticalStrut(5));
            pnlcontainer.add(table3);
            table2.setTableHeader(null);
            table3.setTableHeader(null);
            table1.getColumnModel().addColumnModelListener(this);
            table3.setColumnModel(table1.getColumnModel());
            table2.setColumnModel(table1.getColumnModel());
            table2.getColumnModel().addColumnModelListener(table1);
            table3.getColumnModel().addColumnModelListener(table1);
            btn.addActionListener(this);
            getContentPane().add(pnlcontainer, BorderLayout.CENTER);
            getContentPane().add(btn, BorderLayout.SOUTH);
            setSize(new Dimension(400, 400));
            setVisible(true);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
        public static void main(String[] args)
            new SynTableResize();
        public void columnAdded(TableColumnModelEvent e)
        public void columnMarginChanged(ChangeEvent e)
            TableColumnModel tcm = table1.getColumnModel();
            int columns = tcm.getColumnCount();
            for (int i = 0; i < columns; i++)
                table2.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getWidth());
                table3.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getWidth());
                // the following commented code wont work.
    //            table2.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth());
    //            table3.getColumnModel().getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth());
    //            table2.getColumnModel().getColumn(i).setWidth(tcm.getColumn(i).getWidth());
    //            table3.getColumnModel().getColumn(i).setWidth(tcm.getColumn(i).getWidth());
            SwingUtilities.invokeLater(new Runnable()
                public void run()
                    table2.revalidate();
                    table3.revalidate();
        public void columnMoved(TableColumnModelEvent e)
        public void columnRemoved(TableColumnModelEvent e)
        public void columnSelectionChanged(ListSelectionEvent e)
        public void actionPerformed(ActionEvent e)
            JTable table = new JTable(5, 5);
            table.setColumnModel(table1.getColumnModel());
            table.getColumnModel().addColumnModelListener(table1);
            pnlcontainer.add(Box.createVerticalStrut(5));
            pnlcontainer.add(table);
            pnlcontainer.validate();
            pnlcontainer.repaint();
    }thanks
    dayananda b v

    hi,
    thanks for your replay,
    yes i know that, you can check the following code it works fine.
    actually what i want is, when i resize table column it shold not automaticaly reszie when table resized and i dont want horizontal scroll bar, meaning that all table columns should resize with in the table size(say width 300)
    if i make table autoresize off than horizontal scroll bar will appear and the other columns moved and i want scroll to view other columns.
    please suggest me some way doing it, i tried with doLayout() no help,
    doLayout() method only can be used when table resizes. first off all i want to restrict table resizing with in the limited size
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.event.ChangeEvent;
    import javax.swing.table.TableColumnModel;
    public class TempSycnTable extends JFrame
        JTable  table1       = new JTable(5, 5);
        MyTable table2       = new MyTable(5, 5);
        MyTable table3       = new MyTable(5, 5);
        JPanel  pnlcontainer = new JPanel();
        public TempSycnTable()
            JScrollPane src2 = new JScrollPane(table2);
            JScrollPane src3 = new JScrollPane(table3);
    //        table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //        table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //        table3.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //        src2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    //        src3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            table2.setTableHeader(null);
            table3.setTableHeader(null);
            table3.setColumnModel(table1.getColumnModel());
            table2.setColumnModel(table1.getColumnModel());
            table2.getColumnModel().addColumnModelListener(table1);
            table3.getColumnModel().addColumnModelListener(table1);
            table2.setTableHeader(null);
            table3.setTableHeader(null);
            setLayout(new BorderLayout());
            pnlcontainer.setLayout(new BoxLayout(pnlcontainer, BoxLayout.Y_AXIS));
            pnlcontainer.add(table1.getTableHeader());
            pnlcontainer.add(Box.createVerticalStrut(5));
            pnlcontainer.add(src2);
            pnlcontainer.add(Box.createVerticalStrut(5));
            pnlcontainer.add(src3);
            getContentPane().add(pnlcontainer, BorderLayout.CENTER);
            setSize(new Dimension(300, 300));
            setVisible(true);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
        public static void main(String[] args)
            new TempSycnTable();
        class MyTable extends JTable
            public MyTable()
                super();
            public MyTable(int numRows, int numColumns)
                super(numRows, numColumns);
            public void columnMarginChanged(ChangeEvent event)
                final TableColumnModel eventModel = table1.getColumnModel();
                final TableColumnModel thisModel = getColumnModel();
                final int columnCount = eventModel.getColumnCount();
                for (int i = 0; i < columnCount; i++)
                    thisModel.getColumn(i).setWidth(eventModel.getColumn(i).getWidth());
                repaint();
    }thanks
    daya

Maybe you are looking for

  • Can I use icloud to find my iphone3g?

    HI, We just gave our daughter our old iPhone3G running 4.2   How can we set it up so we can log into icloud on a computer, and locate it using the Find my Iphone service?   I used to be able to do this when I used it and had a Mobile me account a yea

  • DSL connection gets slower than dial up at night

    For the last week my DSL connection has been getting really slow in the late afternoon and evening. It is fine in the morning. Also in the evening I have started getting error messages such as Request Timeout, The connection was reset while the page

  • ActiveX Container showing EXCEL Chart

    Hi, I´m trying to display an Excel97 Chart in a Labview 7.0 ActiveX Container. I´ve tried several things : 1. Creating an container that is connected to an Excel file. Then copying the chart I want to display to the file and saving it. --> problem :

  • Shipping point in S/O........

    I am actually not getting the drill down option of shipping point in sales oder and its showing as a incompletion log even though i have defined it and assigned it the plant and also determined the shipping point in the OVL2 but still i am facing the

  • CS5 Color Settings problem

    Hello, my issue is that now after switching to CS5 (from 4) whenever I work in Photoshop (only) the color settings look wrong on my screen. Everything has that yellowish/brownish tinge to it unless I enter "Proof Colors" and select "Monitor RGB" I ca