CDC mousePressed Bug (in J9)

I have found a horrid bug in IBM's J9 CDC implementation.
The way they have implemented popup trigger is by placing it in the mousePressed event. Since the trigger on PocketPC is to hold the pen on the screen for a "while", this means the mousePressed event is not delivered straight away.
The result of this is that the application does not know when the pen hits the screen, but only at some point later! this makes all kinds of stuff impossible; from signature captures to drawing apps, to custom on screen keyboards... loads of stuff.
It is sounding like IBM does not regard this as a bug but a feature of the platform. I do not agree with this at all, as it is just poorly implemented. If the trigger was placed in the mouseRelaesed event the mousePressed event could be delivered striaght away, and the trigger could be detected from the difference in time beteeen the press and release (providing no or little mouse movement ocurred in the elaped time). This is not a tricky fix by any means.
Anyway, to my point;
Surely the certification for whether a CDC platform is compliant or not should cover obvious things like making sure events happened when they are meant to. After all, mousePressed() is called that for a very good reason! maybe mousePressedSomeTimeAgo() would be better ;)

Hi,
I tried both Socket and Connector.
For Socket take:
        try {
            Socket sock = new Socket("61.31.254.13", 4004);
            OutputStream out = sock.getOutputStream();
            out.write("hello".getBytes());
            // start another reader thread...
        } catch (Exception ex) {
            ex.printStackTrace();
        }Exceptions look like:
java.net.ConnectException:61.31.254.13/61.31.254.13:4004 - Operation failed: 10065 (FormatMessage failed: 317)
        at java.net.PlainSocketImpl.connect(Unkown Source)
        at java.net.Socket.startupSocket(Unkown Source)
        at java.net.Socket.<init>(Unkown Source)
        ....For Connector take:
        try {
            StreamConnection c = (StreamConnection) Connector.open("socket://61.31.254.13:4004");
            OutputStream out = c.openOutputStream();
            out.write("hello".getBytes());
            // start another reader thread...
        } catch (Exception ex) {
            ex.printStackTrace();
        }Exceptions:
javax.microedition.io.ConnectionNotFoundException: Cound not establish connection: (61.31.254.13) 61.31.254.13:4004 - Operation failed: 10065 (FormatMessage failed: 317)
        at com.ibm.oti.connection.socket.Connection.setParameters(Unknown Source)
        at com.ibm.oti.connection.socket.Connection.setParameters(Unknown Source)
        at javax.microedition.io.Connector.open(Unknown Source)
        at javax.microedition.io.Connector.open(Unknown Source)
        ... ...Please note that the above 2 takes both work when gprs connection is opened manually.
Thanks.
JC.L

