Listener implementation

Recently I decided to learn the GUI development in java and I am using the online tutorial avialble in Sun's website.
For the practice, i decided to implement a notepad for a foreign language.
This is what I am trying to do.
In the notepad the user types with the romanji and it gets automatically changed to the appropriate character of the language.
For example, lets say if i type 'ma' then it will show some character pronounuced 'ma' in other language.
I am using the JTextArea for typing. and this is how i plan to convert
to the language. I keep a key for the input method and the languages
corresponding unicode. So when a match is found that match is converted.
However, I am stuck with how to get those characters for conversion.
I tried using DocumentFilter, KeyListener but i found it little difficult to adjust the offset and lengths etc.
Is there a better way of doing it? and what kind of listeners is better?
If someone could some me the direction on how to achieve it, I would be grateful.
Thanks.

Hello,
sounds as if you would like to translate Latin characters (sound) to a Japanese script. Well, my first idea is just to switch the keyboard language (after installing the appropriate language support). In windows this can be quickly done in the systray.
If this is no solution, could you please be more specific as for
I tried using DocumentFilter, KeyListener but i found it little difficult to adjust the offset and lengths etc.I suppose there will be "Latin" (sub)strings of different lengths denoting one character of the target language. Then a buffering of the input is necessary.

Similar Messages

  • Extendable event/listener hierarchy - alternatives to double dispatch?

    In the course of a research project we are currently implementing an event based integration framework. We would like to offer an event hierarchy that should be extendable by the user through inheritance. Also, the user should be able to implement and register event listeners that offer a number of overloaded methods to handle different incoming event types, including the user defined ones. The event listeners are also inherited from an existing listener hierarchy. We want to allow for the user to implement handler methods for only selected subtrees of the event hierarchy, leaving the rest to the default listener implementation.
    We would like to avoid using reflection in order to keep the code portable to C++.
    In a first approach, we tried to solve this using double dispatch, which does not work due to the extendability of the hierarchy. The new event types would need to be added to the base listener interface.
    Currently, we are thinking about implementing a table based dispatching, that requires the user to register new event types before using them. But this might become a bit complicated, as we would like the dispatching to respect the inheritance hierarchy (but not use reflection).
    Since this will be an essential part of the framework, which can not easily be changed, we would be glad to hear your opinion what might be the best approach to this problem. Are there any new features in the Java language we have missed, that might allow to use double dispatch here (e.g. generics)? Are there any generic approaches to table based dispatching, that avoid reflection? Are we totally missing something else?
    Thanks a lot in advance,
    Jan

    Hi,
    to do so, you need to declare those fields in the form CREATE_HIERARCHY.
    For example, to add FLDATE node, you should do:
        ON CHANGE OF LS_SFLIGHT-CARRID.
          PERFORM ADD_CARRID_LINE USING    LS_SFLIGHT
                                  CHANGING L_CARRID_KEY.
        ENDON.
        ON CHANGE OF LS_SFLIGHT-CONNID.
          PERFORM ADD_CONNID_LINE USING    LS_SFLIGHT
                                           L_CARRID_KEY
                                  CHANGING L_CONNID_KEY.
        ENDON.
        ON CHANGE OF LS_SFLIGHT-FLDATE.
          PERFORM ADD_FLDATE_LINE USING    LS_SFLIGHT
                                           L_CONNID_KEY
                                  CHANGING L_FLDATE_KEY.
        ENDON.
        ON CHANGE OF LS_SFLIGHT-PRICE.
          PERFORM ADD_PRICE_LINE USING     LS_SFLIGHT
                                           L_FLDATE_KEY
                                  CHANGING L_PRICE_KEY.
        ENDON.
    and then create the new FORMS PERFORM ADD_PRICE_LINE and
    PERFORM ADD_FLDATE_LINE  by copy of the existent
    PERFORM ADD_CONNID_LINE and change the  L_NODE_TEXT in the form.
    I suposed you are new to ALV's, so i have a sugestion for you.
    Instead of  CL_GUI_ALV_TREE try to use some examples of CL_GUI_ALV_TREE_SIMPLE. It's much more simple to understand and to work with. For example Report BCALV_TREE_SIMPLE_DEMO.
    In this case, to add more nodes to the the you just need to add 3 lines of code in
    perform build_sort_table.
    Regards,

  • Listen for Layer Changes?

    Hi
    I am looking at subscribing to network events and working out event ids and things and so far haven't been able to work out this. Fairly simple question, hopefully the answer is just as simple.
    Can I subscribe to an event which lets lets me listen for any layer changes (in my iOS app)? The docs suggest any actionable event can be listened for, but I am yet to work out how to do this.
    Thanks.

    If you're using a web front end I don't see how that's possible unless you have persistent connections and "push" technology. HTTP is a request/response protocol, which doesn't lend itself to this problem.
    If you're writing a Swing client you have a bit more control.
    Maybe one way to do it would be to use JMS publish/subscribe. When a client connects to the server, it subscribes to the database change topic. Whenever one of the registers clients makes a database change, the DAO puts a message on the topic, which is then broadcast out to all registered subscribers. They can update themselves in their onMessage() listener implementation.
    Could be a network traffic nightmare if you have a lot of clients. And what about transactions? Will you make the topic and the database transaction a single unit of work?
    Might be more complicated than it's worth, but that seems to be your requirement. Not a trivial problem.
    %

  • Re: timeouts and ExternalConnection

    Tim,
    Use a Timer class of Framework library to have an explicit control over
    the connection. If the end-of-stream marker is not received within a
    specified interval of time, handle the situation.
    ExternalConnection class does not have any timeout feature of its own,
    but it would be a good idea to have one in future.
    Braja.
    \\\|///
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~oOOo- (_) -oOOo~~~~~~~
    BRAJA KISHORE CHATTARAJ
    Consultant, Analysts International Corporation.
    Work : Sphinx Pharmaceuticals (A division of Eli Lilly & Co.)
    (919) 419-5798
    Home : 1801, Williamsburg Rd., #41H, Durham, NC 27707.
    (919) 403-7296
    E-mail : [email protected]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Oooo~~~~~~~
    oooO ( )
    Please respond to Tim Kannenberg <[email protected]>
    Subject: timeouts and ExternalConnection
    I am working on a Forte service that uses a socket listener (implemented
    using the ExternalConnection class) to handle incoming messages. The
    messages vary in length, so the code for processing each connection
    loops until it finds an end-of-stream marker. If some client is
    erroneously sending messages without the marker, it'll loop forever. I
    would like the connection to time out if it doesn't receive any valid
    messages within a fixed length of time. Is there some functionality
    I've overlooked in ExternalConnection that would handle this? If not,
    does anybody have an example of a good way to implement it?
    Thanks in advance,
    Tim
    Tim Kannenberg
    Strong Capital Management
    Get Your Private, Free Email at http://www.hotmail.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    I've re-run the speed test. Here they are. Download speedachieved during the test was - 19915 Kbps For your connection, the acceptable range of speedsis 12000-29036 Kbps . Additional Information: IP Profile for your line is -29036 Kbps Upload speed achieved during the test was - 3819 Kbps Additional Information: Upstream Rate IP profile on your line is - 10000 Kbps Although the speed has dropped markedly since Saturday, its the dropouts, the VPN unable to connect and the slow respnses when trying to connect to websites quickly (DNS issue?) that is bothering me. It's not just one website that the problem is with, its any.

  • Timeouts and ExternalConnection

    I am working on a Forte service that uses a socket listener (implemented
    using the ExternalConnection class) to handle incoming messages. The
    messages vary in length, so the code for processing each connection
    loops until it finds an end-of-stream marker. If some client is
    erroneously sending messages without the marker, it'll loop forever. I
    would like the connection to time out if it doesn't receive any valid
    messages within a fixed length of time. Is there some functionality
    I've overlooked in ExternalConnection that would handle this? If not,
    does anybody have an example of a good way to implement it?
    Thanks in advance,
    Tim
    Tim Kannenberg
    Strong Capital Management
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    I've re-run the speed test. Here they are. Download speedachieved during the test was - 19915 Kbps For your connection, the acceptable range of speedsis 12000-29036 Kbps . Additional Information: IP Profile for your line is -29036 Kbps Upload speed achieved during the test was - 3819 Kbps Additional Information: Upstream Rate IP profile on your line is - 10000 Kbps Although the speed has dropped markedly since Saturday, its the dropouts, the VPN unable to connect and the slow respnses when trying to connect to websites quickly (DNS issue?) that is bothering me. It's not just one website that the problem is with, its any.

  • Can not add a picture to the JFrame from an ActionListener class

    As topic says, I can not add a picture to the JFrame from an ActionListener class which is a class inside the JFrame class.
    I have a Map.java class where I load an image with ImageIcon chosen with JFileChooser.
    I my window class (main class), I have following:
    class OpenImage_Listener implements ActionListener
         public void actionPerformed(ActionEvent e)
              int ans = open.showOpenDialog(MainProgram.this);     // "open" is the JFileChooser reference
              if(ans == open.APPROVE_OPTION)
                   File file = open.getSelectedFile();                    
                   MainProgram.this.add(new Map(file.getName()), BorderLayout.CENTER);     // this line does not work - it does not add the choosen picture on the window,
                            //but if I add the picture outside this listener class and inside the MainProgram constructor, the picture apperas, but then I cannot use the JFileChooser.
                            showMessageDialog(MainProgram.this, fil.getName() ,"It works", INFORMATION_MESSAGE);  // this popup works, and thereby the ActionListener also works.
    }So why can�t I add a picture to the window from the above listener class?

    The SSCCE:
    Ok, I think I solved it with the picture, but now I cannot add new components after adding the picture.
    Look at the comment in the actionlistener class:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Test extends JFrame{
         JButton b = new JButton("Open");
         JFileChooser jfc = new JFileChooser(System.getProperty("user.dir"));
         Picture pane;
         Test(){
              super("Main Program");
              setLayout(new BorderLayout());
              JPanel north = new JPanel();
              add(north, BorderLayout.NORTH);
              north.add(b);
              b.addActionListener(new Listener());
              setVisible(true);
              setSize(500,500);
              pane = new Picture("");
              add(pane, BorderLayout.CENTER);
         class Listener implements ActionListener {
              public void actionPerformed(ActionEvent e){
                   int ans = jfc.showOpenDialog(Test.this);
                   if(ans == jfc.APPROVE_OPTION)
                        File file = jfc.getSelectedFile();
                        Test.this.add(new Picture(file.getName()), BorderLayout.CENTER);
                        pane.add(new JButton("NEW BUTTON")); // Why does this button not appear on the window???
                        pane.repaint();
                        pane.revalidate();
         public static void main(String[] args)
              Test t = new Test();
    class Picture extends JPanel
         Image pic;
         String filename;
         Picture(String filename)
              setLayout(null);
              this.filename = filename;
              pic = Toolkit.getDefaultToolkit().getImage(filename);
            protected void paintComponent(Graphics g)
                super.paintComponent(g);
                g.drawImage(pic,0,0,getWidth(),getHeight(),this);
                revalidate();
    }

  • Problems with Graphics

    Hello,
    My instructor is wanting me to use the MVC paradigm. He was telling me that I should be able to put my deal() method in my Model.java. How can I access paintComponent() from the Model.java? If I put the deal() method in the View.java, then it is fine. I have been racking my brains all day long with this. Can anyone please take a look and let me know what I am doing wrong?
    Thanks,
    E
    //======================================
    //======================================
    //NewSolitaireController.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class NewSolitaireController extends JApplet
         //==========================================applet constructor
         public NewSolitaireController()
             this.setContentPane(new NewSolitaireView());
        }//===========================================end constructor
        //=================================================method main
        public static void main(String[] args)
            JFrame window = new JFrame();
            window.setTitle("Solitaire by EK");
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            window.setContentPane(new NewSolitaireView());
            window.pack();
            //window.setResizable(false);
                window.show();
        }//======================================================end main
    }//=========================================endclass SolitaireProject
    //================================================
    //================================================
    //NewSolitaireView.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    //import java.util.*;
    public class NewSolitaireView extends JPanel //implements MouseListener, MouseMotionListener
         //================================================================instance variables
         private GraphicsPanel boardDisplay_;
         private NewSolitaireModel     gameLogic_ = new NewSolitaireModel();
         private boolean gameOver_ = false;
         int clubPosition = 0;
         int diamondPosition = 0;
         int heartPosition = 0;
         int spadePosition = 0;
         private final int ACES_DIST_BETWEEN_CARDS = 87;
         private final int ACES_DIST_FROM_LEFT = 350;
         private final int ACES_DIST_FROM_TOP = 50;
         private final int ACES_MAX = 611;
         private final int PLAYCARDS_DIST_FROM_LEFT = 175;     
         private final int PLAYCARDS_DIST_FROM_TOP = 175;
         private final int PLAYCARDS_DIST_BETWEEN_COLS = 87;
         private final int PLAYCARDS_DIST_BETWEEN_ROWS_BACKS = 5;
         private final int PLAYCARDS_DIST_BETWEEN_ROWS_FACES = 30;
         private final int PLAYCARDS_MAX = 697;
         private final int PILE_DIST_FROM_LEFT = 50;
         private final int PILE_DIST_FROM_TOP = 50;
         private final int SHOWCARD_DIST_FROM_LEFT = 50;
         private final int SHOWCARD_DIST_FROM_TOP = 175;
         private static final int CARD_WIDTH = 77;                              
         private static final int CARD_HEIGHT = 110;
         private final int CARDS_PER_SUIT = 13;                                   //Suit limit
         private final int CARDS_PER_DECK = 52;                                   //Deck limit
         private int initialX = 0;                                                       //x coord - set from drag
         private int initialY = 0;                                                       //y coord - set from drag
         private int _dragFromX = 0;                                                  //Displacement inside image of mouse press
         private int _dragFromY = 0;                                                  //Displacement inside image of mouse press
         private Card[] _club = new Card[CARDS_PER_SUIT];               //Creates an array of clubs
         private Card[] _diamond = new Card[CARDS_PER_SUIT];          //Creates an array of diamonds
         private Card[] _heart = new Card[CARDS_PER_SUIT];               //Creates an array of hearts
         private Card[] _spade = new Card[CARDS_PER_SUIT];               //Creates an array of spades
         private Card[] _deckFront = new Card[CARDS_PER_DECK];          //Creates an array of cardfronts
         private Card[] _deckBack = new Card[CARDS_PER_DECK];          //Creates an array of cardbacks
         private Card _currentCard = null;                                        //Current draggable card
         //====================================================NewSolitaireView constructor
         public NewSolitaireView()
              String suitC = "c";                    //This is the character in the club image names that will be loaded                    
              String suitD = "d";                    //This is the character in the diamond image names that will be loaded
              String suitH = "h";                    //This is the character in the heart image names that will be loaded
              String suitS = "s";                    //This is the character in the spade image names that will be loaded
              String faces = "a23456789tjqk";     //These are the characters in the face image names that will be loaded
              int crdFrontPosition = 0;
              //=========================================================Read in the clubs
                for(int clubCounter = 0; clubCounter < suitC.length(); clubCounter ++)                    
                   for(int face = 0; face < faces.length(); face ++)                    
                        ImageIcon imgFront = new ImageIcon(faces.charAt(face) + suitC.charAt(clubCounter) + ".gif");
                        Image image = imgFront.getImage();
                        Image scaledImage = image.getScaledInstance(CARD_WIDTH, CARD_HEIGHT, Image.SCALE_FAST);
                        imgFront.setImage(scaledImage);
                        _club[clubPosition ++] = new Card(imgFront, initialX ++, initialY ++);
                        _deckFront[crdFrontPosition ++] = new Card(imgFront, initialX ++, initialY ++);     
              //=======================================================Read in the diamonds
                for(int diamondCounter = 0; diamondCounter < suitD.length(); diamondCounter ++)                    
                   for(int face = 0; face < faces.length(); face ++)                    
                        ImageIcon imgFront = new ImageIcon(faces.charAt(face) + suitD.charAt(diamondCounter) + ".gif");
                        Image image = imgFront.getImage();
                        Image scaledImage = image.getScaledInstance(CARD_WIDTH, CARD_HEIGHT, Image.SCALE_FAST);
                        imgFront.setImage(scaledImage);
                        _diamond[diamondPosition ++] = new Card (imgFront, initialX ++, initialY ++);
                        _deckFront[crdFrontPosition ++] = new Card (imgFront, initialX ++, initialY ++);
              //=======================================================Read in the hearts
                for(int heartCounter = 0; heartCounter < suitH.length(); heartCounter ++)                    
                   for(int face = 0; face < faces.length(); face ++)                    
                        ImageIcon imgFront = new ImageIcon(faces.charAt(face) + suitH.charAt(heartCounter) + ".gif");
                        Image image = imgFront.getImage();
                        Image scaledImage = image.getScaledInstance(CARD_WIDTH, CARD_HEIGHT, Image.SCALE_FAST);
                        imgFront.setImage(scaledImage);
                        _heart[heartPosition ++] = new Card (imgFront, initialX ++, initialY ++);
                        _deckFront[crdFrontPosition ++] = new Card (imgFront, initialX ++, initialY ++);
              //==========================================================Read in the spades
                for(int spadeCounter = 0; spadeCounter < suitS.length(); spadeCounter ++)                    
                   for(int face = 0; face < faces.length(); face ++)                    
                        ImageIcon imgFront = new ImageIcon(faces.charAt(face) + suitS.charAt(spadeCounter) + ".gif");
                        Image image = imgFront.getImage();
                        Image scaledImage = image.getScaledInstance(CARD_WIDTH, CARD_HEIGHT, Image.SCALE_FAST);
                        imgFront.setImage(scaledImage);
                        _spade[spadePosition ++] = new Card (imgFront, initialX ++, initialY ++);
                        _deckFront[crdFrontPosition ++] = new Card (imgFront, initialX ++, initialY ++);
              int crdBackPosition = 0;
              //Load the card back image into an array of 52 cardbacks and resize each cardback
              for(int crdBack = 0; crdBack < CARDS_PER_DECK; crdBack ++)
                   ImageIcon imgBack = new ImageIcon("b.gif");
                   Image image = imgBack.getImage();
                   Image scaledImage = image.getScaledInstance(CARD_WIDTH, CARD_HEIGHT, Image.SCALE_FAST);
                   imgBack.setImage(scaledImage);
                   _deckBack[crdBackPosition ++]     = new Card (imgBack, initialX ++, initialY ++);
              //============================================================Create  buttons
          JButton newGameButton = new JButton("New Game");
              JButton exitButton = new JButton("Exit");
              //========================================================Create controlPanel
          JPanel controlPanel = new JPanel();
              controlPanel.add(newGameButton);
              controlPanel.add(exitButton);
              //=======================================================Create GraphicsPanel
              boardDisplay_ = new GraphicsPanel();
              //======================================Set the layout and add the components
              this.add(controlPanel);
              this.add(boardDisplay_);
              //===================================================Add listeners to buttons
              exitButton.addActionListener(new ExitAction());     
              newGameButton.addActionListener(new NewGameAction());                    
         }//==============================================end NewSolitaireView constructor
         class GraphicsPanel extends JPanel //implements MouseListener
              //===================================class GraphicsPanel constructor
              public GraphicsPanel()
                   //Initialize graphics
                   this.setPreferredSize(new Dimension(850, 500));
                   this.setBackground(Color.white);     
               //this.addMouseListener(this);     
              }//=======================================end GraphicsPanel constructor
              //=================================================method paintComponent     
              public void paintComponent(Graphics g)
                   super.paintComponent(g);                                   //Required for background.
                   //update(g); 
                   g.drawRect(PILE_DIST_FROM_LEFT, PILE_DIST_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
                   g.drawRect(SHOWCARD_DIST_FROM_LEFT, SHOWCARD_DIST_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
                   for(int position1 = ACES_DIST_FROM_LEFT; position1 <= ACES_MAX; position1 += ACES_DIST_BETWEEN_CARDS)
                        g.drawRect(position1, ACES_DIST_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);
                   for(int position2 = PLAYCARDS_DIST_FROM_LEFT; position2 <= PLAYCARDS_MAX; position2 += PLAYCARDS_DIST_BETWEEN_COLS)
                        g.drawRect(position2, PLAYCARDS_DIST_FROM_TOP, CARD_WIDTH, CARD_HEIGHT);          
                   //This is to test the card images, but they are not working
                   for(int k = 0; k < 51; k ++)
                        Card c = _deckFront[k];
                        c.image.paintIcon(this, g, c.x, c.y);
              }//=====================================================end paintComponent method
         }//========================================================end class GraphicsPanel
         //======================================================================class Card
         class Card
              javax.swing.ImageIcon image;
              int x;
              int y;
              public Card(javax.swing.ImageIcon image, int x, int y)
                   this.image = image;
                   this.x = x;
                   this.y = y;
         }//=================================================================end class Card
         //===========================================================inner class ExitAction
         class ExitAction implements ActionListener
              public void actionPerformed(ActionEvent e)
                   System.exit(0);
              }//==========================================================end actionPerformed
         }//=======================================================end inner class ExitAction
         //=========================================================inner class NewGameAction
         class NewGameAction implements ActionListener
              public void actionPerformed(ActionEvent e)
                   gameLogic_.shuffle();
                   //gameLogic_.deal(Graphics g);
                   repaint();
              }//===========================================================end actionPerformed
         }//=====================================================end inner class NewGameAction
    }//===========================================================end class NewSolitaireView
    //==========================================
    //==========================================
    //NewSolitaireModel.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    //import javax.swing.ImageIcon.*;
    //import java.awt.Image.*;
    //import java.awt.Graphics.*;
    class NewSolitaireModel
         private NewSolitaireView     gameGUI_ = new NewSolitaireView();
         private final int ACES_DIST_BETWEEN_CARDS = 87;
         private final int ACES_DIST_FROM_LEFT = 350;
         private final int ACES_DIST_FROM_TOP = 50;
         private final int ACES_MAX = 611;
         private final int PLAYCARDS_DIST_FROM_LEFT = 175;     
         private final int PLAYCARDS_DIST_FROM_TOP = 175;
         private final int PLAYCARDS_DIST_BETWEEN_COLS = 87;
         private final int PLAYCARDS_DIST_BETWEEN_ROWS_BACKS = 5;
         private final int PLAYCARDS_DIST_BETWEEN_ROWS_FACES = 30;
         private final int PLAYCARDS_MAX = 697;
         private final int PILE_DIST_FROM_LEFT = 50;
         private final int PILE_DIST_FROM_TOP = 50;
         private final int SHOWCARD_DIST_FROM_LEFT = 50;
         private final int SHOWCARD_DIST_FROM_TOP = 175;     
         private final int FIRST_CARD_AFTER_DEAL = 29;
         private final int CARDS_PER_DECK = 52;                                   //Deck limit
         private Card[] _deckFront = new Card[CARDS_PER_DECK];          //Creates an array of cardfronts
         private Card[] _deckBack = new Card[CARDS_PER_DECK];          //Creates an array of cardbacks
         //===============================================NewSolitaireModel constructor
         public NewSolitaireModel()
              shuffle();
              //repaint();
         }//==============================================end NewSolitaireModel constructor
         public void deal(Graphics g)
              //================================================Deal the cards for game play
              //=========This is done initially and everytime the new game button is pressed
              //===========================================Uses paintComponent for paintIcon
              //========================Deal the first row of cards (top 7), first 1 face up
              int crd1 = 1;
              int col1 = PLAYCARDS_DIST_FROM_LEFT;
              int fromTop1 = PLAYCARDS_DIST_FROM_TOP;
              Card df = _deckFront[crd1];
              ImageIcon icon;
              //icon.paintIcon(df, g, col1, fromTop1);
              //=========================================================next 6 face down
              crd1 = 2;
              col1 = col1 + PLAYCARDS_DIST_BETWEEN_COLS;
              for(int count = 0; count < 6; count ++)
                   Card db = _deckBack[crd1];
                   //image.paintIcon(db, g, col1, fromTop1);
                   crd1 ++;
                   col1 += PLAYCARDS_DIST_BETWEEN_COLS;
              //====================Deal the second row of cards (next 6), first 1 face up
              int crd2 = 8;
              int col2 = 262;
              int fromTop2 = fromTop1 + PLAYCARDS_DIST_BETWEEN_ROWS_BACKS;
              df = _deckFront[crd2];
              //df.image.paintIcon(this, g, col2, fromTop2);
              //==========================================================next 5 face down
              crd2 = 9;
              col2 = col2 + PLAYCARDS_DIST_BETWEEN_COLS;
              for(int count = 0; count < 5; count ++)
                   Card db = _deckBack[crd2];
                   //db.image.paintIcon(this, g, col2, fromTop2);
                   crd2 ++;
                   col2 += PLAYCARDS_DIST_BETWEEN_COLS;
              //======================Deal the third row of cards (next 5), first 1 face up
              int crd3 = 14;
              int col3 = 349;
              int fromTop3 = fromTop2 + PLAYCARDS_DIST_BETWEEN_ROWS_BACKS;
              df = _deckFront[crd3];
              //df.image.paintIcon(this, g, col3, fromTop3);
              //==========================================================next 4 face down
              crd3 = 15;
              col3 = col3 + PLAYCARDS_DIST_BETWEEN_COLS;
              for(int count = 0; count < 4; count ++)
                   Card db = _deckBack[crd3];
                   //db.image.paintIcon(this, g, col3, fromTop3);
                   crd3 ++;
                   col3 += PLAYCARDS_DIST_BETWEEN_COLS;
              //===================Deal the fourth row of cards (next 4), first 1 face up 
              int crd4 = 19;
              int col4 = 436;
              int fromTop4 = fromTop3 + PLAYCARDS_DIST_BETWEEN_ROWS_BACKS;
              df = _deckFront[crd4];
              //df.image.paintIcon(this, g, col4, fromTop4);
              //========================================================next 3 face down
              crd4 = 20;
              col4 = col4 + PLAYCARDS_DIST_BETWEEN_COLS;
              for(int count = 0; count < 3; count ++)
                   Card db = _deckBack[crd4];
                   //db.image.paintIcon(this, g, col4, fromTop4);
                   crd4 ++;
                   col4 += PLAYCARDS_DIST_BETWEEN_COLS;
              //====================Deal the fifth row of cards (next 3), first 1 face up
              int crd5 = 23;
              int col5 = 523;
              int fromTop5 = fromTop4 + PLAYCARDS_DIST_BETWEEN_ROWS_BACKS;
              df = _deckFront[crd5];
              //df.image.paintIcon(this, g, col5, fromTop5);
              //==========================================================next 2 face down
              crd5 = 24;
              col5 = col5 + PLAYCARDS_DIST_BETWEEN_COLS;
              for(int count = 0; count < 2; count ++)
                   Card db = _deckBack[crd5];
                   //db.image.paintIcon(this, g, col5, fromTop5);
                   crd5 ++;
                   col5 += PLAYCARDS_DIST_BETWEEN_COLS;
              //====================Deal the sixth row of cards (next 2), first 1 face up
              int crd6 = 26;
              int col6 = 610;
              int fromTop6 = fromTop5 + PLAYCARDS_DIST_BETWEEN_ROWS_BACKS;
              df = _deckFront[crd6];
              //df.image.paintIcon(this, g, col6, fromTop6);
              //==================================================second 1 face down
              crd6 = 27;
              col6 = col6 + PLAYCARDS_DIST_BETWEEN_COLS;
              for(int count = 0; count < 1; count ++)
                   Card db = _deckBack[crd6];
                   //db.image.paintIcon(this, g, col6, fromTop6);
                   crd6 ++;
                   col6 += PLAYCARDS_DIST_BETWEEN_COLS;
              //====================Deal the seventh row of cards (next 1) face up           
              int crd7 = 28;
              int col7 = 697;
              int fromTop7 = fromTop6 + PLAYCARDS_DIST_BETWEEN_ROWS_BACKS;
              df = _deckFront[crd7];
              //df.image.paintIcon(this, g, col7, fromTop7);
              //=============Put the undealt cards in the upper left stack to use for game play
              for(int playCard = FIRST_CARD_AFTER_DEAL; playCard < CARDS_PER_DECK; playCard ++)
                   Card db = _deckBack[playCard];
                   //db.image.paintIcon(this, g, PILE_DIST_FROM_LEFT, PILE_DIST_FROM_TOP);
         }//============================================================end method deal
         //=============================================================method displayImage
         private void displayImage(int k)
              //Graphics g = getGraphics();
         //=================================================================method shuffle
         public void shuffle()
              Random rgen = new Random(); // Random number generator
              // Shuffle by exchanging each element randomly
              for (int i = 0; i < CARDS_PER_DECK; i ++)
                   int randomPosition = rgen.nextInt(CARDS_PER_DECK);
                   Card temp = _deckFront;
                   _deckFront[i] = _deckFront[randomPosition];
                   _deckFront[randomPosition] = temp;
         }//===============================================================end method shuffle               
    }//=============================================end class NewSolitaireModel

    I would have deal() in the model. I think that's where it belongs, because deal() should probably be distributing the cards in some random manner into some container (abstractly speaking). The view can then get the cards from that container when it's notified that the deal() happened...
    public class DeckModel {
       private List listeners = new ArrayList();
       private List available = new ArrayList();
       private List played = new ArrayList();
       public void deal() {
          // take all cards, shuffle them, put them into "available"
          fireCardsShuffled();// listeners can then get from available and display them however
       public void play(Card c) {
          played.add(c);
          available.remove(c);
          fireCardsPlayed(c);
       public void fireCardsPlayed(Card c) {
          // notifiy listeners
          for(int x = 0; x < listeners.size(); x++) {
             ((DeckListener)listeners.get(x)).cardPlayed(new DeckEvent(this, c));
       public void fireCardsShuffled() {
          // notifiy listeners
          for(int x = 0; x < listeners.size(); x++) {
             ((DeckListener)listeners.get(x)).cardsShuffled(new DeckEvent(this, null));
       public void addDeckListener(DeckListener dl) {
           listeners.add(dl); // maybe have a remove method.
    // deck listener, implemented by the view.
    public interface DeckListener {
       public void cardsShuffled(DeckEvent de);
       public void cardPlayed(DeckEvent de);
    }Something along those lines.

  • Questions on events in a multi-class GUI

    I have a GUI application that is constructed as follows:
    1. Main Class - Actually creates the JFrame, contains main method, etc.
    2. MenuBar Class - Constructor creates a new JMenuBar structure and populates it with various JMenus and JMenuItems. A new instance of this class is instantiated in the Main Class to be used in the setMenuBar() method.
    3. ContentPane Class - Constructor creates a vertical JSplitPane. A new instance of this class is instantiated in the Main Class to be used in the setContentPane() method.
    4. BottomPane Class - Constructor creates a JPanel and populates it with various stuff. A new instance of this class is instantiated in the Content Pane Class to be used as the bottom pane in the vertical JSplitPane.
    5. TopPane Class - Constructor creates a horizontal JSplitPane and populates the left pane with a JScrollPane containing a JList. A new instance of this class is instantiated in the Content Pane Class to be used as the top pane in the vertical JSplitPane.
    6. TabbedPane Class - Constructor creates a JTabbedPane. A new instance of this class is instantiated in the Top Pane Class to be used as the right pane in the horizontal JSplitPane.
    7. DisplayPane Class - Constructor creates a JPanel. A new instance of this class is instantiated in the Tabbed Pane Class as the first tab. The user has the ability to click at points in this pane and a dialog box will pop up prompting the user for a string. Once the user enters something and clicks "OK", an instance of a custom Java2D component that I've created will be added to the DisplayPane where the user had clicked, with the string the user inputted being used as its name. The user can then drag the component around, enter a key combination to display all the names, etc.
    8. Custom Java2D Component Class - Constructor creates my custom Java2D component. Instances of this are added to the Display Pane Class, as I have described.
    Now, originally, I was going to ask "How do you work with events between these multiple classes?" but I have solved half of that problem myself with the following class:
    9. Listener Class - A new instance of this class is declared in the constructor of the Main Class, and is thus passed down through the GUI hierachy via the constructors of the various classes. I then use the addActionListener() method on various components in the other classes, and then the Listener Class can capture an event using the getActionCommand() method to figure out what fired the event.
    So that covers the "How do I capture events in multiple classes?" question. Now I'm left with "How do I affect changes on those classes based on events?"
    For example: In my MenuBar class, I have a "Save" menu item. When this is clicked, I want to declare a new JFileChooser and then use the showSaveDialog() method, which throws up a dialog for saving a file. The problem is, the showSaveDialog() method takes a Component which is the parent frame. Obviously the Listener Class is not a frame. I want to use the Main Class as the parent frame. How would I do this sort of thing?
    Another example: In my MenuBar class, I have a "New" menu item. For now, I want this to invoke a method in the DisplayPane Class that erases all of my custom Java2D components that have been made, thus giving the user a clean slate. How would I give my Listener Class access to that method?
    A final example: Every time the user adds one of my custom Java2D components, I want that component's name to be added to the JList that is in my TopPane class. Vice versa with deleting a component: its name should be removed from the JList. How would I listen for new components being added? (A change listener on the pane? One on the ArrayList<> that contains all of the components? Something else?) And, of course, how would I give the Listener Class the ability to change the contents of the JList?
    One idea I've come up with so far is to instantiate a new instance of each of my GUI classes in the Listener class, but that doesn't really make much sense. Wouldn't those be new instances that are totally separate from the instances the rest of my program is using? Another thought is to make the Listener Class an internal class inside the Main Class so that it can use the accessor methods of the GUI classes, but a.) I would like to avoid stuffing everything in one class and b.) this brings up the question of "How would I get an accessor method that is in a class that is two or three deep in the hierarchy?" (.getSomething().getSomethingInsideThat().getSomethingInsideTheInsideThing()?)
    Help with answering any or all of my questions would be much appreciated.

    Hrm. At the moment, for my first attempt, I'm doing something similar, it just strikes me as quite unwieldy.
    Start of Listener class, with method for setting what it listens to. (I can't use a constructor for this because the MenuBar and the ContentPane take an instance of
    this Listener class in through their constructors. You can't pass the Listener in through their constructors while simultaneously passing them in through this
    Listener's constructor. That would be an endless cycle of failure. So I just instantiate an instance of this Listener class, then pass it in through the MenuBar and
    ContentPane constructors when I instantiate instances of them, and then call this setListensTo() method.)
    public class Listener implements ActionListener
      private MenuBar menuBar;
      private ContentPane contentPane;
      public void setListensTo(MenuBar menuBar, ContentPane contentPane)
        this.menuBar = menuBar;
        this.contentPane = contentPane;
      }The part of my actionPerformed() method that does some rudimentary saving, which I will make more complicated later:
    else if (evt.getActionCommand() == "saveMenuItem")
      JFileChooser fileChooser = new JFileChooser();
      int returnVal = fileChooser.showSaveDialog(menuBar.getTopLevelAncestor());
      if (returnVal == JFileChooser.APPROVE_OPTION)
        File file = fileChooser.getSelectedFile();
        ArrayList<Node> nodes = contentPaneClass.getTopPaneClass().getTabbedPane().getDisplayPane().getNodes();
        try
          BufferedWriter out = new BufferedWriter(new FileWriter(file));
          for (int i = 0; i < nodes.size(); i++)
            Node node = nodes.get(i);
            out.write(node.getIndex() + "," + node.getXPos() + "," + node.getYPos() + "," + node.getName());
            out.newLine();
          out.close();
        catch (IOException e)
          //To be added                    
    }That part that seems unwieldy is the
    ArrayList<Node> nodes = contentPaneClass.getTopPaneClass().getTabbedPane().getDisplayPane().getNodes();The reason I'm using a separate Listener class is because if I put, say, the actions for the MenuBar in the MenuBar class, and then want to save stuff in the JPanel
    at the bottom of the hierachy, I would have to go up from the MenuBar into the JFrame, and then back down the hierachy to the JPanel, and vice versa. Kind of like
    walking up a hill and then down the other side. I imagine this would be even more unwieldy than what I'm doing now.
    On the plus side, I am making progress, so thanks all for the help so far!

  • Login issue in OIM11g due to oim credsmap error

    We have OIM 11gR2PS1 installed on unix box. We have AD connector 11.1.1.5.0 installed on it .Also,peoplesoft recon connector PSFT_ER-11.1.1.5.0 is installed
    In our scenario,we have webservice code in which using recon event we are creating users in OIM environment
    This is hosted on same OIM server unix box.Inside webservice code we have refred oimclient.jar file to work with OIM APIs and Recon Service class.
    When i tested webservice for first time it was unable to load OIM API classes as it was unable to find oimclient.jar in classpath.
    So to resolve this issue i kept oimclient.jar in location- "WL_HOME/server/lib/"  and also added following entry in setDomainEnv.sh to load oimclient.jar explicitly in classpath
    CLASSPATH="WL_HOME/server/lib/oimclient.jar:${CLASSPATH}"
    export CLASSPATH
    and made entry in system-jazn-data.xml present in DOMAIN_HOME//config/fmwconfig/ as :
    <grant>
                <grantee>
                    <codesource>
                        <url>file:${domain.home}/servers/oim_server1/stage/*</url>
                    </codesource>
                </grantee>
                <permissions>
       <permission>
                   <class>oracle.security.jps.service.credstore.CredentialAccessPermission</class>
                         <name>context=SYSTEM,mapName=oim,keyName=*</name>
                         <actions>read,write</actions>
        </permission>
                </permissions>
            </grant>
    After this change, webservice was working as expected and OIM related things were working fine.
    But,when we tried to run schedule task "Active Directory Group Lookup Recon" for AD, we are getting error message as :
    java.lang.LinkageError: loader constraint violation: loader (instance of com/thortech/xl/dataobj/tcADPClassLoader) previously initiated loading for a different type with name "com/thortech/xl/dataaccess/tcDataProvider"
    So,to resolve this AD schedule task issue,we rolled back changes made for webservice in setDomainEnv.sh and system-jazn-data.xml file
    and removed explicit classpath entry line of oimclient.jar from  setDomainEnv.sh
    But after restrating all admin and managed servers,we are currently facing issue in logging into OIM idenity/syadmin or design console with xelsyadm credentials
    we have never made any changes of password for xelsyadm account or not made any change in any authenticatorproviders in weblogic console
    we tried everything form reverting all changes to original setup without webservice or peoplesoft listener implementation
    removed all explicit classpath entries or grant entry for oim credsmap from system-jazn-data.xml.
    But still same issue persists
    Any helpful suggestion is appreciated on this ASAP.
    issue logs are:
    TaskFlow Registration: TaskFlowDeployerThread.registerTaskFlowWithTask - Error while setting task display, this can happen with app loading issue, trying to load for 2
    <Nov 11, 2013 11:24:20 PM EST> <Warning> <oracle.soa.services.workflow.worklist> <BEA-000000> <<.> Error while setting task display, this can happen with app loading issue, trying to load for 2>
    <Nov 11, 2013 11:24:24 PM EST> <Error> <XELLERATE.ACCOUNTMANAGEMENT> <BEA-000000> <Class/Method: tcDefaultDBEncryptionImpl/initKeyStore encounter some problems: access denied ("oracle.security.jps.service.credstore.CredentialAccessPermission" "context=SYSTEM,mapName=oim,keyName=.xldatabasekey" "read")
    java.security.AccessControlException: access denied ("oracle.security.jps.service.credstore.CredentialAccessPermission" "context=SYSTEM,mapName=oim,keyName=.xldatabasekey" "read")
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
      at java.security.AccessController.checkPermission(AccessController.java:559)
      at oracle.security.jps.util.JpsAuth$AuthorizationMechanism$3.checkPermission(JpsAuth.java:458)
      at oracle.security.jps.util.JpsAuth.checkPermission(JpsAuth.java:518)
      at oracle.security.jps.util.JpsAuth.checkPermission(JpsAuth.java:544)
      at oracle.security.jps.internal.credstore.util.CsfUtil.checkPermission(CsfUtil.java:643)
      at oracle.security.jps.internal.credstore.ldap.LdapCredentialStore.containsCredential(LdapCredentialStore.java:214)
      at oracle.iam.platform.utils.config.OIMPrivilegedExceptionAction.run(CSFCredentialProvider.java:236)
      at java.security.AccessController.doPrivileged(Native Method)
      at oracle.iam.platform.utils.config.CSFCredentialProvider.getPassword(CSFCredentialProvider.java:79)
      at oracle.iam.platform.utils.config.standalone.StandAloneCryptoConfig.getPassword(StandAloneCryptoConfig.java:76)
      at com.thortech.xl.crypto.tcDefaultDBEncryptionImpl.initKeyStore(tcDefaultDBEncryptionImpl.java:67)
      at com.thortech.xl.crypto.tcDefaultDBEncryptionImpl.getCipher(tcDefaultDBEncryptionImpl.java:96)
      at com.thortech.xl.crypto.tcDefaultDBEncryptionImpl.encrypt(tcDefaultDBEncryptionImpl.java:193)
      at com.thortech.xl.crypto.tcCryptoUtil.encrypt(tcCryptoUtil.java:118)
      at com.thortech.xl.crypto.tcCryptoUtil.encrypt(tcCryptoUtil.java:275)
      at oracle.iam.platform.auth.impl.Authenticator.encrypt(Authenticator.java:188)
      at oracle.iam.platform.auth.impl.Authenticator.authenticateWithPassword(Authenticator.java:161)
      at oracle.iam.platform.auth.impl.Authenticator.authenticate(Authenticator.java:134)
      at oracle.iam.platform.auth.providers.wls.OIMAuthLoginModule.login(OIMAuthLoginModule.java:46)
      at com.bea.common.security.internal.service.LoginModuleWrapper$1.run(LoginModuleWrapper.java:110)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.bea.common.security.internal.service.LoginModuleWrapper.login(LoginModuleWrapper.java:106)
      at sun.reflect.GeneratedMethodAccessor951.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:784)
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203)
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:698)
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:696)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:695)
      at javax.security.auth.login.LoginContext.login(LoginContext.java:594)
      at com.bea.common.security.internal.service.JAASLoginServiceImpl.login(JAASLoginServiceImpl.java:113)
      at sun.reflect.GeneratedMethodAccessor961.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
      at com.sun.proxy.$Proxy16.login(Unknown Source)
      at weblogic.security.service.internal.WLSJAASLoginServiceImpl$ServiceImpl.login(WLSJAASLoginServiceImpl.java:89)
      at com.bea.common.security.internal.service.JAASAuthenticationServiceImpl.authenticate(JAASAuthenticationServiceImpl.java:82)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
      at com.sun.proxy.$Proxy34.authenticate(Unknown Source)
      at weblogic.security.service.WLSJAASAuthenticationServiceWrapper.authenticate(WLSJAASAuthenticationServiceWrapper.java:40)
      at weblogic.security.service.PrincipalAuthenticator.authenticate(PrincipalAuthenticator.java:338)
      at weblogic.servlet.security.internal.SecurityModule.checkAuthenticate(SecurityModule.java:252)
      at weblogic.servlet.security.ServletAuthentication.login(ServletAuthentication.java:466)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at oracle.idm.common.login.SignInBean.handleWeblogicAuthn(SignInBean.java:131)
      at oracle.idm.common.login.SignInBean.doLogin(SignInBean.java:97)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
      at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
      at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)
      at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    >
    <Nov 11, 2013 11:24:24 PM EST> <Error> <OIM Authenticator> <BEA-000000> <Error encrypting password>
    java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at oracle.idm.common.login.SignInBean.handleWeblogicAuthn(SignInBean.java:131)
      at oracle.idm.common.login.SignInBean.doLogin(SignInBean.java:97)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Caused by: javax.security.auth.login.FailedLoginException: [Security:090304]Authentication Failed: User xelsysadm javax.security.auth.login.FailedLoginException: [Security:090302]Authentication Failed: User xelsysadm denied
      at weblogic.security.providers.authentication.LDAPAtnLoginModuleImpl.login(LDAPAtnLoginModuleImpl.java:261)
      at com.bea.common.security.internal.service.LoginModuleWrapper$1.run(LoginModuleWrapper.java:110)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.bea.common.security.internal.service.LoginModuleWrapper.login(LoginModuleWrapper.java:106)
      at sun.reflect.GeneratedMethodAccessor951.invoke(Unknown Source)
      at com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
      at com.sun.proxy.$Proxy34.authenticate(Unknown Source)
      at weblogic.security.service.WLSJAASAuthenticationServiceWrapper.authenticate(WLSJAASAuthenticationServiceWrapper.java:40)
      at weblogic.security.service.PrincipalAuthenticator.authenticate(PrincipalAuthenticator.java:338)
      at weblogic.servlet.security.internal.SecurityModule.checkAuthenticate(SecurityModule.java:252)
      at weblogic.servlet.security.ServletAuthentication.login(ServletAuthentication.java:466)
      ... 72 more

    Hi All,
    I have tried out option of adding authwl.conf in java argument as mentioned. But,still same issue persists. I think it will be same whether we refer authwl.conf file from OIM_ORACLE_HOME/server/config or OIM_ORACLE_HOME/designconsole/config/ location.
    We havent made any changes in USR table for xelsysadm user
    Even system-jazn-data.xml is intact.
    Actually,when i removed following classpath entry from setDomainEnv.sh file
    CLASSPATH="WL_HOME/server/lib/oimclient.jar:${CLASSPATH}"
    export CLASSPATH
    Its working fine and i am not facing any login issue in OIM console.Also the Active Directory connector scheduled task are running fine without giving earlier error whic is becaus of explicit classpath addition in setDomainEnv.sh.This error was
    java.lang.LinkageError: loader constraint violation: loader (instance of com/thortech/xl/dataobj/tcADPClassLoader) previously initiated loading for a different type with name "com/thortech/xl/dataaccess/tcDataProvider" .
    This error was arising since i have explicitly mentioned oimclient.jar again in classpath and as OIM server also will load it at OIM server startup time. So it was finding two instance of tcDataProvider and was not able to decide to refer to which one of them.
    But, I have to refer oimclient.jar in my webservice code to work.If we dont add classpath entry explicitly for oimclient.jar then it will throw error..that it is unable to load OIMClient class.
    Webservice is deployed in OIM serveer . Is there any other way by which i can refer oimclient class in webservice code without causing this classpath conflict issue. ?
    Also.is it correctthat for first time when we load Classpath explicitly like i did in my scenario,then it will always try to refer same classpath for that jar always.
    For ex: in my env i made changes in setDomainEnv.sh and modifed classpath enrty as :
    CLASSPATH="${OIM_ORACLE_HOME}/server/client/oimclient.jar:${CLASSPATH}"
    export CLASSPATH
    but this time it will start throwin the exception as :
    <Nov 11, 2013 11:24:24 PM EST> <Error> <XELLERATE.ACCOUNTMANAGEMENT> <BEA-000000> <Class/Method: tcDefaultDBEncryptionImpl/initKeyStore encounter some problems: access denied ("oracle.security.jps.service.credstore.CredentialAccessPermission" "context=SYSTEM,mapName=oim,keyName=.xldatabasekey" "read")
    java.security.AccessControlException: access denied ("oracle.security.jps.service.credstore.CredentialAccessPermission" "context=SYSTEM,mapName=oim,keyName=.xldatabasekey" "read")
    Do i need to reinstall OIM setup to resolve this issue or is there any other way to refer oimclient.jar in my webservice code deployed in OIM env ?
    Please suggest.
    Thanks,
    RPB

  • How to keep filename in textfield when filter is changed in a filechooser

    Hi, guys,
    I met a problem to keep filename in textfield when filter is changed in a filechooser
    for example, a JFileChooser has two filters
    *.jpg
    *.png
    Before I open JFileChooser, I used setSelectedFile(File) to set "aaa.jpg" as default name in textfield.
    when I change the filter to "*.png, ", I want to change the text in textfield to "aaa.png", Actually, I used setSelectedFile(File), If there is an existed file named "aaa.png", this file will be selected on fileView, but the name will not be shown on the textfield. Anybody has ideas?
    Thanks in advanced.

    I really thank you for your answer, but it seems you misunderstand what I said because of my poor english..
    what I said is:
    after you open the filechooser, the filechooser has a combobox to choose file filter and a field to show filename.
    what I want is:
    when you open the filechooser, initial name in field is "test. jpg"
    change filter, "test.jpg" will be change to "test.gif" in the field.
    I don't want to close the filechooser.
    That's why I used a listener to listen JFileChooser.FILE_FILTER_CHANGED_PROPERTY event.
    and I modified your codes
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.io.File;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.filechooser.FileFilter;
    class Testing extends JFrame {
         String defaultFile = "";
         JFileChooser fc = new JFileChooser(".");
         ExtensionFileFilter eff;
         public Testing() {
              setLocation(200, 300);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              JButton btnShow = new JButton("Show Chooser");
              JPanel p = new JPanel(new GridLayout(1, 2));
              p.add(btnShow);
              getContentPane().add(p, BorderLayout.SOUTH);
              pack();
              fc.addPropertyChangeListener(new Listener(fc));
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fc.setAcceptAllFileFilterUsed(false);
              fc.setFileFilter(new ExtensionFileFilter(".gif"));
              fc.addChoosableFileFilter(new ExtensionFileFilter(".jpg"));
              defaultFile = defaultFile.equals("") ? "Test.jpg" : "Test.gif";
              fc.setSelectedFile(new java.io.File(defaultFile));
              btnShow.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent ae) {
                        fc.showOpenDialog(Testing.this);
         public static void main(String[] args) {
              new Testing().setVisible(true);
    class ExtensionFileFilter extends FileFilter {
         String fileTypes = "";
         java.util.List extensions = new java.util.ArrayList();
         public ExtensionFileFilter() {
         public ExtensionFileFilter(String ft) {
              fileTypes = ft;
         public String getDescription() {
              return fileTypes;
         public boolean accept(File f) {
              if(f.isDirectory()) return true;
              if (f.getName().endsWith(fileTypes)) {
                   return true;
              return false;
    class Listener implements PropertyChangeListener {
        JFileChooser fChooser = null;
        Listener(JFileChooser fChooser) {
            this.fChooser = fChooser;
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
                 FileFilter fileFilter = (FileFilter) evt.getNewValue();
                if (fileFilter != null) {
                    String fileName = null;
                    if (fileFilter.getDescription().equals(".jpg")) {
                        fileName = "Test.jpg";
                    } else if (fileFilter.getDescription().equals(".gif")){
                         fileName = "Test.gif";
                    String newFileName = "C:\\" + fileName;
                    fChooser.setSelectedFile(new File(newFileName));
    }Thanks again.
    Message was edited by:
    JadeSword

  • Issue in bursting through email BIP

    Hi,
    I have a XML data (employee.xml) file like:
    <DATA>
         <DEPTS>
              <DEPT>
                   <EMPLOYEES>
                        <EMPLOYEE>
                             <EMPNO>7369</EMPNO>
                             <ENAME>SMITH</ENAME>
                             <JOB>CLERK</JOB>
                             <MGR>7902</MGR>
                             <HIREDATE>1980-12-17T00:00:00.000-08:00</HIREDATE>
                             <SAL>800</SAL>
                             <DEPTNO>20</DEPTNO>
                             <EMAIL>[email protected]</EMAIL>
                        </EMPLOYEE>
                        <EMPLOYEE>
                             <EMPNO>7566</EMPNO>
                             <ENAME>JONES</ENAME>
                             <JOB>MANAGER</JOB>
                             <MGR>7839</MGR>
                             <HIREDATE>1981-04-02T00:00:00.000-08:00</HIREDATE>
                             <SAL>2975</SAL>
                             <DEPTNO>20</DEPTNO>
                             <EMAIL>[email protected]</EMAIL>
                        </EMPLOYEE>
                   </EMPLOYEES>
              </DEPT>
              <DEPT>
                   <DEPTNO>30</DEPTNO>
                   <NAME>Sales</NAME>
                   <MANAGER_EMAIL>[email protected]</MANAGER_EMAIL>
                   <EMPLOYEES>
                        <EMPLOYEE>
                             <EMPNO>7788</EMPNO>
                             <ENAME>SCOTT</ENAME>
                             <JOB>ANALYST</JOB>
                             <MGR>7566</MGR>
                             <HIREDATE>1982-12-09T00:00:00.000-08:00</HIREDATE>
                             <SAL>3000</SAL>
                             <DEPTNO>20</DEPTNO>
                             <EMAIL>[email protected]</EMAIL>
                        </EMPLOYEE>
                        <EMPLOYEE>
                             <EMPNO>7876</EMPNO>
                             <ENAME>ADAMS</ENAME>
                             <JOB>CLERK</JOB>
                             <MGR>7788</MGR>
                             <HIREDATE>1983-01-12T00:00:00.000-08:00</HIREDATE>
                             <SAL>1100</SAL>
                             <EMAIL>[email protected]</EMAIL>
                        </EMPLOYEE>
                   </EMPLOYEES>
              </DEPT>
         </DEPTS>
    </DATA>
    Control File (SampleControlFile.xml) :
    <?xml version="1.0" encoding="UTF-8"?>
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
         <xapi:request select="/DATA/DEPTS/DEPT/EMPLOYEES/EMPLOYEE">
              <xapi:delivery>
                   <xapi:email server="my.smtp.server" port="25" from="[email protected]" reply-to="">
                        <xapi:message id="123" to="${EMAIL}" cc="${CC_EMAIL_ADDRESS}" attachment="true" subject="Employee Details for ${ENAME}"> Mr. ${ENAME}, Please review the attached document</xapi:message>
                   </xapi:email>
              </xapi:delivery>
              <xapi:document output-type="pdf" delivery="123">
                   <xapi:template type="rtf" location="${EMP_TEMPLATE}"/>
              </xapi:document>
         </xapi:request>
    </xapi:requestset>
    Java code:
    public class SampleBursting implements BurstingListener {
    public SampleBursting( String tempDir) {
    Logger.setLevel(Logger.STATEMENT);
    try {
    BurstingProcessorEngine dp = new BurstingProcessorEngine();
    dp.deleteTempOutputFile(false);
    dp.setTempDirectory(tempDir); //Set the temp file
    dp.setData(new FileReader(tempDir + "/employee.xml")); //Data File
    dp.setXMLAPI(tempDir + "/SampleControlFile.xml"); // Bursting Control file.
    dp.registerListener(this);
    Properties prop = new Properties();
    prop.put("user-variable:EMAIL_SERVER", "localhost");
    prop.put("user-variable:EMAIL_PORT", "25");
    prop.put("user-variable:FROM_EMAIL_ADDRESS", "[email protected]");
    prop.put("user-variable:CC_EMAIL_ADDRESS", "[email protected]");
    prop.put("user-variable:EMP_TEMPLATE", tempDir + "/employee.rtf");
    dp.setConfig(prop);
    dp.process();
    //dp.deletTemporaryOutputFiles();
    } catch (Exception e) {
    Logger.log(e);
    public static void main(String[] args) {
    SampleBursting sampleBursting = new SampleBursting(args[0]);
    //Listener Implementation//
    public void beforeProcess() {}
    public void afterProcess() {}
    public void beforeProcessRequest(int requestIndex) {}
    public void afterProcessRequest(int requestIndex) {}
    public void beforeProcessDocument(int requestIndex, int documentIndex) {}
    public void afterProcessDocument(int requestIndex, int documentIndex,
    Vector documentOutputs) {}
    public void beforeDocumentDelivery(int requestIndex, int documentIndex,
    String deliveryId) {}
    public void afterDocumentDelivery(int requestIndex, int documentIndex,
    String deliveryId, Object deliveryObject,
    Vector attachments) {}
    public void afterEnterpriseDocumentDelivery(DocumentStatus documentStatus) {
    public void beforeProcessDocument(DocumentStatus status) {
    public void afterProcessDocument(DocumentStatus status) {}
    public void beforeDocumentDelivery(DocumentStatus status) {}
    public void afterDocumentDelivery(DocumentStatus status) {}
    While running the code I am getting below error in logs:
    [120210_125526981][oracle.apps.xdo.batch.DeliveryHelper][EXCEPTION] javax.mail.internet.AddressException: Illegal address in string ``
         at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:94)
         at oracle.apps.xdo.delivery.smtp.SMTPDeliveryRequestHandler.addRecipients(Unknown Source)
         at oracle.apps.xdo.delivery.smtp.SMTPDeliveryRequestHandler.submitRequest(Unknown Source)
         at oracle.apps.xdo.delivery.AbstractDeliveryRequest.submit(Unknown Source)
         at oracle.apps.xdo.batch.DeliveryHelper.submitRequests(Unknown Source)
         at oracle.apps.xdo.batch.bursting.DocumentDelivery.submitCoreDeliveryRequests(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.addDocument2Queue(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.createBurstingDocument(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.burstDocument(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.globalDataEndElement(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.endElement(Unknown Source)
         at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:211)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1354)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:368)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:314)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:349)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingRequest(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingEndElement(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.endElement(Unknown Source)
         at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:211)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1354)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:368)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:314)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:287)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.burstingConfigParser(Unknown Source)
         at oracle.apps.xdo.batch.BurstingProcessorEngine.process(Unknown Source)
         at com.sample.SampleBursting.<init>(SampleBursting.java:36)
         at com.sample.SampleBursting.main(SampleBursting.java:44)
    [120210_125526981][][EXCEPTION] Error!! Could not deliver the output for Delivery channel:null . Please check the Log for error details..
    Can anyone tell me what could be the issue.
    ~
    Joy

    Thanks for your reply.
    I am setting the CC_EMAIL_ADDRESS from the java code:
    prop.put("user-variable:CC_EMAIL_ADDRESS", "[email protected]");
    In the log I found:
    [TEMP_DIR:String] [C:/JDev11/JavaClientApplication/BIReport\120210_125525178]
    [ASYNC_CHECK_INTERVAL:Integer] [60000]
    [HOST:String] [my.smtp.server]
    [SMTP_TO_RECIPIENTS:String] [
    [SMTP_ENCODING:String]
    [SMTP_CONTENT_TYPE:String] [text/plain;charset=UTF-8]
    [SMTP_SUBJECT:String] [Employee Details for
    [BUFFERING_MODE:Boolean] [true]
    [SMTP_CC_RECIPIENTS:String] [[email protected]]
    [SMTP_FROM:String] [[email protected]]
    [TEMP_FILE_PREFIX:String] [dlvr]
    [PORT:Integer] [(java.lang.Integer]
    [RETRY:Integer] [0]
    [SMTP_ATTACHMENT:Attachment] [(oracle.apps.xdo.delivery.smtp.Attachment]
    [RETRY_INTERVAL:Integer] [60000]
    [TEMP_FILE_SUFFIX:String] [.tmp]
    [SMTP_ATTACHMENT_FIRST:Boolean] [(java.lang.Boolean]
    [SMTP_CHARSET:String] [UTF-8]
    [ASYNC_TIMEOUT:Integer] [86400000]
    ~
    Joy

  • Can any one tell what is the problem in this code?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.util.*;
    public class AppletTest2 extends JApplet implements ActionListener,MouseMotionListener,WindowListener{
    JFrame fr = new JFrame("Visual Tool -- Work Flow Editor");
         JPanel panel1 = new JPanel();
         JPanel panel2 = new JPanel();
         JButton sButton = new JButton("Source");
         JButton rButton = new JButton("Redirection");
         JButton dButton = new JButton("Destination");
         JButton connect = new JButton("Connect");
         BasicStroke stroke = new BasicStroke(2.0f);
         int flag = 1 ;
         Vector lines = new Vector();
         JButton sBut,rBut,dBut;
    int x1 = 0 ;
         int y1 = 0 ;
         int x2 = 0 ;
         int y2 = 0;
         int x3 = 0;
         int y3 = 0;
         int i=0;
         int j=0;
         int k=0;
         int l = 100;
    int b = 50;
    public void init(){
              /*********Frame ******************/
    fr.getContentPane().setLayout(new BorderLayout());
         fr.setSize(700,500);
              fr.getContentPane().add(panel1,BorderLayout.CENTER);
              fr.getContentPane().add(panel2,BorderLayout.SOUTH);
              fr.addWindowListener(this);
              /*****************PANEL 1*********************/
              panel1.setLayout(null);
    panel1.setBounds(new Rectangle(0,0,400,400));
              panel1.setBackground(new Color(105,105,205));
    /************************PANEL 2 *************/
              panel2.setLayout(new FlowLayout());
              panel2.setBackground(new Color(105,205,159));
              panel2.add(sButton);
              panel2.add(rButton);
              panel2.add(dButton);
              panel2.add(connect);
              connect.setToolTipText("Use this button after selecting From and To position to connect");
              /***************************LISTENER********************/
    sButton.addActionListener(this);
              rButton.addActionListener(this);
              dButton.addActionListener(this);
              connect.addActionListener(this);
              fr.setVisible(true);     
              fr.setResizable(false);
         } // init clse
    /************************** START METHOD **********************************************/
              public void start(){                                 
                   System.out.println("inside start");
                   paint(panel1.getGraphics());
    /*******************************APPLET METHODS **************************************************/
              public void stop(){}
              public void destroy(){}
    /******************************MOUSE MOTION LISTENERS METHOD*************************************/
              public void mouseMoved(MouseEvent e){System.out.println("moved");}
              public void mouseDragged(MouseEvent e){System.out.println("dragged");}
    /***************************************ACTION EVENT IMPLEMENTAION *******************************/
         public void actionPerformed(ActionEvent e){
              if (e.getSource().equals(sButton)){          
              sourceObject("Source Object");          
              else if (e.getSource().equals(rButton)){          
              redirectionObject("Redirection");
              i = i+1;
              else if (e.getSource().equals(dButton)){
              destinationObject("Destination");
                   j= j+1;
              else if (e.getSource().equals(connect)){
                   System.out.println("am inside connect");                
                   paint(panel1.getGraphics());               
    else if(e.getSource().equals(sBut)){
                   System.out.println("am s button");                
                   x1 = sBut.getX() + l;
                   y1 = sBut.getY() + (b/2);
              else if(e.getSource().equals(rBut)){
                   System.out.println("am r button");               
                   x2 = rBut.getX() ;
                   y2 = rBut.getY()+ b/2;
                   System.out.println("x2 : " + x2 + "y2 :" +y2 );
              else if(e.getSource().equals(dBut)){
                   System.out.println("am d button");                
                   x3 = dBut.getX();
    y3 = dBut.getY()+ b/2;
    } // action close
    /**********************Main **********************************/     
         public static void main(String args[]){
         JApplet at = new AppletTest2();
              at.init();
              at.start();
    /********************my methods starts here *******************/
         public void sourceObject(String name){     
    sBut = new JButton(name);
         panel1.add(sBut);
         sBut.setBounds(new Rectangle(20,208,l,b));     
         sBut.addActionListener(this);
    System.out.println("am inside the source object") ;
         public void redirectionObject(String name){     
         rBut = new JButton(name);
         panel1.add(rBut);
         rBut.setBounds(new Rectangle(290,208,l,b));     
    rBut.addActionListener(this);
    System.out.println("am inside the redirection :" + j) ;
    public void destinationObject(String name){     
         dBut = new JButton(name);
         panel1.add(dBut);     
    System.out.println("am inside the destination object") ;
    if (j == 0)
                   dBut.setBounds(new Rectangle(566,60,l,b));                    
                   System.out.println("am inside the destination:" + j) ;
                   } else if (j == 2)
                        dBut.setBounds(new Rectangle(566,208,l,b));     
                        System.out.println("am inside the destination :" + j) ;
                   } else if (j == 1)
    dBut.setBounds(new Rectangle(566,350,l,b));     
                        System.out.println("am inside the destination :" + j) ;
    dBut.addActionListener(this);
    /* public void connectObject(Object obj1,Object obj2){
    System.out.println("nothing");
    /************************************* PAINT **************************/
    public void paint(Graphics g){
         System.out.println("inside paint");
         Graphics2D g2 = (Graphics2D) g;
         g2.setStroke(stroke);
    if(flag == 1){
    System.out.println("inside flag");
    int np = lines.size();
                        System.out.println(np);
                             for (int I=0; I < np; I++) {                       
         Rectangle p = (Rectangle)lines.elementAt(I);
                             System.out.println("width" + p.width);
                             g2.setColor(Color.red);
                             g2.drawLine(p.x,p.y,p.width,p.height);
                             System.out.println(p.x +"" +""+ p.y + ""+ ""+ p.width+ "" + ""+ p.height);
    flag = -1;
    }else if(flag == -1){
         if(x1 != 0 && y1 != 0 && x2 != 0 && y2 != 0 ){
    // Graphics2D g2 = (Graphics2D) g;
         // g2.setStroke(stroke);
    g2.setColor(Color.red);
         g2.drawLine(x1,y1,x2,y2);
         lines.addElement(new Rectangle(x1,y1,x2,y2));     
         x1 = 0 ;y1 = 0 ;
         x2 = 0 ;y2 = 0 ;
    //     g2.drawLine(100,100,200,200);
    else if (x2 != 0 && y2 != 0 && x3 != 0 && y3 != 0 )
              // Graphics2D g2 = (Graphics2D) g;
                   // g2.setStroke(stroke);
              g2.setColor(Color.green);
                        g2.drawLine(x2,y2,x3,y3);
                        lines.addElement(new Rectangle(x2,y2,x3,y3));
                        x2 = 0; y2 = 0 ;
                        x3 = 0 ; y3 = 0 ;                    
    else if (x1 != 0 && y1 != 0 && x3 != 0 && y3 != 0)
                   //     Graphics2D g2 = (Graphics2D) g;
                   // g2.setStroke(stroke);
                   g2.setColor(Color.red);
                   g2.drawLine(x1,y1,x3,y3);
                        lines.addElement(new Rectangle(x1,y1,x3,y3));                              
                        x1 = 0; y1 = 0 ;
                        x3 = 0 ; y3 = 0 ;                    
    // repaint();
    /********************************WINDOW LISTENER IMPLEMENTATION *****************************/
    public void windowActivated(WindowEvent we) { 
              flag = 1;
              paint(panel1.getGraphics());
    System.out.println("windowActivated -- event 1");
         //start();               
         public void windowClosed(WindowEvent we) {
                                                                System.out.println("windowClosed -- 2");
         public void windowClosing(WindowEvent we){
                                                                System.out.println("windowClosing -- 3");
    public void windowDeactivated(WindowEvent we) {
                                                                     System.out.println("windowDeactivated -- 4");
    public void windowDeiconified(WindowEvent we) {
                                                                     flag = 1;
                                                                     System.out.println("windowDeiconified -- 5");          
                                                                     paint(panel1.getGraphics());           
    public void windowIconified(WindowEvent we) {           
                                                           System.out.println("windowIconified -- 6");
                                                           //paint(panel1.getGraphics());
    public void windowOpened(WindowEvent we) {             
                                                      //     flag = 1;
                                                      //     paint(panel1.getGraphics());
                                                           System.out.println("windowopened -- 7");     
    The problem am facing here is that when i minimize the frame and maximize , my old lines are getting disappared.
    For avoiding that i am storing the old coordinates and
    try to redraw , when maximize.
    but the lines are coming for flash of second and disappearing once again ?
    can any one help?
    thanks all

    Very interestingly the same code is repainting in
    Linux SUSE,jdk1.3.
    but not in WINNT , jdk 1.3
    Any reason ?
    Is the swing 100 % platform independenet ?????
    Does swing also uses native thread ???

  • How to play sound in midlet midp1.0

    how to play a sound (wav format) in midp1.0?
    help needed regarding nokia api.

    well i think ur specified location might be wrong.
    also check out some other ways:
    i hope this might help u.
    1.
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;
    import java.io.*;
    import java.util.*;
    public class mainsound {
    public Player player;
    public mainsound(String s){
    try{
    InputStream is = getClass().getResourceAsStream(s);
    player = Manager.createPlayer(is,"audio/AMR");
    player.addPlayerListener(new Listener());
    player.prefetch();
    catch(Exception e){System.out.println("Media Error" + e);}
    class Listener implements PlayerListener {
         public void playerUpdate(Player p, String event, Object eventData) {
              if (event == END_OF_MEDIA) {
              try {
              p.start();
              } catch (MediaException me) { }
    2.
    public void soundview()
    byte abyte0[]=a("024A3A45D0040029286185985504D04D06186987107107106185985504D0450710690610610000");
    Sound sound = new Sound(abyte0, 1);
    sound.init(abyte0, 1);
    sound.play(1);
    public static byte[] a(String s1)
    s1.toUpperCase();
    byte abyte0[] = new byte[s1.length() / 2];
    int i1 = 0;
    int j1 = 0;
    for(int l1 = s1.length() / 2; l1 > 0; l1--)
    int k1;
    if(s1.charAt(j1) >= '0' && s1.charAt(j1) <= '9')
    k1 = s1.charAt(j1) - 48;
    else
    k1 = (s1.charAt(j1) - 65) + 10;
    k1 *= 16;
    if(s1.charAt(j1 + 1) >= '0' && s1.charAt(j1 + 1) <= '9')
    k1 += s1.charAt(j1 + 1) - 48;
    else
    k1 += (s1.charAt(j1 + 1) - 65) + 10;
    abyte0[i1] = (byte)k1;
    j1 += 2;
    i1++;
    return abyte0;

  • Getting Text to show on GUI

    I'm about desperate because i spent 3 days on this and i'm am in dire need for help!
    1. First i want to create a GUI that it a quiz.
    2. Create Questions by using Combo Box
    3. Next it creates a text field and allow me to input my answer
    4. following that, after the input is inputted, i click a button that says check answer and it will return if it is correct or false.
    The problem is that code is so messed up that i don't know where to go.
    When i run it, it show me a combo box with 3 questions but before i even answer it, it shows that i'm incorrect.
    Thats why I can't really brief wat i need help in. So, could you write a quick code that can summarize the whole thing. You can use my code and fix it up. Thanks very so much!
    package anaquiz;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class AnAQuiz extends JPanel {
        private JComboBox choice;
        private JLabel label;
        private JTextField text;
        Button CheckAnswer;
        Button TryAgain;
        private String Answer1 = "Wilson";
        private String Answer2 = "Ace";
        private String Answer3 = "Yes";
        private String input = " ";
        boolean Answer = false;
        JLabel testresult = new JLabel("");
    public AnAQuiz() {
            choice = new JComboBox();
            label = new JLabel();
            label.setBackground(Color.blue);
            choice.addItem("Tennis Question #1");
            choice.addItem("Tennis Question #2");
            choice.addItem("Tennis Question #3");
            text = new JTextField(20); //step 4
            Listener listen = new Listener();
            choice.addActionListener(listen);
            setLayout(new BoxLayout(this, 0));
            add(choice);
            add(label);
            add(text);
            add(testresult);
    private class Listener implements ActionListener {
    public void actionPerformed(ActionEvent event ) {
       int c = choice.getSelectedIndex();
         switch (c) {
                 case 0:
                    label.setText("Whats the famous tennis brand that begins with 'W'?");
                    if (Answer1.equals(input))testresult.setText("Correct");
                  else { testresult.setText("Incorrect");
                     break;
                 case 1:
                    label.setText("What do you call when someone misses a serve?");
                    if (Answer2.equals(input))testresult.setText("Correct");
                   else { testresult.setText("Incorrect");
                    break;
                 case 2:
                    label.setText("Should you shake hands after a match?");
                    if (input.equals(Answer3))testresult.setText("Correct");
                     else{
                         testresult.setText("Incorrect");
                    break;
          testresult.setVisible(false);
    public static void main(String[] args)    {
            JFrame frame = new JFrame("Quiz");
            frame.getContentPane().add(new AnAQuiz());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
          //  frame.show();
            frame.setVisible(true);
    }

    package anaquiz;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class AnAQuiz extends JPanel {
        private JComboBox choice;
        private JLabel label;
        private JTextField text;
        Button CheckAnswer;
        Button TryAgain;
        private String Answer1 = "Wilson";
        private String Answer2 = "Ace";
        private String Answer3 = "Yes";
        private String input = " ";
        boolean Answer = false;
        JLabel testresult = new JLabel("");
        public AnAQuiz() {
            choice = new JComboBox();
            label = new JLabel();
            label.setBackground(Color.blue);
            choice.addItem("Tennis Question #1");
            choice.addItem("Tennis Question #2");
            choice.addItem("Tennis Question #3");
            text = new JTextField(20); //step 4
            ButtonListener listen = new ButtonListener();
            CheckBoxListener listen1 = new CheckBoxListener();
            choice.addActionListener(listen);
            choice.addActionListener(listen1);
            setLayout(new BoxLayout(this, 0));
            add(choice);
            add(label);
            add(text);
            testresult.setVisible(false);
            add(testresult);
        private class  CheckBoxListener implements ActionListener {
            public void actionPerformed(ActionEvent event) {
                int c = choice.getSelectedIndex();
                switch (c) {
                case 0:
                    label.setText(
                            "Whats the famous tennis brand that begins with 'W'?");
                    break;
                case 1:
                    label.setText("What do you call when someone misses a serve?");
                    break;
                case 2:
                    label.setText("Should you shake hands after a match?");
                    break;
            private class  ButtonListener implements ActionListener {
                public void actionPerformed(ActionEvent event) {
                    int c = choice.getSelectedIndex();
                    if (Answer1.equals(input)) testresult.setText("Correct");
                    else
                        testresult.setText("Incorrect");
                    if (Answer2.equals(input)) testresult.setText("Correct");
                    else
                        testresult.setText("Incorrect");
                    if (input.equals(Answer3)) testresult.setText("Correct");
                    else
                        testresult.setText("Incorrect");
            public static void main(String[] args) {
                JFrame frame = new JFrame("Quiz");
                frame.getContentPane().add(new AnAQuiz());
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                //  frame.show();
                frame.setVisible(true);
    }now it has no errors but correct and incorrect doesn't show after i type in the answer in the textfield after hitting the enter button

  • Java Media Framework + jipCam + IP Cam

    Hi everyone,
    I maked an aplication using JMF, its connect to a USB cam and shouw the video, it's can snapshot the video too.. and record the video. Now i'm studding a JMF integration with a IP CAM, using the jipCam [http://jipcam.sourceforge.net]
    But, i having some difficulty to do it.
    Someone here has axperiency with jipCam?
    My main question is how to prepare the MediaLocator using jipCam.
    Thanks, and sorry the poor english language..
    ---- portuguese version
    Sauda��es,
    Fiz um aplicativo utilizando JMF que se conecta a uma camera USB e exibe sua imagem, podendo tirar 'fotografias' da imagem e/ou gravar o v�deo. Agora estou estudando a integra��o do JMF com uma Camera IP, para tanto estou estudando o jipCam http://jipcam.sourceforge.net/ que � um framework que auxilia exatamente neste tipo de comunica��o: conectar uma camera ip em um aplicativo jmf. Por�m, estou com dificuldades para encontrar documenta��o, ou c�digo de exemplo, nem se quer um Hello World encontrei.. Em fim, algo que facilite minha vida. Algu�m j� trabalhou, ou estudou algo a respeito?

    I build a simple code to play a IP Cam:
    But i have the fallow error:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Category
         at ipcam.PlayerManager.main(PlayerManager.java:115)
    import java.awt.Component;
    import javax.media.ConfigureCompleteEvent;
    import javax.media.ControllerEvent;
    import javax.media.ControllerListener;
    import javax.media.EndOfMediaEvent;
    import javax.media.Manager;
    import javax.media.MediaLocator;
    import javax.media.Player;
    import javax.media.PrefetchCompleteEvent;
    import javax.media.Processor;
    import javax.media.RealizeCompleteEvent;
    import javax.media.ResourceUnavailableEvent;
    import javax.media.SizeChangeEvent;
    import javax.media.protocol.DataSource;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    * @author cassio
    * @since December 2007
    public class PlayerManager extends JFrame implements ControllerListener {
         private static final long serialVersionUID = 1L;
         private Player p;
         private Object waitSync = new Object();
         boolean stateTransitionOK = true;
         public void play(DataSource ds) {
              try {
                   p = Manager.createPlayer(ds);
              } catch (Exception e) {
                   System.err.println("Failure to create the player: " + e);
               * turn on the listeners and realize the player
              p.addControllerListener(this);
              p.prefetch();
              if (!waitForState(Processor.Prefetched)) {
                   System.err.println("Failure to realize the player: ");
              JPanel painel = new JPanel();
              Component cc; // control component
              Component vc; // visual component
              if ((vc = p.getVisualComponent()) != null)
                   painel.add(vc);
              if ((cc = p.getControlPanelComponent()) != null)
                   add(cc);
              this.setContentPane(painel);
              p.start();
              this.setVisible(true);
         public void addNotify() {
              super.addNotify();
              pack();
         private boolean waitForState(int state) {
              synchronized (waitSync) {
                   try {
                        while (p.getState() < state && stateTransitionOK)
                             waitSync.wait();
                   } catch (Exception e) {
              return stateTransitionOK;
          * Controller Listener implementation
         public void controllerUpdate(ControllerEvent evt) {
              if (evt instanceof ConfigureCompleteEvent
                        || evt instanceof RealizeCompleteEvent
                        || evt instanceof PrefetchCompleteEvent) {
                   synchronized (waitSync) {
                        stateTransitionOK = true;
                        waitSync.notifyAll();
              } else if (evt instanceof ResourceUnavailableEvent) {
                   synchronized (waitSync) {
                        stateTransitionOK = false;
                        waitSync.notifyAll();
              } else if (evt instanceof EndOfMediaEvent) {
                   p.close();
              } else if (evt instanceof SizeChangeEvent) {
          * Main program
         public static void main(String[] args) {
              MediaLocator ml = new MediaLocator("http://192.168.0.100:80");
              net.sf.jipcam.axis.media.protocol.http.DataSource ds = null;
              try {
                   // DataSource configuration
                   ds = new net.sf.jipcam.axis.media.protocol.http.DataSource();
                   ds.setLocator(ml);
                   // i'm not using password
                   ds.setUsername(null);
                   ds.setPassword(null);
              } catch (Exception e) {
                   System.err.println("Impossp�vel criar dataSuource para: " + ml);
                   e.printStackTrace();
              PlayerManager p = new PlayerManager();
              p.play(ds);
    }someone has any idea?
    this code can work with an local cam or a local file. you only need to substitute the MediaLocator and the DataSource settings in the main method:
    using jipCam (the current main code):
         public static void main(String[] args) {
              MediaLocator ml = new MediaLocator("http://192.168.0.100:80");
              net.sf.jipcam.axis.media.protocol.http.DataSource ds = null;
              try {
                   // DataSource configuration
                   ds = new net.sf.jipcam.axis.media.protocol.http.DataSource();
                   ds.setLocator(ml);
                   // i'm not using password
                   ds.setUsername(null);
                   ds.setPassword(null);
              } catch (Exception e) {
                   System.err.println("Impossp�vel criar dataSuource para: " + ml);
                   e.printStackTrace();
              PlayerManager p = new PlayerManager();
              p.play(ds);
         }accessing a local device (new main code):
         public static void main(String[] args) {
              MediaLocator ml = new MediaLocator("vfw://3"); //use the jmf registry to see the correct location
              DataSource ds = null;
              try {
                   // DataSource configuration
                   ds = Manager.createDataSource(ml);
              } catch (Exception e) {
                   System.err.println("Impossp�vel criar dataSuource para: " + ml);
                   e.printStackTrace();
              PlayerManager p = new PlayerManager();
              p.play(ds);
         }Edited by: cassioso on Dec 10, 2007 11:25 AM
    add the cod to run as a local application

Maybe you are looking for