Similar Messages

  • Bug in SQL Server 2008 R2 for Change Data Capture (CDC)

    I'm pretty sure I've encountered a bug in SQL Server 2008 R2 that's been fixed in 2012, regarding changing the design of a database using CDC.  With CDC disabled on a table with sys.sp_cdc_disable_table, I can add a column or change a column's data
    type, but when I call sp_rename, on 2008 R2 I'm getting "Cannot alter column 'xxx' because it is 'REPLICATED'.", even though the table's properties shows "Table is replicated" as False.  In 2012, works fine.
    Even calling sys.sp_cdc_disable_db didn't prevent this error.

    Feel free to file a request on http://connect.microsoft.com
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Help, experiencing minor bugs in program

    this is supposed to use rectangles and you should be able to load and save and they have colors and do a few more things with them, the loading is where it doesn't work.
    *-------------------------------------------------------------- 80 columns ---|
    * This is the main class for the application. It is built along the same
    * lines as the Editor class of project 1. It has a constructor, two instance
    * methods, and a static main()  that kicks the whole thing off.
    * The two instance methods are a menu creation method, and a menuItems
    * initialisation method.  The constructor instantiates the window
    * and sets up its internals by creating and installing the drawing canvas,
    * toolbar, and menus. All of the code works correctly as is and should
    * require no changes.
    * @version      1.1 15/04/01
    * @author       Julie Zelenski
    * @author       Restructured by Ian A. Mason
    * @see       javax.swing.JFrame
    * @see       javax.swing.JMenuBar
    * @see       javax.swing.JMenuItem
    * @see       javax.swing.JMenu
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class JavaDraw extends JFrame {
        final Toolbar toolbar = new Toolbar();
        final DrawingCanvas canvas = new DrawingCanvas(toolbar, 350, 350);
        final int menuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
        final JMenuBar mb = new JMenuBar();
        final String[]
             fileMenuItems = {"Clear all", "Load file", "Save to file", "Quit"};
        final int[] fileKeyCodes = {KeyEvent.VK_N, KeyEvent.VK_O, KeyEvent.VK_S, KeyEvent.VK_Q};
        final ActionListener[] fileActionListeners = {
         new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  canvas.clearAll();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  canvas.loadFile();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  canvas.saveToFile();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  System.exit(0);}}
        final String[] editMenuItems = {"Cut", "Copy", "Paste", "Delete"};
        final int[] editKeyCodes = {KeyEvent.VK_X, KeyEvent.VK_C, KeyEvent.VK_V, KeyEvent.VK_BACK_SPACE};
        final int[] editMenuMasks = {menuMask, menuMask, menuMask, 0};
        final ActionListener[] editActionListeners = {
         new ActionListener() {
              public void actionPerformed(ActionEvent e) { canvas.cut();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) { canvas.copy();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) { canvas.paste();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) { canvas.delete();}}
        final String[] layeringMenuItems = {"Bring to front", "Send to back"};
        final int[]    layeringKeyCodes = {KeyEvent.VK_F, KeyEvent.VK_B};
        final ActionListener[] layeringActionListeners = {
         new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  canvas.bringToFront();}},
         new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  canvas.sendToBack();}}
        private JavaDraw(){
         super("JavaDraw!");
         toolbar.setCanvas(canvas);
         getContentPane().add(toolbar, BorderLayout.SOUTH);
         getContentPane().add(canvas, BorderLayout.CENTER);
         createMenus();
         setJMenuBar(mb);
         setLocation(100, 20);
         pack();
         setVisible(true);
        static public void main(String[] args){
         JavaDraw javaDraw = new JavaDraw();
        private void initMenus(JMenu m,
                      String  miLabel,
                      int keyCode,
                      int menuMask,
                      ActionListener al){
         JMenuItem mi = new JMenuItem(miLabel);
         m.add(mi);
         mi.addActionListener(al);
         mi.setAccelerator(KeyStroke.getKeyStroke(keyCode, menuMask));
        private void createMenus(){
         JMenu m;
         m = new JMenu("File");
         for(int i = 0; i < fileMenuItems.length; i++)
             initMenus(m,
                    fileMenuItems,
              fileKeyCodes[i],
              menuMask,
              fileActionListeners[i]);
         mb.add(m);
         m = new JMenu("Edit");
         for(int i = 0; i < editMenuItems.length; i++)
         initMenus(m,
              editMenuItems[i],
              editKeyCodes[i],
              editMenuMasks[i],
              editActionListeners[i]);
         mb.add(m);
         m = new JMenu("Layering");
         for(int i = 0; i < layeringMenuItems.length; i++)
         initMenus(m,
              layeringMenuItems[i],
              layeringKeyCodes[i],
              menuMask,
              layeringActionListeners[i]);
         mb.add(m);
    *-------------------------------------------------------------- 80 columns ---|
    * The DrawingCanvas class a small extension of JComponent
    * @version 1.1 15/04/01
    * @author Julie Zelenski
    * @author (touched up by Ian A. Mason)
    * @see javax.swing.JComponent
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    public class DrawingCanvas extends JComponent{
    static final int DRAG_NONE = 0;
    static final int DRAG_CREATE = 1;
    static final int DRAG_RESIZE = 2;
    static final int DRAG_MOVE = 3;
    // list of all shapes on canvas
    protected Vector allShapes;          
    // currently selected shape (can be null at times)
    protected Rect selectedShape;
    // reference to toolbar to message for tool&color settings
    protected Toolbar toolbar;
    protected Rect clipboard=null;          
    /* These are the unimplemented menu commands. The menus are already
    * set up to send the correct messages to the canvas, but the
    * method bodies themselves are currently completely empty. It will
    * be your job to fill them in!
    public void cut() {
         copy();
         delete();
    public void copy() {
         int x=(int)selectedShape.getBounds().getX();
         int y=(int)selectedShape.getBounds().getY();
         Point p=new Point(x,y);
         clipboard=new Rect(p,this);
         clipboard.setBounds(selectedShape.getBounds());
    public void paste() {
         if(clipboard==null)
              return;
         allShapes.add(clipboard);
         setSelectedShape(clipboard);
         copy();
         this.repaint();
    public void delete() {
         if(selectedShape==null)
              return;
         else{
         int num=allShapes.indexOf(selectedShape);
         allShapes.remove(num);
         selectedShape=null;
         this.repaint();
    public void clearAll() {
         allShapes.removeAllElements();
         this.repaint();
    public void loadFile() {
         Load load=new Load(this);
         load.setSize(250,200);
         load.validate();
         load.setVisible(true);
    public void done(Vector vect){
         allShapes.removeAllElements();
         for(int i=0;i<vect.size();i++){
              allShapes.add(vect.elementAt(i));
         this.repaint();
    public void saveToFile() {
         Save save=new Save(allShapes);
         save.setSize(250,200);
         save.validate();
         save.setVisible(true);
    public void bringToFront() {
         if(selectedShape==null)
              return;
         int size=allShapes.size();
         int index=allShapes.indexOf(selectedShape);
         for(int i=index+1;i<=size-1;i++){
              allShapes.set(i-1,allShapes.elementAt(i));
         allShapes.set(size-1,selectedShape);
         this.repaint();
    public void sendToBack() {
         if(selectedShape==null)
              return;
         int index=allShapes.indexOf(selectedShape);
         for(int i=index-1;i>=0;i--){
              allShapes.remove(allShapes.elementAt(i+1));
              allShapes.add(i+1,allShapes.elementAt(i));
         allShapes.remove(allShapes.elementAt(0));
         allShapes.add(0,selectedShape);
         this.repaint();
    * Constructor for creating a new empty DrawingCanvas. We set up
    * our size and background colors, instantiate an empty vector of shapes,
    * and install a listener for mouse events using our inner class
    * CanvasMouseHandler
    public DrawingCanvas(Toolbar tb, int width, int height){
         setPreferredSize(new Dimension(width, height));
         setBackground(Color.white);
         toolbar = tb;
         allShapes = new Vector();
         selectedShape = null;
         CanvasMouseHandler handler = new CanvasMouseHandler();
         addMouseListener(handler);
         addMouseMotionListener(handler);
    * All components are responsible for drawing themselves in
    * response to repaint() requests. The standard method a component
    * overrides is paint(Graphics g), but for Swing components, the default
    * paint() handler calls paintBorder(), paintComponent() and paintChildren()
    * For a Swing component, you override paintComponent and do your
    * drawing in that method. For the drawing canvas, we want to
    * clear the background, then iterate through our shapes asking each
    * to draw. The Graphics object is clipped to the region to update
    * and we use to that avoid needlessly redrawing shapes outside the
    * update region.
    public void paintComponent(Graphics g){
         Rectangle regionToRedraw = g.getClipBounds();
         g.setColor(getBackground());
         g.fillRect(regionToRedraw.x, regionToRedraw.y,
              regionToRedraw.width, regionToRedraw.height);
         Iterator iter = allShapes.iterator();
         while (iter.hasNext())
         ((Rect)iter.next()).draw(g, regionToRedraw);
    * Changes the currently selected shape. There is at most
    * one shape selected at a time on the canvas. It is possible
    * for the selected shape to be null. Messages the shape to
    * change its selected state which will in turn refresh the
    * shape with the knobs active.
    protected void setSelectedShape(Rect shapeToSelect) {
         // if change in selection
         if (selectedShape != shapeToSelect) {
         // deselect previous selection
         if (selectedShape != null)
              selectedShape.setSelected(false);
         // set selection to new shape
         selectedShape = shapeToSelect;
         if (selectedShape != null) {
              shapeToSelect.setSelected(true);
    * A hit-test routine which finds the topmost shape underneath a
    * given point.We search Vector of shapes in back-to-front order
    * since shapes created later are added to end and drawn last, thus
    * appearing to be "on top" of the earlier ones. When a click comes
    * in, we want to select the top-most shape.
    protected Rect shapeContainingPoint(Point pt){
         for (int i = allShapes.size()-1; i >= 0; i--) {
         Rect r = (Rect)allShapes.elementAt(i);
         if (r.inside(pt)) return r;
         return null;
    * The inner class CanvasMouseHandler is the object that handles the
    * mouse actions (press, drag, release) over the canvas. Since there is
    * a bit of state to drag during the various operations (which shape,
    * where we started from, etc.) it is convenient to encapsulate all that
    * state with this little convenience object and register it as the
    * handler for mouse events on the canvas.
    protected class CanvasMouseHandler
         extends MouseAdapter implements MouseMotionListener {
         Point dragAnchor;          
         // variables using to track state during drag operations
         int dragStatus;
         /** When the mouse is pressed we need to figure out what
         * action to take. If the tool mode is arrow, the click might
         * be a select, move or reisze. If the tool mode is one of the
         * shapes, the click initiates creation of a new shape.
         public void mousePressed(MouseEvent event){
         Rect clicked = null;
         Point curPt = event.getPoint();
         // first, determine if click was on resize knob of selected shape
         if (toolbar.getCurrentTool() == Toolbar.SELECT) {
              if (selectedShape != null &&
              (dragAnchor = selectedShape.getAnchorForResize(curPt))
              != null) {
              // drag will resize this shape
              dragStatus = DRAG_RESIZE;     
              } else if ((clicked = shapeContainingPoint(curPt)) != null) {
              // if not, check if any shape was clicked
              setSelectedShape(clicked);
              // drag will move this shape      
              dragStatus = DRAG_MOVE;
              dragAnchor = curPt;
              } else {     
              // else this was a click in empty area,
              // deselect selected shape,
              setSelectedShape(null);
              // drag does nothing in this case
              dragStatus = DRAG_NONE;
         } else {
              Rect newShape = new Rect(curPt, DrawingCanvas.this);
              // create rect here
              allShapes.add(newShape);
              setSelectedShape(newShape);
              dragStatus = DRAG_CREATE;          
              // drag will create (resize) this shape
              dragAnchor = curPt;
         /** As the mouse is dragged, our listener will receive periodic
         * updates as mouseDragged events. When we get an update position,
         * we update the move/resize event that is in progress.
         public void mouseDragged(MouseEvent event){
         Point curPt = event.getPoint();
         switch (dragStatus) {
         case DRAG_MOVE:
              selectedShape.translate(curPt.x - dragAnchor.x,
                             curPt.y - dragAnchor.y);
              // update for next dragged event
              dragAnchor = curPt;
              break;
         case DRAG_CREATE: case DRAG_RESIZE:
              selectedShape.resize(dragAnchor, curPt);
              break;
         public void mouseMoved(MouseEvent e) {}
    /** A little helper routine that will be useful for the load & save
    * operations. It brings up the standard JFileChooser dialog and
    * allows the user to specify a file to open or save. The return
    * value is the full path to the chosen file or null if no file was
    * selected.
    protected String filenameChosenByUser(boolean forOpen){
         JFileChooser fc = new JFileChooser(System.getProperty("user.dir") +
                             java.io.File.separator + "Documents");
         int result = (forOpen? (fc.showOpenDialog(this)) :
              fc.showSaveDialog(this));
         java.io.File chosenFile = fc.getSelectedFile();
         if (result == JFileChooser.APPROVE_OPTION && chosenFile != null)
         return chosenFile.getPath();
         return null;
         // return null if no file chosen or dialog cancelled
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import java.io.*;
    class Load extends JFrame implements ActionListener, Serializable{
         Container contentPane;
         JTextField jtf;
         JButton jb;
         Object obj=null;
         Load load;
         Thread thread;
         DrawingCanvas draw;
         public Load(DrawingCanvas dc){
              draw=dc;
              contentPane=getContentPane();
              contentPane.setLayout(new FlowLayout());
              jtf=new JTextField(20);
              jb=new JButton("Load");
              jb.addActionListener(this);
              contentPane.add(jtf);
              contentPane.add(jb);
         public void actionPerformed(ActionEvent e){
              String text=jtf.getText();
              SimpleObjectReader reader=SimpleObjectReader.openFileForReading(text+".shp");
              if(reader==null){
                   System.out.println("Couldn't open file!");
                   return;
              obj=reader.readObject();
              reader.close();
              draw.done((Vector)obj);
              this.setVisible(false);
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.Vector;
    import java.io.*;
    class Save extends JFrame implements ActionListener, Serializable{
         Container contentPane;
         JTextField jtf;
         Vector shapes;
         JButton jb;
         public Save(Vector shapeVector){
              shapes=shapeVector;
              contentPane=getContentPane();
              contentPane.setLayout(new FlowLayout());
              jtf=new JTextField(20);
              jb=new JButton("Save");
              jb.addActionListener(this);
              contentPane.add(jtf);
              contentPane.add(jb);
         public void actionPerformed(ActionEvent e){
              String text=jtf.getText();
              SimpleObjectWriter writer=SimpleObjectWriter.openFileForWriting(text+".shp");
              if(writer==null){
                   System.out.println("Couldn't open file!");
                   return;
              writer.writeObject(shapes);
              writer.close();
              this.setVisible(false);
    *-------------------------------------------------------------- 80 columns ---|
    * The RectShape class defines a simple rectangular shape object.
    * It tracks its bounding box, selected state, and the canvas it is being
    * drawn in. It has some basic methods to select, move, and resize the
    * rectangle. It has methods that draw the shape in the selected or unselected
    * states and updates the canvas whenever the state or bounds of the rectangle
    * change. The code that is there works properly, but you will need to extend
    * and change the code to support additional features.
    * @version 1.1 15/04/01
    * @author Julie Zelenski
    * @author (touched up by Ian A. Mason)
    import java.awt.*;
    import java.io.*;
    public class Rect implements Serializable{     
    protected Rectangle bounds;
    protected boolean isSelected;
    public Color color;
    public DrawingCanvas canvas;
    protected static final int KNOB_SIZE = 6;
    protected static final int NONE = -1;
    protected static final int NW = 0;
    protected static final int SW = 1;
    protected static final int SE = 2;
    protected static final int NE = 3;
    /** The constructor that creates a new zero width and height rectangle
    * at the given position in the canvas.
    public Rect(Point start, DrawingCanvas dcanvas){
         canvas = dcanvas;
         bounds = new Rectangle(start);
         color=canvas.toolbar.getCurrentColor();
    /** The "primitive" for all resizing/moving/creating operations that
    * affect the rect bounding box. The current implementation just resets
    * the bounds variable and triggers a re-draw of the union of the old &
    * new rectangles. This will redraw the shape in new size and place and
    * also "erase" if bounds are now smaller than before. It is a good
    * design to have all changes to a critical variable bottleneck through
    * one method so that you can be sure that all the updating that goes
    * with it only needs to be implemented in this one place. If any of your
    * subclasses have additional work to do when the bounds change, this is
    * the method to override. Make sure that any methods that change the
    * bounds call this method instead of directly manipulating the variable.
    protected void setBounds(Rectangle newBounds){
         Rectangle oldBounds = bounds;
         bounds = newBounds;
         updateCanvas(oldBounds.union(bounds));
    /** The resize operation is called when first creating a rect, as well as
    * when later resizing by dragging one of its knobs. The two parameters
    * are the points that define the new bounding box. The anchor point
    * is the location of the mouse-down event during a creation operation
    * or the opposite corner of the knob being dragged during a resize
    * operation. The end is the current location of the mouse. If you
    * create the smallest rectangle which encloses these two points, you
    * will have the new bounding box. Use the setBounds() primitive which
    * is the bottleneck we are using for all geometry changes, it handles
    * updating and redrawing.
    public void resize(Point anchor, Point end){
         Rectangle newRect = new Rectangle(anchor);
         // creates smallest rectange which
         // includes both anchor & end
         newRect.add(end);
         // reset bounds & redraw affected areas
         setBounds(newRect);      
    public Rectangle getBounds(){
         return bounds;
    /** The translate operation is called when moving a shape by dragging in
    * the canvas. The two parameters are the delta-x and delta-y to move
    * by. Note that either or both can be negative. Create a new rectangle
    * from our bounds and translate and then go through the setBounds()
    * primitive to change it.
    public void translate(int dx, int dy){
         Rectangle newRect = new Rectangle(bounds);
         newRect.translate(dx, dy);
         setBounds(newRect);
    /** Used to change the selected state of the shape which will require
    * updating the affected area of the canvas to add/remove knobs.
    public void setSelected(boolean newState){
         isSelected = newState;
         // need to erase/add knobs
         // including extent of extended bounds
         updateCanvas(bounds, true);
    /** The updateCanvas() methods are used when the state has changed
    * in such a way that it needs to be refreshed in the canvas to properly
    * reflect the new settings. The shape should take responsibility for
    * messaging the canvas to properly update itself. The appropriate AWT/JFC
    * way to re-draw a component is to send it the repaint() method with the
    * rectangle that needs refreshing. This will cause an update() event to
    * be sent to the component which in turn will call paint(), where the
    * real drawing implementation goes. See the paint() method in
    * DrawingCanvas to see how it is implemented.
    protected void updateCanvas(Rectangle areaOfChange, boolean enlargeForKnobs){
         Rectangle toRedraw = new Rectangle(areaOfChange);
         if (enlargeForKnobs)
         toRedraw.grow(KNOB_SIZE/2, KNOB_SIZE/2);
         canvas.repaint(toRedraw);
    protected void updateCanvas(Rectangle areaOfChange){
         updateCanvas(areaOfChange, isSelected);
    /** When the DrawingCanvas needs a shape to draw itself, it sends a draw
    * message, passing the graphics context and the current region being
    * redrawn. If the shape intersects with that region, it must draw itself
    * doing whatever it takes to properly represent itself in the canvas
    * (colors, location, size, knobs, etc.) by messaging the Graphics object.
    public void draw(Graphics g, Rectangle regionToDraw){
         if (!bounds.intersects(regionToDraw))
         return;
         g.setColor(color);
         g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
         if (isSelected) { // if selected, draw the resizing knobs
         // along the 4 corners
         Rectangle[] knobs = getKnobRects();
         for (int i = 0; i < knobs.length; i++)
              g.fillRect(knobs[i].x, knobs[i].y,
                   knobs[i].width, knobs[i].height);
    /** When the DrawingCanvas needs to determine which shape is under
    * the mouse, it asks the shape to determine if a point is "inside".
    * This method should returns true if the given point is inside the
    * region for this shape. For a rectangle, any point within the
    * bounding box is inside the shape.
    public boolean inside(Point pt){
         return bounds.contains(pt);
    /** When needed, we create the array of knob rectangles on demand. This
    * does mean we create and discard the array and rectangles repeatedly.
    * These are small objects, so perhaps it is not a big deal, but
    * a valid alternative would be to store the array of knobs as an
    * instance variable of the Shape and and update the knobs as the bounds
    * change. This means a little more memory overhead for each Shape
    * (since it is always storing the knobs, even when not being used) and
    * having that redundant data opens up the possibility of bugs from
    * getting out of synch (bounds move but knobs didn't, etc.) but you may
    * find that a more appealing way to go. Either way is fine with us.
    * Note this method provides a nice unified place for one override from
    * a shape subclass to substitute fewer or different knobs.
    protected Rectangle[] getKnobRects(){
         Rectangle[] knobs = new Rectangle[4];
         knobs[NW] = new Rectangle(bounds.x - KNOB_SIZE/2,
                        bounds.y - KNOB_SIZE/2, KNOB_SIZE, KNOB_SIZE);
         knobs[SW] = new Rectangle(bounds.x - KNOB_SIZE/2,
                        bounds.y + bounds.height - KNOB_SIZE/2,
                        KNOB_SIZE, KNOB_SIZE);
         knobs[SE] = new Rectangle(bounds.x + bounds.width - KNOB_SIZE/2,
                        bounds.y + bounds.height - KNOB_SIZE/2,
                        KNOB_SIZE, KNOB_SIZE);
         knobs[NE] = new Rectangle(bounds.x + bounds.width - KNOB_SIZE/2,
                        bounds.y - KNOB_SIZE/2,
                        KNOB_SIZE, KNOB_SIZE);
         return knobs;
    /** Helper method to determine if a point is within one of the resize
    * corner knobs. If not selected, we have no resize knobs, so it can't
    * have been a click on one. Otherwise, we calculate the knob rects and
    * then check whether the point falls in one of them. The return value
    * is one of NW, NE, SW, SE constants depending on which knob is found,
    * or NONE if the click doesn't fall within any knob.
    protected int getKnobContainingPoint(Point pt){
         // if we aren't selected, the knobs
         // aren't showing and thus there are no knobs to check
         if (!isSelected) return NONE;
         Rectangle[] knobs = getKnobRects();
         for (int i = 0; i < knobs.length; i++)
         if (knobs[i].contains(pt))
              return i;
         return NONE;
    /** Method used by DrawingCanvas to determine if a mouse click is starting
    * a resize event. In order for it to be a resize, the click must have
    * been within one of the knob rects (checked by the helper method
    * getKnobContainingPoint) and if so, we return the "anchor" ie the knob
    * opposite this corner that will remain fixed as the user drags the
    * resizing knob of the other corner around. During the drag actions of a
    * resize, that fixed anchor point and the current mouse point will be
    * passed to the resize method, which will reset the bounds in response
    * to the movement. If the mouseLocation wasn't a click in a knob and
    * thus not the beginning of a resize event, null is returned.
    public Point getAnchorForResize(Point mouseLocation){
         int whichKnob = getKnobContainingPoint(mouseLocation);
         // no resize knob is at this location
         if (whichKnob == NONE)
         return null;
         switch (whichKnob) {
         case NW: return new Point(bounds.x + bounds.width,
                        bounds.y + bounds.height);
         case NE: return new Point(bounds.x, bounds.y + bounds.height);
         case SW: return new Point(bounds.x + bounds.width, bounds.y);
         case SE: return new Point(bounds.x, bounds.y);
         return null;
    import java.io.*;
    * SimpleObjectReader is a small class to wrap around the usual ObjectStream
    * to shield you from the exception handling which we haven't yet gotten
    * to in class.
    * <P>It has just three methods of note: one to open a new file for reading,
    * one to read an object from an open file, and one to close the file when done.
    * <P>Any object that you attempt to read must properly implement the Serializable
    * interface. Here is a simple example that shows using the SimpleFileReader to
    * to rehydrate objects from a file and print them:
    * <PRE>
    * SimpleObjectReader reader = SimpleObjectReader.openFileForReading("shapes");
    * if (reader == null) {
    * System.out.println("Couldn't open file!");
    * return;
    * Object obj;
    * while ((obj = reader.readObject()) != null)
    * System.out.println(obj);
    * reader.close();
    * </PRE>
    * <P>You are free to edit or extend this class, but we don't expect that
    * you should need to make any changes.
    * @version 1.1 15/04/01
    * @author Julie Zelenski
    * @author (touched up by Ian A. Mason)
    public class SimpleObjectReader {
    private ObjectInputStream ois;
    * Opens a new file for reading. The filename can either be a relative
    * path, which will be relative to the working directory of the program
    * when started, or an absolute path. If the file exists and can be
    * opened, a new SimpleObjectReader is returned. If the file cannot be
    * opened (for any reason: wrong name, wrong path, lack of permissions, etc.)
    * null is returned.
    public static SimpleObjectReader openFileForReading(String filename){
         try {
         return new SimpleObjectReader(new ObjectInputStream(new FileInputStream(filename)));
         } catch(IOException e) {     
         return null;
    * Reads a single object from the file and returns it. If there are
    * no more objects in the file (i.e, we have reached the end of file),
    * null is returned null is returned. null is also
    * returned on any I/O error.
    public Object readObject (){
         try {
         return ois.readObject();
         } catch (IOException e) {
         e.printStackTrace();
         return null;
         } catch (ClassNotFoundException e) {
         e.printStackTrace();
         return null;
    * Closes the file when done reading. You should close a reader when
    * you are finished to release the OS resources for use by others.
    public void close (){
         try {
         ois.close();
         catch (IOException e) {}
    * Constructor is private so that only means to create a new reader
    * is through the static method which does error checking.
    private SimpleObjectReader(ObjectInputStream ois){
         this.ois = ois;
    import java.io.*;
    * SimpleObjectWriter is a small class to wrap around the usual
    * ObjectOutputStream to shield you from the exception handling
    * which we haven't yet gotten to in class.
    * <P>It has just three methods of note: one to open a new file for writing,
    * one to write an object to the file, and one to close the
    * the file when done.
    * <P>Here is a simple example that shows using the SimpleObjectWriter
    * to create a new file and write some objects into it:
    * <PRE>
    * SimpleObjectWriter writer =
    * SimpleObjectWriter.openFileForWriting("objects");
    * if (writer == null) {
    * System.out.println("Couldn't open file!");
    * return;
    * writer.writeObject("Here is a string");
    * writer.writeObject("And another one.");
    * writer.writeObject(new Date());
    * writer.close();
    * </PRE>
    * <P>You are free to edit or extend this class, but we don't expect that
    * you should need to make any changes.
    * @version 1.1 15/04/01
    * @author Julie Zelenski
    * @author (touched up by Ian A. Mason)
    public class SimpleObjectWriter {
    private ObjectOutputStream oos;
    * Opens a new file for writing. The filename can either be a relative
    * path, which will be relative to the working directory of the program
    * when started, or an absolute path. If the file can be created, a
    * new SimpleObjectWriter is returned. If the file already exists, this
    * will overwrite its content

    I'm not reading that either, but to help you for next time:
    - use more than 1 sentence to describe your problem
    - only post the RELEVANT code, or a small test program with the same problem if possible.
    At least you formatted it, I'll give you that.
    Cheers,
    Radish21
    PS. I think in this case, posting another (better worded) thread might be a good idea, because no one is going to read this one. In general though, don't :)

  • Swing bug?: scrolling BLIT_SCROLL_MODE painting JTextArea components hangs

    java version "1.5.0_04"
    Hello,
    When drawing JComponent Text Areas and dynamically scrolling, Java gets confused, gets the shivers and freezes when the viewport cannot get its arms around the canvas. ;)
    Possible problem at JViewport.scrollRectToVisible().
    When painting non-text area components eg. graphics circles, it is ok.
    Have provided example code. This code is based on the ScrollDemo2 example provided in the Sun Java
    Tutorial
    thanks,
    Anil Philip
    juwo LLC
    Usage: run program and repeatedly click the left mouse button near right boundary to create a new JComponent node each time and to force scrolling area to increase in size to the right.
    When the first node crosses the left boundary, then the scroll pane gets confused, gets the shivers and hangs.
    The other scroll modes are a bit better - but very slow leaving the toolbar (in the oroginal application) unpainted sometimes.
    * to show possible bug when in the default BLIT_SCROLL_MODE and with JTextArea components.
    * author: Anil Philip. juwo LLC. http://juwo.com
    * Usage: run program and repeatedly click the left mouse button near right boundary to
    * create a new JComponent node each time and to force scrolling area to increase in size to the right.
    * When the first node crosses the left boundary, then the scroll pane gets confused, gets the shivers
    and hangs.
    * The other scroll modes are a bit better - but very slow leaving the toolbar (in the oroginal
    application)
    * unpainted sometimes.
    * This code is based on the ScrollDemo2 example provided in the Sun Java Tutorial (written by John
    Vella, a tutorial reader).
    import javax.swing.*;
    import javax.swing.border.EtchedBorder;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    /* ScrollDemo2WithBug.java is a 1.5 application that requires no other files. */
    public class ScrollDemo2WithBug extends JPanel {
    private Dimension area; //indicates area taken up by graphics
    private Vector circles; //coordinates used to draw graphics
    private Vector components;
    private JPanel drawingPane;
    public ScrollDemo2WithBug() {
    super(new BorderLayout());
    area = new Dimension(0, 0);
    circles = new Vector();
    components = new Vector();
    //Set up the instructions.
    JLabel instructionsLeft = new JLabel(
    "Click left mouse button to place a circle.");
    JLabel instructionsRight = new JLabel(
    "Click right mouse button to clear drawing area.");
    JPanel instructionPanel = new JPanel(new GridLayout(0, 1));
    instructionPanel.add(instructionsLeft);
    instructionPanel.add(instructionsRight);
    //Set up the drawing area.
    drawingPane = new DrawingPane();
    drawingPane.setBackground(Color.white);
    drawingPane.setPreferredSize(new Dimension(200, 200));
    //Put the drawing area in a scroll pane.
    JScrollPane scroller = new JScrollPane(drawingPane);
    // scroller.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
    if(scroller.getViewport().getScrollMode() == JViewport.BACKINGSTORE_SCROLL_MODE)
    System.out.println("BACKINGSTORE_SCROLL_MODE");
    if(scroller.getViewport().getScrollMode() == JViewport.BLIT_SCROLL_MODE)
    System.out.println("BLIT_SCROLL_MODE");
    if(scroller.getViewport().getScrollMode() == JViewport.SIMPLE_SCROLL_MODE)
    System.out.println("SIMPLE_SCROLL_MODE");
    //Lay out this demo.
    add(instructionPanel, BorderLayout.PAGE_START);
    add(scroller, BorderLayout.CENTER);
    /** The component inside the scroll pane. */
    public class DrawingPane extends JPanel implements MouseListener {
    private class VisualNode {
    int x = 0;
    int y = 0;
    int id = 0;
    public VisualNode(int id, int x, int y) {
    this.id = id;
    this.x = x;
    this.y = y;
    title.setLineWrap(true);
    title.setAlignmentY(Component.TOP_ALIGNMENT);
    titlePanel.add(new JButton("Hi!"));
    titlePanel.add(title);
    nodePanel.add(titlePanel);
    nodePanel.setBorder(BorderFactory
    .createEtchedBorder(EtchedBorder.RAISED));
    box.add(nodePanel);
    ScrollDemo2WithBug.this.drawingPane.add(box);
    Box box = Box.createVerticalBox();
    Box titlePanel = Box.createHorizontalBox();
    JTextArea title = new JTextArea(1, 10); // 1 rows x 10 cols
    Box nodePanel = Box.createVerticalBox();
    public void paintNode(Graphics g) {
    int ix = (int) x + ScrollDemo2WithBug.this.getInsets().left;
    int iy = (int) y + ScrollDemo2WithBug.this.getInsets().top;
    title.setText(id + " (" + ix + "," + iy + ") ");
    box.setBounds(ix, iy, box.getPreferredSize().width, box
    .getPreferredSize().height);
    int n = 0;
    DrawingPane() {
    this.setLayout(null);
    addMouseListener(this);
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.fill3DRect(10, 10, 25, 25, true);
    Point point;
    for (int i = 0; i < circles.size(); i++) {
    point = (Point) circles.elementAt(i);
    VisualNode node = (VisualNode) components.get(i);
    node.paintNode(g);
    //Handle mouse events.
    public void mouseReleased(MouseEvent e) {
    final int W = 100;
    final int H = 100;
    boolean changed = false;
    if (SwingUtilities.isRightMouseButton(e)) {
    //This will clear the graphic objects.
    circles.removeAllElements();
    area.width = 0;
    area.height = 0;
    changed = true;
    } else {
    int x = e.getX() - W / 2;
    int y = e.getY() - H / 2;
    if (x < 0)
    x = 0;
    if (y < 0)
    y = 0;
    Point point = new Point(x, y);
    VisualNode node = new VisualNode(circles.size(), point.x,
    point.y);
    // add(node);
    components.add(node);
    circles.addElement(point);
    drawingPane.scrollRectToVisible(new Rectangle(x, y, W, H));
    int this_width = (x + W + 2);
    if (this_width > area.width) {
    area.width = this_width;
    changed = true;
    int this_height = (y + H + 2);
    if (this_height > area.height) {
    area.height = this_height;
    changed = true;
    if (changed) {
    //Update client's preferred size because
    //the area taken up by the graphics has
    //gotten larger or smaller (if cleared).
    drawingPane.setPreferredSize(area);
    //Let the scroll pane know to update itself
    //and its scrollbars.
    drawingPane.revalidate();
    drawingPane.repaint();
    public void mouseClicked(MouseEvent e) {
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    public void mousePressed(MouseEvent e) {
    * Create the GUI and show it. For thread safety, this method should be
    * invoked from the event-dispatching thread.
    private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("ScrollDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    JComponent newContentPane = new ScrollDemo2WithBug();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.setSize(800, 600);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }

    I changed the name so you can run this as-is without name clashing. It works okay now.
    import javax.swing.*;
    import javax.swing.border.EtchedBorder;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class SD2 extends JPanel {
        public SD2() {
            super(new BorderLayout());
            //Set up the instructions.
            JLabel instructionsLeft = new JLabel(
                    "Click left mouse button to place a circle.");
            JLabel instructionsRight = new JLabel(
                    "Click right mouse button to clear drawing area.");
            JPanel instructionPanel = new JPanel(new GridLayout(0, 1));
            instructionPanel.add(instructionsLeft);
            instructionPanel.add(instructionsRight);
            //Set up the drawing area.
            DrawingPane drawingPane = new DrawingPane(this);
            drawingPane.setBackground(Color.white);
            drawingPane.setPreferredSize(new Dimension(200, 200));
            //Put the drawing area in a scroll pane.
            JScrollPane scroller = new JScrollPane(drawingPane);
            // scroller.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
            if(scroller.getViewport().getScrollMode() == JViewport.BACKINGSTORE_SCROLL_MODE)
                System.out.println("BACKINGSTORE_SCROLL_MODE");
            if(scroller.getViewport().getScrollMode() == JViewport.BLIT_SCROLL_MODE)
                System.out.println("BLIT_SCROLL_MODE");
            if(scroller.getViewport().getScrollMode() == JViewport.SIMPLE_SCROLL_MODE)
                System.out.println("SIMPLE_SCROLL_MODE");
            //Lay out this demo.
            add(instructionPanel, BorderLayout.PAGE_START);
            add(scroller, BorderLayout.CENTER);
         * Create the GUI and show it. For thread safety, this method should be
         * invoked from the event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("ScrollDemo2");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new SD2();
            newContentPane.setOpaque(true);      //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.setSize(800, 600);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    /** The component inside the scroll pane. */
    class DrawingPane extends JPanel implements MouseListener {
        SD2 sd2;
        private Dimension area;     //indicates area taken up by graphics
        private Vector circles;     //coordinates used to draw graphics
        private Vector components;
        int n = 0;
        final int
            W = 100,
            H = 100;
        DrawingPane(SD2 sd2) {
            this.sd2 = sd2;
            area = new Dimension(0, 0);
            circles = new Vector();
            components = new Vector();
            this.setLayout(null);
            addMouseListener(this);
         * The 'paint' method is a Container method and it passes its
         * Graphics context, g, to each of its Component children which
         * use it to draw themselves into the parent. JComponent overrides
         * this Container 'paint' method and in it calls this method in
         * addition to others - see api. So the children of DrawingPane will
         * each paint themselves. Here you can do custom painting/rendering.
         * But this is not the place to ask components to paint themselves.
         * That would get swing very confused...
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.fill3DRect(10, 10, 25, 25, true);
            g.setColor(Color.red);
            Point point;
            for (int i = 0; i < circles.size(); i++) {
                point = (Point) circles.elementAt(i);
                g.fillOval(point.x-2, point.y-2, 4, 4);
        //Handle mouse events.
        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                //This will clear the graphic objects.
                circles.removeAllElements();
                components.removeAllElements();
                removeAll();                    // to clear the components
                area.width = 0;
                area.height = 0;
                setPreferredSize(area);
                revalidate();
                repaint();
            } else {
                int x = e.getX() - W / 2;
                int y = e.getY() - H / 2;
                if (x < 0)
                    x = 0;
                if (y < 0)
                    y = 0;
                Point point = new Point(x, y);
                VisualNode node = new VisualNode(this, circles.size(), point.x, point.y);
                // add(node);
                components.add(node);       // not needed
                circles.addElement(point);
                checkBoundries(x, y, node);
        private void checkBoundries(int x, int y, VisualNode node) {
            boolean changed = false;
            // since we used the setPreferredSize property to set the size
            // of each box we'll have to use it again to let the JScrollPane
            // know what size we need to show all our child components
            int this_width = (x + node.box.getPreferredSize().width + 2);
            if (this_width > area.width) {
                area.width = this_width;
                changed = true;
            int this_height = (y + node.box.getPreferredSize().height + 2);
            if (this_height > area.height) {
                area.height = this_height;
                changed = true;
            if (changed) {
                //Update client's preferred size because
                //the area taken up by the graphics has
                //gotten larger or smaller (if cleared).
                setPreferredSize(area);
                scrollRectToVisible(new Rectangle(x, y, W, H));
                //Let the scroll pane know to update itself
                //and its scrollbars.
                revalidate();
            repaint();
        public void mouseReleased(MouseEvent e) { }
        public void mouseClicked(MouseEvent e)  { }
        public void mouseEntered(MouseEvent e)  { }
        public void mouseExited(MouseEvent e)   { }
    * We are adding components to DrawingPanel so there is no need to get
    * into the paint methods of DrawingPane. Components are designed to draw
    * themseleves when their parent container passes them a Graphics context
    * and asks them to paint themselves into the parent.
    class VisualNode {
        DrawingPane drawPane;
        int x;
        int y;
        int id;
        Box box;
        public VisualNode(DrawingPane dp, int id, int x, int y) {
            drawPane = dp;
            this.id = id;
            this.x = x;
            this.y = y;
            box = Box.createVerticalBox();
            Box titlePanel = Box.createHorizontalBox();
            JTextArea title = new JTextArea(1, 10);     // 1 rows x 10 cols
            Box nodePanel = Box.createVerticalBox();
            title.setLineWrap(true);
            title.setAlignmentY(Component.TOP_ALIGNMENT);
            titlePanel.add(new JButton("Hi!"));
            titlePanel.add(title);
            nodePanel.add(titlePanel);
            nodePanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
            box.add(nodePanel);
            // here we are adding a component to drawPane so there is really
            // no need to keep this VisualNode in a collection
            drawPane.add(box);
            int ix = (int) x + drawPane.getInsets().left;
            int iy = (int) y + drawPane.getInsets().top;
            title.setText(id + " (" + ix + "," + iy + ") ");
            // since we are using the preferredSize property to setBounds here
            // we'll need access to it (via box) for the scrollPane in DrawPane
            // so we expose box as a member variable
            box.setBounds(ix, iy, box.getPreferredSize().width,
                                  box.getPreferredSize().height);
    }

  • Intermittent MousePressed Events

    I am having trouble with mouse pressed events. I have a JFrame with 2 images in JPanels, with a separate JComponent sindow that will display one or the other image with a delay. It flickers between the 2 images using a thread. The JPanel responds to MousePressed events with the flickering turned off. When it is turned on the mouse pressed events are intermittent, I placed a print statement in the MousePressed method and I have to keep clicking the mouse to get it to work.
    Has anyone seen MousePressed problems with threads before?
    Thanks, Greg

    I am afraid it was my own bug :(
    I had reimplemented processMouseEvent() in my subclass of JTextPane to consume mouse events in the margin area if the click count was >1 thinking this applied only to mouse clicks and not mouse pressed.
    Still had the issue of the JTextPane itself being a mouse listener to do text selection (word for double click, line for triple click). So what I did was : if the click was in the margin area I would determine if it was the type i needed (pressed) and pass the event to my listener and otherwise not pass it to the super method. So all solved now. :)
    I prepared a small test - obstensibly to post - but that showed it was indeed my bug and after more searching found the answer. It is quite a big project with parts written many years ago. Even so, a bit red faced now ...

  • Bug: JTabbedPane setTabLayoutPolicy in 1.4

    I noticed weird behavior when using setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT). When adding a MouseListener to a JTabbedPane with this property set (it's a recent addition since 1.4), mouseClicked, mouseReleased, and mousePressed events do not occur. These events don't occur when clicked on the tab name (it works in other various areas though), but this is not standard behavior. When adding a MouseListener to a JTabbedPane, these events should occur no matter where you clicked on the JTabbedPane. Expected results are received with the default value, setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT). Here's someone else (the only other person I know) who experienced this problem:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=185937
    Try running his code (my code is too long to show, it's part of a big project) and let me know if this bug exists for whatever operating system you use. Could anyone let me know if there's a workaround for this problem? I filed this bug and I hope Sun will fix it soon :) Thanks.

    I dunno whether its a bug or not but in my old application Tab key stopped working when run on JRE1.4.1!
    And if I had Java Console open Tab worked fine (earlier we were using JRE1.3 plugin, now I tried the application on JRE1.4.1 ).
    Only after setting the myApplet.FocusCycleRoot(true) did it started working again.
    Cheers,
    Amit

  • Javax.print problems on applet - bug on mac os implementation?

    Dear All,
    I am working on an applet and application that include a print function and I get a weird behaviour on MacOS in applet mode (both with Safari and Firefox - Mac OS X Versione 10.4.9 (Build 8P135) ). In contrast, things work fine on Windows XP (both Explorer 7 and Firefox with Java Plug-in 1.6.0_01) and even in MacOS when using the application.
    The problems are:
    - the print dialogue goes on and off a few times before letting the user interact with it
    - the page format in the dialogue is set to A5 (instead of the printer's default)
    - there is a small empty window appearing together with the dialogue and not disappearing even after the applet is closed
    Is this a known problem? If so, are there work-arounds?
    (I had no luck on Google about this)
    To reproduce the problem I created a stripped down version of the applet, in 2 files, I report it at the bottom of this message. I am using a modified version the PrintUtilities class from http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html
    Am I doing something wrong? Or shall I consider submitting a bug report?
    Any suggestion is welcome! Please let me know if I should provide more detailed information.
    Thank you in advance,
    Enrico
    PrintMe.java
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    public class PrintMe extends JApplet implements MouseListener{
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         public PrintMe() {
              super();
         private class MyComponent extends JPanel{
              private static final long serialVersionUID = 1L;
              public void paintComponent(Graphics g) {
                   super.paintComponent(g);
                  Graphics2D g2 = (Graphics2D) g;
                  g2.setColor(Color.black);
                  g2.drawString( "Test text", 0, g2.getFontMetrics().getHeight() );
         public void init() {
              MyComponent aComponent = new MyComponent();
              jContentPane = new JPanel();
              jContentPane.setLayout(new BorderLayout());
              jContentPane.add(aComponent);
              this.setContentPane(jContentPane);
              this.addMouseListener(this);
         public void print(){
              try{
                   PrintUtilities.printComponent(this);
              }catch (Exception e) {
                   e.printStackTrace();
         public void mouseClicked(MouseEvent e) {
              print();
         public void mouseEntered(MouseEvent e) {
              // not used
         public void mouseExited(MouseEvent e) {
              // not used
         public void mousePressed(MouseEvent e) {
              // not used
         public void mouseReleased(MouseEvent e) {
              // not used
    PrintUtilities.java
    import java.awt.Component;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.swing.RepaintManager;
    import javax.swing.RootPaneContainer;
    /** A simple utility class that lets you very simply print
    *  an arbitrary component. Just pass the component to the
    *  PrintUtilities.printComponent. The component you want to
    *  print doesn't need a print method and doesn't have to
    *  implement any interface or do anything special at all.
    *  If you are going to be printing many times, it is marginally more
    *  efficient to first do the following:
    *    PrintUtilities printHelper = new PrintUtilities(theComponent);
    *  then later do printHelper.print(). But this is a very tiny
    *  difference, so in most cases just do the simpler
    *  PrintUtilities.printComponent(componentToBePrinted).
    *  7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/
    *  May be freely used or adapted.
    public class PrintUtilities implements Printable {
         private Component componentToBePrinted;
         public static void printComponent(Component c) {
              new PrintUtilities(c).print();
         public PrintUtilities(Component componentToBePrinted) {
              this.componentToBePrinted = componentToBePrinted;
         public void print() {
              try{
                   PrinterJob printJob = PrinterJob.getPrinterJob();
                   printJob.setPrintable(this);
                   PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
                   if( printJob.printDialog(attributes) ){
                        try {
                             printJob.setJobName("MyName");
                             printJob.print(attributes);
                        } catch(PrinterException pe) {
                             System.err.println("Error printing: " + pe);
                             pe.printStackTrace();
              }catch (Exception e) {
                   e.printStackTrace();
         public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
              if (pageIndex > 0) {
                   return(NO_SUCH_PAGE);
              } else {
                   RootPaneContainer rpc = (RootPaneContainer)(this.componentToBePrinted);
                   rpc.getRootPane().getGlassPane().setVisible( false );
                   Graphics2D g2d = (Graphics2D)g;
                   double sy = pageFormat.getImageableHeight() / componentToBePrinted.getHeight();
                   double sx = pageFormat.getImageableWidth() / componentToBePrinted.getWidth();
                   if( sx > sy ){
                        sx = sy;
                   }else{
                        sy = sx;
                   g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
                   g2d.scale(sx, sy);
                   disableDoubleBuffering(componentToBePrinted);
                   componentToBePrinted.paint(g2d);
                   enableDoubleBuffering(componentToBePrinted);
                   return(PAGE_EXISTS);
         /** The speed and quality of printing suffers dramatically if
          *  any of the containers have double buffering turned on.
          *  So this turns if off globally.
          *  @see enableDoubleBuffering
         public static void disableDoubleBuffering(Component c) {
              RepaintManager currentManager = RepaintManager.currentManager(c);
              currentManager.setDoubleBufferingEnabled(false);
         /** Re-enables double buffering globally. */
         public static void enableDoubleBuffering(Component c) {
              RepaintManager currentManager = RepaintManager.currentManager(c);
              currentManager.setDoubleBufferingEnabled(true);
    }

    Trying to answer to myself..
    Is it possible that the problems are due to me mixing java.awt.print and javax.swing.print ?

  • Bug when using JComboBox as JTable CellEditor

    Hello! I have a JTable that displays database information, and one of the columns is editable using a JComboBox. When the user selects an item from the JComboBox, the database (and consequently the JTable) is updated with the new value.
    Everything works fine except for a serious and subtle bug. To explain what happens, here is an example. If Row 1 has the value "ABC" and the user selects the editable column on that row, the JComboBox drops down with the existing value "ABC" already selected (this is the default behavior, not something I implemented). Now, if the user does not select a new value from the JComboBox, and instead selects the editable column on Row 2 that contains "XYZ", Row 1 gets updated to contain "XYZ"!
    The reason that is happening is because I'm updating the database by responding to the ActionListener.actionPerformed event in the JComboBox, and when a new row is selected, the actionPerformed event gets fired BEFORE the JTable's selected row index gets updated. So the old row gets updated with the new row's information, even though the user never actually selected a new item in the JComboBox.
    If I use ItemListener.itemStateChanged instead, I get the same results. If I use MouseListener.mousePressed/Released I get no events at all for the JComboBox list selection. If anyone else has encountered this problem and found a workaround, I would very much appreciate knowing what you did. Here are the relavent code snippets:
    // In the dialog containing JTable:
    JComboBox cboRouteType = new JComboBox(new String[]{"ABC", "XYZ"));
    cboRouteType.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
              doCboRouteTypeSelect((String)cboRouteType.getSelectedItem());
    private void doCboRouteTypeSelect(String selItem) {
         final RouteEntry selRoute = tblRoutes.getSelectedRoute();
         if (selRoute == null) { return; }
         RouteType newType = RouteType.fromString(selItem);
         // Only update the database if the value was actually changed.
         if (selRoute.getRouteType() == newType) { return; }
         RouteType oldType = selRoute.getRouteType();
         selRoute.setRouteType(newType);
         // (update the db below)
    // In the JTable:
    public RouteEntry getSelectedRoute() {
         int selIndx = getSelectedRow();
         if (selIndx < 0) return null;
         return model.getRouteAt(selIndx);
    // In the TableModel:
    private Vector<RouteEntry> vRoutes = new Vector<RouteEntry>();
    public RouteEntry getRouteAt(int indx) { return vRoutes.get(indx); }

    Update: I was able to resolve this issue. In case anyone is curious, the problem was caused by using the actionPerformed method in the first place. Apparently when the JComboBox is used as a table cell editor, it calls setValueAt on my table model and that's where I'm supposed to respond to the selection.
    Obviously the table itself shouldn't be responsible for database updates, so I had to create a CellEditListener interface and implement it from the class that actually does the DB update in a thread and is capable of reporting SQL exceptions to the user. All that work just to let the user update the table/database with a dropdown. Sheesh!

  • Does CDC work on spatial tables?

    I'm trying to prototype using change data capture on some spatial tables. I'm able to create the cdc tables and subsribe, etc. with no errors. But when I go to try and update a record in my spatial table I keep getting the following errors:
    ERROR at line 1:
    ORA-31495: error in synchronous change table on "FULL"."GEONAME_FEATURE"
    ORA-01733: virtual column not allowed here
    My non-spatial tables that I set up the same way work fine for updates and inserts.
    The spatial CDC table and the base spatial table look the same. Is there something about Spatial that prohibits it from being used with change data capture?

    This might be related to bug 3561140 - we are working with the appropriate folks in Oracle to try to resolve it. If you can post your view definition then we can try to ensure this is fixed at the same time (a small test case would be appreciated).

  • Oracle CDC - Incorrect data in change tables

    We are using Asynchronous autolog online CDC and the performance has been pretty good so far.
    However, recently we have encountered an issue where there are a couple of invalid records in one of the change tables.
    The change table seems to have update transactions on a record that had no updates made to it. In fact the updated records in the change table indicate a primary key that does not exist on the source table. Has anyone encountered a similar issue ? the data that has been brought over on one of the number columns is something like
    xm<<1123.
    gk

    Thanks Justin. On digging further into metalink I found another bug 6454634 which appears to be similar. Both this and the bug mentioned by you are fixed in 10.2.0.4 patch 14. I will follow up further.

  • BUG: ClassCastException in Business Component Browser

    I am consistently getting a ClassCastException when I use the Business Component Browser in JDev 9.0.3.1.
    Details: This bug was encountered in one of the hands-on practices given in the Oracle Press book Oracle 9i JDeveloper Handbook.
    I have an entity object with an Email attribute based on a user-defined domain, EmailDomain, which in turn is based on the String type. The validate() method in the EmailDomain.java class implements a simple check on email addresses. When I use the Business Component Browser to view records in the corresponding view object, I have no problem changing values for the email address so long as they adhere to the validation rule. However, when I input an invalid value and attempt to change the focus to another field, the ClassCastException occurs with the following stack trace:
    Exception occurred during event dispatching:
    java.lang.ClassCastException: javax.swing.JViewport
         boolean oracle.jbo.jbotester.JBOFieldHelper.setDataValue(java.lang.Object)
              JBOFieldHelper.java:115
         boolean oracle.jbo.jbotester.JBOFieldHelper.applyEdit()
              JBOFieldHelper.java:149
         void oracle.jbo.jbotester.JBOFieldHelper$DefaultJBOFocusListener.focusLost(java.awt.event.FocusEvent)
              JBOFieldHelper.java:194
         void java.awt.AWTEventMulticaster.focusLost(java.awt.event.FocusEvent)
              AWTEventMulticaster.java:171
         void java.awt.Component.processFocusEvent(java.awt.event.FocusEvent)
              Component.java:3642
         void javax.swing.JComponent.processFocusEvent(java.awt.event.FocusEvent)
              JComponent.java:1980
         void java.awt.Component.processEvent(java.awt.AWTEvent)
              Component.java:3535
         void java.awt.Container.processEvent(java.awt.AWTEvent)
              Container.java:1164
         void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
              Component.java:2593
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
              Container.java:1213
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
              Component.java:2497
         boolean java.awt.LightweightDispatcher.setFocusRequest(java.awt.Component)
              Container.java:2076
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1335
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Container.proxyRequestFocus(java.awt.Component)
              Container.java:1330
         void java.awt.Component.requestFocus()
              Component.java:4174
         void javax.swing.JComponent.grabFocus()
              JComponent.java:915
         void javax.swing.JComponent.requestFocus()
              JComponent.java:897
         void javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent)
              DefaultCaret.java:315
         void java.awt.AWTEventMulticaster.mousePressed(java.awt.event.MouseEvent)
              AWTEventMulticaster.java:221
         void java.awt.AWTEventMulticaster.mousePressed(java.awt.event.MouseEvent)
              AWTEventMulticaster.java:220
         void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
              Component.java:3712
         void java.awt.Component.processEvent(java.awt.AWTEvent)
              Component.java:3544
         void java.awt.Container.processEvent(java.awt.AWTEvent)
              Container.java:1164
         void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
              Component.java:2593
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
              Container.java:1213
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
              Component.java:2497
         void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
              Container.java:2451
         boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
              Container.java:2210
         boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
              Container.java:2125
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
              Container.java:1200
         void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
              Window.java:922
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
              Component.java:2497
         void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
              EventQueue.java:339
         boolean java.awt.EventDispatchThread.pumpOneEventForHierarchy(java.awt.Component)
              EventDispatchThread.java:131
         void java.awt.EventDispatchThread.pumpEventsForHierarchy(java.awt.Conditional, java.awt.Component)
              EventDispatchThread.java:98
         void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
              EventDispatchThread.java:93
         void java.awt.EventDispatchThread.run()
              EventDispatchThread.java:85
    The Business Component Browser then stops responding correctly to focus and input events, and has to be terminated and restarted to start working correctly again.

    Hi Alan,
    This is Bug 2710133 (I first noticed it in release 9.0.4, but it seems that it was introduced in 9.0.3.1). You're correct; the Business Component Browser is not correctly dealing with exceptions thrown by validateEntity(). We're working to re-fix this bug.
    (Note that this is just a problem with the Browser, not the BC4J framework itself. The code should still work in an actual application.)
    Best,
    Avrom

  • [2 Bugs] BC4J/JClient 9.0.3 JComboBox + LOV Binding

    I may have stumbled across some other bugs.. Here's how you may reproduce them:
    2 Tables (both are filled with proper values, PK's and FK's are set):
    EMP(ID: NUMBER, DESC: VARCHAR2, DEPT_ID: NUMBER)
    DEPT(ID: NUMBER, DESC: VARCHAR2)
    All appropriate ViewObjects and stuff have been generated and are in place.
    I have a JClient Panel and on it sits a JComboBox.
    The model of the JComboBox is set through the property editor to a
    JClient LOV Binding which looks as follows: DEPT.ID goes into EMP.DEPT_ID
    and the displayed LOV attribute is: DEPT.DESC
    Now, when I run the program, I attempt to select a new value from the JComboBox.
    This will succeed, but as soon as the JComboBox looses focus, I get this exception:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:
    oracle.jbo.domain.Number with value: <insert displayed value in JComboBox here>When I add DEPT.ID to the displayed LOV attributes, no exception is thrown.
    That's because the String "(some number) (spaces) (some string)" will in
    fact be parsed to a valid number.
    However, because of this measure, only the DEPT.ID will be shown in the JComboBox
    when it's in its 'closed state'.
    This leads me to the second bug. When selecting multiple attributes to be
    displayed into the JComboBox, the order in which I put them doesn't seem to
    'stick'. Everytime the ID attribute is first and the rest follows in the same
    order in which the table's columns have been defined. Re-ordering them
    manually in the property editor, doesn't seem to help. The order will be
    forgotten after I close and re-open the property editor.
    The first bug doesn't seem to have any real negative effect. The new value
    is stored nonetheless; after committing and restarting the application,
    all new values are still available.
    (Stack Trace follows)
    Hope This Helps
    Arno

    As promised, here's the stack trace. The 'offending' value is "Rubriek".
    Exception occurred during event dispatching:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Number with value:Rubriek
      java.lang.Object oracle.jbo.domain.TypeFactory.get(java.lang.Class, java.lang.Class, java.lang.Object)
        TypeFactory.java:713
      java.lang.Object oracle.jbo.domain.TypeFactory.getInstance(java.lang.Class, java.lang.Object)
        TypeFactory.java:80
      int oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndex(java.lang.Object)
        JUCtrlListBinding.java:567
      java.lang.Object oracle.jbo.uicli.binding.JUCtrlListBinding.findMatchingListValue(java.lang.Object)
        JUCtrlListBinding.java:425
      java.lang.Object oracle.jbo.uicli.controls.JUMultiAttrListEditor.getItem()
        JUMultiAttrListEditor.java:65
      void javax.swing.plaf.basic.BasicComboBoxUI$EditorFocusListener.focusLost(java.awt.event.FocusEvent)
        BasicComboBoxUI.java:1394
      void java.awt.AWTEventMulticaster.focusLost(java.awt.event.FocusEvent)
        AWTEventMulticaster.java:171
      void java.awt.Component.processFocusEvent(java.awt.event.FocusEvent)
        Component.java:3642
      void javax.swing.JComponent.processFocusEvent(java.awt.event.FocusEvent)
        JComponent.java:1980
      void java.awt.Component.processEvent(java.awt.AWTEvent)
        Component.java:3535
      void java.awt.Container.processEvent(java.awt.AWTEvent)
        Container.java:1164
      void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
        Component.java:2593
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1213
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      boolean java.awt.LightweightDispatcher.setFocusRequest(java.awt.Component)
        Container.java:2076
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1335
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Component.requestFocus()
        Component.java:4174
      void javax.swing.JComponent.grabFocus()
        JComponent.java:915
      void javax.swing.JComponent.requestFocus()
        JComponent.java:897
      void javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent)
        DefaultCaret.java:315
      void java.awt.AWTEventMulticaster.mousePressed(java.awt.event.MouseEvent)
        AWTEventMulticaster.java:221
      void java.awt.AWTEventMulticaster.mousePressed(java.awt.event.MouseEvent)
        AWTEventMulticaster.java:220
      void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
        Component.java:3712
      void java.awt.Component.processEvent(java.awt.AWTEvent)
        Component.java:3544
      void java.awt.Container.processEvent(java.awt.AWTEvent)
        Container.java:1164
      void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
        Component.java:2593
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1213
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
        Container.java:2451
      boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
        Container.java:2210
      boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
        Container.java:2125
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1200
      void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
        Window.java:922
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
        EventQueue.java:339
      boolean java.awt.EventDispatchThread.pumpOneEventForHierarchy(java.awt.Component)
        EventDispatchThread.java:131
      void java.awt.EventDispatchThread.pumpEventsForHierarchy(java.awt.Conditional, java.awt.Component)
        EventDispatchThread.java:98
      void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
        EventDispatchThread.java:93
      void java.awt.EventDispatchThread.run()
        EventDispatchThread.java:85
    ## Detail 0 ##
    java.lang.NumberFormatException: k
      int java.lang.Integer.parseInt(java.lang.String, int)
        Integer.java:414
      int java.lang.Integer.parseInt(java.lang.String)
        Integer.java:463
      void java.math.BigDecimal.<init>(java.lang.String)
        BigDecimal.java:149
      void oracle.jbo.domain.Number.<init>(java.lang.String)
        Number.java:258
      java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[])
        native code
      java.lang.Object oracle.jbo.domain.TypeConvMapEntry.convert(java.lang.Class, java.lang.Class, java.lang.Object)
        TypeConvMapEntry.java:66
      java.lang.Object oracle.jbo.domain.TypeFactory.get(java.lang.Class, java.lang.Class, java.lang.Object)
        TypeFactory.java:681
      java.lang.Object oracle.jbo.domain.TypeFactory.getInstance(java.lang.Class, java.lang.Object)
        TypeFactory.java:80
      int oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndex(java.lang.Object)
        JUCtrlListBinding.java:567
      java.lang.Object oracle.jbo.uicli.binding.JUCtrlListBinding.findMatchingListValue(java.lang.Object)
        JUCtrlListBinding.java:425
      java.lang.Object oracle.jbo.uicli.controls.JUMultiAttrListEditor.getItem()
        JUMultiAttrListEditor.java:65
      void javax.swing.plaf.basic.BasicComboBoxUI$EditorFocusListener.focusLost(java.awt.event.FocusEvent)
        BasicComboBoxUI.java:1394
      void java.awt.AWTEventMulticaster.focusLost(java.awt.event.FocusEvent)
        AWTEventMulticaster.java:171
      void java.awt.Component.processFocusEvent(java.awt.event.FocusEvent)
        Component.java:3642
      void javax.swing.JComponent.processFocusEvent(java.awt.event.FocusEvent)
        JComponent.java:1980
      void java.awt.Component.processEvent(java.awt.AWTEvent)
        Component.java:3535
      void java.awt.Container.processEvent(java.awt.AWTEvent)
        Container.java:1164
      void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
        Component.java:2593
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1213
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      boolean java.awt.LightweightDispatcher.setFocusRequest(java.awt.Component)
        Container.java:2076
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1335
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Container.proxyRequestFocus(java.awt.Component)
        Container.java:1330
      void java.awt.Component.requestFocus()
        Component.java:4174
      void javax.swing.JComponent.grabFocus()
        JComponent.java:915
      void javax.swing.JComponent.requestFocus()
        JComponent.java:897
      void javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent)
        DefaultCaret.java:315
      void java.awt.AWTEventMulticaster.mousePressed(java.awt.event.MouseEvent)
        AWTEventMulticaster.java:221
      void java.awt.AWTEventMulticaster.mousePressed(java.awt.event.MouseEvent)
        AWTEventMulticaster.java:220
      void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
        Component.java:3712
      void java.awt.Component.processEvent(java.awt.AWTEvent)
        Component.java:3544
      void java.awt.Container.processEvent(java.awt.AWTEvent)
        Container.java:1164
      void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
        Component.java:2593
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1213
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
        Container.java:2451
      boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
        Container.java:2210
      boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
        Container.java:2125
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1200
      void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
        Window.java:922
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
        EventQueue.java:339
      boolean java.awt.EventDispatchThread.pumpOneEventForHierarchy(java.awt.Component)
        EventDispatchThread.java:131
      void java.awt.EventDispatchThread.pumpEventsForHierarchy(java.awt.Conditional, java.awt.Component)
        EventDispatchThread.java:98
      void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
        EventDispatchThread.java:93
      void java.awt.EventDispatchThread.run()
        EventDispatchThread.java:85
    Exception occurred during event dispatching:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Number with value:Rubriek
      java.lang.Object oracle.jbo.domain.TypeFactory.get(java.lang.Class, java.lang.Class, java.lang.Object)
        TypeFactory.java:713
      java.lang.Object oracle.jbo.domain.TypeFactory.getInstance(java.lang.Class, java.lang.Object)
        TypeFactory.java:80
      int oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndex(java.lang.Object)
        JUCtrlListBinding.java:567
      java.lang.Object oracle.jbo.uicli.binding.JUCtrlListBinding.findMatchingListValue(java.lang.Object)
        JUCtrlListBinding.java:425
      java.lang.Object oracle.jbo.uicli.controls.JUMultiAttrListEditor.getItem()
        JUMultiAttrListEditor.java:65
      void javax.swing.plaf.basic.BasicComboBoxUI$EditorFocusListener.focusLost(java.awt.event.FocusEvent)
        BasicComboBoxUI.java:1394
      void java.awt.AWTEventMulticaster.focusLost(java.awt.event.FocusEvent)
        AWTEventMulticaster.java:171
      void java.awt.Component.processFocusEvent(java.awt.event.FocusEvent)
        Component.java:3642
      void javax.swing.JComponent.processFocusEvent(java.awt.event.FocusEvent)
        JComponent.java:1980
      void java.awt.Component.processEvent(java.awt.AWTEvent)
        Component.java:3535
      void java.awt.Container.processEvent(java.awt.AWTEvent)
        Container.java:1164
      void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
        Component.java:2593
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1213
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      boolean java.awt.LightweightDispatcher.processFocusEvent(java.awt.event.FocusEvent)
        Container.java:2167
      boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
        Container.java:2130
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1200
      void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
        Window.java:922
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
        EventQueue.java:339
      boolean java.awt.EventDispatchThread.pumpOneEventForHierarchy(java.awt.Component)
        EventDispatchThread.java:131
      void java.awt.EventDispatchThread.pumpEventsForHierarchy(java.awt.Conditional, java.awt.Component)
        EventDispatchThread.java:98
      void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
        EventDispatchThread.java:93
      void java.awt.EventDispatchThread.run()
        EventDispatchThread.java:85
    ## Detail 0 ##
    java.lang.NumberFormatException: k
      int java.lang.Integer.parseInt(java.lang.String, int)
        Integer.java:414
      int java.lang.Integer.parseInt(java.lang.String)
        Integer.java:463
      void java.math.BigDecimal.<init>(java.lang.String)
        BigDecimal.java:149
      void oracle.jbo.domain.Number.<init>(java.lang.String)
        Number.java:258
      java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[])
        native code
      java.lang.Object oracle.jbo.domain.TypeConvMapEntry.convert(java.lang.Class, java.lang.Class, java.lang.Object)
        TypeConvMapEntry.java:66
      java.lang.Object oracle.jbo.domain.TypeFactory.get(java.lang.Class, java.lang.Class, java.lang.Object)
        TypeFactory.java:681
      java.lang.Object oracle.jbo.domain.TypeFactory.getInstance(java.lang.Class, java.lang.Object)
        TypeFactory.java:80
      int oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndex(java.lang.Object)
        JUCtrlListBinding.java:567
      java.lang.Object oracle.jbo.uicli.binding.JUCtrlListBinding.findMatchingListValue(java.lang.Object)
        JUCtrlListBinding.java:425
      java.lang.Object oracle.jbo.uicli.controls.JUMultiAttrListEditor.getItem()
        JUMultiAttrListEditor.java:65
      void javax.swing.plaf.basic.BasicComboBoxUI$EditorFocusListener.focusLost(java.awt.event.FocusEvent)
        BasicComboBoxUI.java:1394
      void java.awt.AWTEventMulticaster.focusLost(java.awt.event.FocusEvent)
        AWTEventMulticaster.java:171
      void java.awt.Component.processFocusEvent(java.awt.event.FocusEvent)
        Component.java:3642
      void javax.swing.JComponent.processFocusEvent(java.awt.event.FocusEvent)
        JComponent.java:1980
      void java.awt.Component.processEvent(java.awt.AWTEvent)
        Component.java:3535
      void java.awt.Container.processEvent(java.awt.AWTEvent)
        Container.java:1164
      void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
        Component.java:2593
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1213
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      boolean java.awt.LightweightDispatcher.processFocusEvent(java.awt.event.FocusEvent)
        Container.java:2167
      boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
        Container.java:2130
      void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
        Container.java:1200
      void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
        Window.java:922
      void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
        Component.java:2497
      void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
        EventQueue.java:339
      boolean java.awt.EventDispatchThread.pumpOneEventForHierarchy(java.awt.Component)
        EventDispatchThread.java:131
      void java.awt.EventDispatchThread.pumpEventsForHierarchy(java.awt.Conditional, java.awt.Component)
        EventDispatchThread.java:98
      void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
        EventDispatchThread.java:93
      void java.awt.EventDispatchThread.run()
        EventDispatchThread.java:85

  • JFileChooser crashes JVM - bug basically ignored. What can I do?

    See:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7160713
    The bug has been marked as incomplete,needs more info, and "Low Prioroty" - Yet there is no mechanism to provide any more information. There is no way to add comments, or vote. The bug brings down the entire JVM with a native crash and it is trivial to reproduce.
    I would provide any information that is asked of me - but I need a way to do it. I think I got an email request for info (It's been a while now), but replies to the email bounced, and as noted above the bug page has no way to give feedback.
    Use any JFileChooser, click on the "Details" view. Then start clicking on column headings... after a few clicks the JVM crashes. Tested again with 7u6 - still crashes.

    This reproduces the problem more reliably for me.
    * JFileChooser Windows Crash
    package filechoosercrash;
    import java.awt.AWTEvent;
    import java.awt.BorderLayout;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.Window;
    import java.awt.event.AWTEventListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.InputEvent;
    import java.util.concurrent.CountDownLatch;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.LookAndFeel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UIManager.LookAndFeelInfo;
    import javax.swing.UnsupportedLookAndFeelException;
    * @author scott
    public class FileChooserCrash {
         static CountDownLatch latch = new CountDownLatch(1);
         static JFrame frame;
         static JButton button;
         static JFileChooser chooser;
         static Robot robot;
         private static AWTEventListener terminator = new AWTEventListener() {
              @Override
              public void eventDispatched(AWTEvent event) {
                   System.exit(10);
          * @param args the command line arguments
         public static void main(final String[] args) throws Exception {
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        try {
                             swingMain(args);
                        } catch (Exception ex) {
                             Logger.getLogger(FileChooserCrash.class.getName()).log(Level.SEVERE, null, ex);
              latch.await();
              // do the clicks
              sleep(3000);
              Toolkit.getDefaultToolkit().addAWTEventListener(terminator, AWTEvent.KEY_EVENT_MASK);
              long now = System.currentTimeMillis();
              for (int c = 0; c < 10; c++) {
                   Window w = JDialog.getWindows()[1]; // better be there!
                   System.out.println("w=" + w);
                   int detailsX = w.getX() + w.getWidth() - 36;
                   int detailY = w.getY() + 50;
                   int headingY = w.getY() + 100;
                   System.out.println("details at " + detailsX + ", " + detailY);
                   // Click details
                   robot.mouseMove(detailsX, detailY);
                   clickMouse();
                   sleep(100);
                   // Click column headings
                   while (System.currentTimeMillis() - now < 2 * 1000) {
                        int headingX = w.getX() + (w.getWidth()/2) + (int) (Math.random() * (w.getWidth()/2));
                        robot.mouseMove(headingX, headingY);
                        clickMouse();
                        sleep(300);
                   // Cancel
                   robot.mouseMove(w.getX() + w.getWidth() - 36, w.getY() + w.getHeight() - 36);
                   clickMouse();
                   sleep(300);
                   // re-open
                   robot.mouseMove(frame.getX() + 36, frame.getY() + 36);
                   clickMouse();
                   sleep(1000);
                   now = System.currentTimeMillis();
         private static void sleep(int millis) {
              try {
                   Thread.sleep(millis);
              } catch (InterruptedException ex) {
         private static void clickMouse() {
              robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
              sleep(100);
              robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
         private static void swingMain(String[] args) throws Exception {
              //switchToNimbus();
              robot = new Robot();
              frame = new JFrame("JFileChooser Crash Test");
              button = new JButton("Start...");
              button.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        showFileChooser(frame);
              frame.getContentPane().add(button, BorderLayout.CENTER);
              frame.getContentPane().add(new JLabel("Press \"Start...\" and let go of the mouse.  Robot will be used to change FileChooser to details view and then quickly click column headings until the crash."), BorderLayout.SOUTH);
              frame.pack();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         static void showFileChooser(JFrame parent) {
              chooser = new JFileChooser("C:\\");
              latch.countDown();
              chooser.showOpenDialog(parent);
         private static void switchToNimbus() throws UnsupportedLookAndFeelException, IllegalAccessException, InstantiationException, ClassNotFoundException {
              for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
                   if (laf.getName().startsWith("Nimbus")) {
                        System.out.println("Using " + laf.getName());
                        UIManager.setLookAndFeel(laf.getClassName());
                        break;
    }

  • CDC and deferred updates

    I am using CDC to generate events based on the entries in the CDC tables. I need to distingush between insert, update and delete events but when SQL chooses to do a deferred update, it changes an update into a delete and insert - is there a way I can affect
    this behaviour so that any update command results in an update record in the cdc tables?
    I am aware of the DBCC TRACEON (8207,-1) but this seems to only apply to update commands affecting 1 record and which don't affect fields used by unique constraints - my update commands will affect multiple records and fields with unique constraints applied
    to them.

    This problem is caused by a bug in the fn_cdc_get_net_changes_<capture_instance> functions. The bug works in 2 ways, the first is indentified in this thread: an additional row is exported with __$operation = 1. A 2nd problem, resulting from the same
    bug, is that some rows with __$operation = 1 are incorrectly suppressed. These missing rows are however less easily spotted and thus this incarnation of the problem is nowhere reported.
    The bug is reported on Connect as
    ID 690476 back in 2011 already. Below is a copy of the corrected cdc.fn_get_net_changes_dbo_NETTEST function in my test database. The fix can easily be extracted from this sample code. I would suggest you do not adapt the functions yourself in a production
    environment. Instead we should put all our combined powers in to get Microsoft to fix this issue. Please Vote and if possible have the case reopened as soon as possible. 
    create function [cdc].[fn_cdc_get_net_changes_dbo_NETTEST]
    ( @from_lsn binary(10),
    @to_lsn binary(10),
    @row_filter_option nvarchar(30)
    returns table
    return
    select NULL as __$start_lsn,
    NULL as __$operation,
    NULL as __$update_mask, NULL as [ID], NULL as [A]
    where ( [sys].[fn_cdc_check_parameters]( N'dbo_NETTEST', @from_lsn, @to_lsn, lower(rtrim(ltrim(@row_filter_option))), 1) = 0)
    union all
    select __$start_lsn,
    case __$count_23BAE034
    when 1 then __$operation
    else
    case __$min_op_23BAE034
    when 2 then 2
    when 4 then
    case __$operation
    when 1 then 1
    else 4
    end
    else
    case __$operation
    when 2 then 4
    when 4 then 4
    else 1
    end
    end
    end as __$operation,
    null as __$update_mask , [ID], [A]
    from
    select t.__$start_lsn as __$start_lsn, __$operation,
    case __$count_23BAE034
    when 1 then __$operation
    else
    ( select top 1 c.__$operation
    from [cdc].[dbo_NETTEST_CT] c with (nolock)
    where ( (c.[ID] = t.[ID]) )
    and ((c.__$operation = 2) or (c.__$operation = 4) or (c.__$operation = 1))
    and (c.__$start_lsn <= @to_lsn)
    and (c.__$start_lsn >= @from_lsn)
    order by c.__$seqval) end __$min_op_23BAE034, __$count_23BAE034, t.[ID], t.[A]
    from [cdc].[dbo_NETTEST_CT] t with (nolock) inner join
    ( select r.[ID], max(r.__$seqval) as __$max_seqval_23BAE034,
    count(*) as __$count_23BAE034
    from [cdc].[dbo_NETTEST_CT] r with (nolock)
    where (r.__$start_lsn <= @to_lsn)
    and (r.__$start_lsn >= @from_lsn)
    group by r.[ID]) m
    on t.__$seqval = m.__$max_seqval_23BAE034 and
    ( (t.[ID] = m.[ID]) )
    where lower(rtrim(ltrim(@row_filter_option))) = N'all'
    and ( [sys].[fn_cdc_check_parameters]( N'dbo_NETTEST', @from_lsn, @to_lsn, lower(rtrim(ltrim(@row_filter_option))), 1) = 1)
    and (t.__$start_lsn <= @to_lsn)
    and (t.__$start_lsn >= @from_lsn)
    and ((t.__$operation = 2) or (t.__$operation = 4) or
    ((t.__$operation = 1) and not exists (
    select top(1) *
    from [cdc].[dbo_NETTEST_CT] c with (nolock)
    where ( (c.[ID] = t.[ID]) )
    and c.__$operation = 2
    and c.__$start_lsn = t.__$start_lsn
    and c.__$seqval = t.__$seqval
    --(2 not in
    -- ( select top 1 c.__$operation
    -- from [cdc].[dbo_NETTEST_CT] c with (nolock)
    -- where ( (c.[ID] = t.[ID]) )
    -- and ((c.__$operation = 2) or (c.__$operation = 4) or (c.__$operation = 1))
    -- and (c.__$start_lsn <= @to_lsn)
    -- and (c.__$start_lsn >= @from_lsn)
    -- order by c.__$operation desc
    and t.__$operation = (
    select
    max(mo.__$operation)
    from
    [cdc].[dbo_NETTEST_CT] as mo with (nolock)
    where
    mo.__$seqval = t.__$seqval
    and
    ( (t.[ID] = mo.[ID]) )
    group by
    mo.__$seqval
    ) Q
    union all
    select __$start_lsn,
    case __$count_23BAE034
    when 1 then __$operation
    else
    case __$min_op_23BAE034
    when 2 then 2
    when 4 then
    case __$operation
    when 1 then 1
    else 4
    end
    else
    case __$operation
    when 2 then 4
    when 4 then 4
    else 1
    end
    end
    end as __$operation,
    case __$count_23BAE034
    when 1 then
    case __$operation
    when 4 then __$update_mask
    else null
    end
    else
    case __$min_op_23BAE034
    when 2 then null
    else
    case __$operation
    when 1 then null
    else __$update_mask
    end
    end
    end as __$update_mask , [ID], [A]
    from
    select t.__$start_lsn as __$start_lsn, __$operation,
    case __$count_23BAE034
    when 1 then __$operation
    else
    ( select top 1 c.__$operation
    from [cdc].[dbo_NETTEST_CT] c with (nolock)
    where ( (c.[ID] = t.[ID]) )
    and ((c.__$operation = 2) or (c.__$operation = 4) or (c.__$operation = 1))
    and (c.__$start_lsn <= @to_lsn)
    and (c.__$start_lsn >= @from_lsn)
    order by c.__$seqval) end __$min_op_23BAE034, __$count_23BAE034,
    m.__$update_mask , t.[ID], t.[A]
    from [cdc].[dbo_NETTEST_CT] t with (nolock) inner join
    ( select r.[ID], max(r.__$seqval) as __$max_seqval_23BAE034,
    count(*) as __$count_23BAE034,
    [sys].[ORMask](r.__$update_mask) as __$update_mask
    from [cdc].[dbo_NETTEST_CT] r with (nolock)
    where (r.__$start_lsn <= @to_lsn)
    and (r.__$start_lsn >= @from_lsn)
    group by r.[ID]) m
    on t.__$seqval = m.__$max_seqval_23BAE034 and
    ( (t.[ID] = m.[ID]) )
    where lower(rtrim(ltrim(@row_filter_option))) = N'all with mask'
    and ( [sys].[fn_cdc_check_parameters]( N'dbo_NETTEST', @from_lsn, @to_lsn, lower(rtrim(ltrim(@row_filter_option))), 1) = 1)
    and (t.__$start_lsn <= @to_lsn)
    and (t.__$start_lsn >= @from_lsn)
    and ((t.__$operation = 2) or (t.__$operation = 4) or
    ((t.__$operation = 1) and not exists (
    select top(1) *
    from [cdc].[dbo_NETTEST_CT] c with (nolock)
    where ( (c.[ID] = t.[ID]) )
    and c.__$operation = 2
    and c.__$start_lsn = t.__$start_lsn
    and c.__$seqval = t.__$seqval
    --(2 not in
    -- ( select top 1 c.__$operation
    -- from [cdc].[dbo_NETTEST_CT] c with (nolock)
    -- where ( (c.[ID] = t.[ID]) )
    -- and ((c.__$operation = 2) or (c.__$operation = 4) or (c.__$operation = 1))
    -- and (c.__$start_lsn <= @to_lsn)
    -- and (c.__$start_lsn >= @from_lsn)
    -- order by c.__$operation desc
    and t.__$operation = (
    select
    max(mo.__$operation)
    from
    [cdc].[dbo_NETTEST_CT] as mo with (nolock)
    where
    mo.__$seqval = t.__$seqval
    and
    ( (t.[ID] = mo.[ID]) )
    group by
    mo.__$seqval
    ) Q
    union all
    select t.__$start_lsn as __$start_lsn,
    case t.__$operation
    when 1 then 1
    else 5
    end as __$operation,
    null as __$update_mask , t.[ID], t.[A]
    from [cdc].[dbo_NETTEST_CT] t with (nolock) inner join
    ( select r.[ID], max(r.__$seqval) as __$max_seqval_23BAE034
    from [cdc].[dbo_NETTEST_CT] r with (nolock)
    where (r.__$start_lsn <= @to_lsn)
    and (r.__$start_lsn >= @from_lsn)
    group by r.[ID]) m
    on t.__$seqval = m.__$max_seqval_23BAE034 and
    ( (t.[ID] = m.[ID]) )
    where lower(rtrim(ltrim(@row_filter_option))) = N'all with merge'
    and ( [sys].[fn_cdc_check_parameters]( N'dbo_NETTEST', @from_lsn, @to_lsn, lower(rtrim(ltrim(@row_filter_option))), 1) = 1)
    and (t.__$start_lsn <= @to_lsn)
    and (t.__$start_lsn >= @from_lsn)
    and ((t.__$operation = 2) or (t.__$operation = 4) or
    ((t.__$operation = 1) and not exists (
    select top(1) *
    from [cdc].[dbo_NETTEST_CT] c with (nolock)
    where ( (c.[ID] = t.[ID]) )
    and c.__$operation = 2
    and c.__$start_lsn = t.__$start_lsn
    and c.__$seqval = t.__$seqval
    --(2 not in
    -- ( select top 1 c.__$operation
    -- from [cdc].[dbo_NETTEST_CT] c with (nolock)
    -- where ( (c.[ID] = t.[ID]) )
    -- and ((c.__$operation = 2) or (c.__$operation = 4) or (c.__$operation = 1))
    -- and (c.__$start_lsn <= @to_lsn)
    -- and (c.__$start_lsn >= @from_lsn)
    -- order by c.__$operation desc
    and t.__$operation = (
    select
    max(mo.__$operation)
    from
    [cdc].[dbo_NETTEST_CT] as mo with (nolock)
    where
    mo.__$seqval = t.__$seqval
    and
    ( (t.[ID] = mo.[ID]) )
    group by
    mo.__$seqval
    SQL expert for JF Hillebrand IT BV - The Netherlands.

  • Mouse Click Event Is this a bug

    &#65279; I have a applet that has popupmenus tied to certain buttons. When a use clicks on one of the
    buttons a popupmenu is displayed for that button. Originally I used Mouse Click event to show
    the popupmenu but I found that when you switched buttons mouse click wouldn't fire right. When
    I switch to a action event it worked every time instead of losing 2-3 clicks when switching
    buttons. Does anyone no why this might happen. Is it a bug in mouse click?

    The reason why mouse clicks seem to dissapear is because a mouseClicked event is only ever fired when its mousePressed and mouseReleased coordinates are the same.
    This can be a pain!! Id recomend using the mouseReleased method to register mouseClicked events, this should always be called.

Maybe you are looking for

  • How to change email address login for this forum

    I no longer have the email address I use for this forum and was wondering how to change it if possible?

  • Animated GIFs in Captivate 2 or 3

    I have 31 lessons (PowerPoint) that contain animated GIFs. If I import these into Captivate 2 or Captivate 3, will these animations within the animated GIFs be maintained? Thanks for any replies! All the best with your own projects. Dean

  • HR Replication - only part of org structure needed in SRM - excess IDOC's

    Dear peers, we are running HR-ALE to replicate HR master data from a separate HR system (ECC 6) into the ERP system (ECC 6, with SRM as add-on). Only a part of the organizational structure is needed in SRM, this O-unit is specified in PFAL for initia

  • Mi_host service logs?

    Hi guys, Do you know how can I retrieve logs of the mi_host service..? Via the sicf I did not find a way.. The reason I am asking is that a specific user receives HTTP code 500 during synchronisation..(User's authorization is OK, and the code returne

  • BlazeDs Channel Call Error

    Hi, I am using Flex/AS, BlazeDs and Java in my application. But randomly i keep on getting. Most of the times it works but at times it happens. Cant tell the exact scenario. Fault Code: Channel Call Failed Fault Detail: Error I cannot understand why