saager mhatre

Ranch Hand
+ Follow
since Dec 20, 2000
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by saager mhatre

This should solve all your problems...
The Element Interface @ The Swing Connection

This works with the DefaultStyledDocument implementaion of the Document Model used by the JTextComponent Component(Controller) in Swing.

Here's some scratchy code to help you along.
I'm sorry there aren't too may comments.

I went a little overboard with the renderer , but I know you'll forgive me!
The key mappings are:
  • Superscript: Alt + Up
  • Normal: Alt + Down
  • Bold: Ctrl + B

  • [ December 07, 2005: Message edited by: saager mhatre ]
    [ December 07, 2005: Message edited by: saager mhatre ]
    18 years ago
    If you're just trying to trap the Enter key on a TextComponent, you could simply register an ActionListener to the component. The default input map for text components routes Enter strokes to the ActionListeners with the components text as the ActionCommand.
    18 years ago

    You usually don't define RuntimeException (or one of its subclasses) in the "throws" clause of a method

    The EJB Spec Chapter 18.1.1 Application Exceptions says

    An application exception is an exception defined in the throws clause of a method of an enterprise bean�s home, component, message listener, or web service endpoint interface, other than the java.rmi.RemoteException.

    The same section also says

    An application exception class must be a subclass (direct or indirect) of java.lang.Exception. An application exception class must not be defined as a subclass of the java.lang.RuntimeException or of the java.rmi.RemoteException.

    So by definition, java.lang.RemoteException and its subcalsses would not be Application Exceptions. But in the limited context of the Client View (by declaration), the java.lang.RuntimeException clause has been ignored as unchecked exceptions need not be declared in the throws clause.

    Wot say??


    In a broader perspective, in several places the spec refers to Application Exceptions and non-Application Exceptions.
    Would non-Application Exceptions always imply System Exceptions or is there any gray area here.
    [ January 11, 2005: Message edited by: saager mhatre ]
    Three cheers for JavaRanch! And four for Mikalai Zaikin!
    With all the resources avalable here it's pretty muc impossible to come out with a bad score.

    I do have a few questions for Mikalai about his BCD Exam guide. I've posted them on a seperate thread in the BCD forum here.

    Mikalai, I'd be obliged if you could just take a look at them. Thanx!
    19 years ago
    First off, I'd like to seriously congratulate Mikalai Zaikin for coming up with a really well organized and comprehensive guide. Kudos!!

    There were a couple of things, though, that bothered me, like:
  • Chapter 12. Exceptions

  • The first line says

    An APPLICATION EXCEPTION is an exception defined in the throws clause of a method of the enterprise Bean's home and component interfaces, other than the java.rmi.RemoteException.

    Shouldn't this also include java.lang.RuntimeException?
  • Chapter 6. Component Contract for Container-Managed Persistence (CMP)

  • Here you mentioned that

    ...the container-managed persistent (CMP) fields and container-managed relationship (CMR) fields...are accessed through get and set accessor methods.

    If I remember the JavaBeans Framework correctly, the get methods were called accessors and the set methods were called mutators. That's just a cosmetic issue, but we wouldn't want to confuse any newbies!

    Feel free to get back to me with any comments/queries you may have.
    [ January 10, 2005: Message edited by: saager mhatre ]
    Coool Bud! Hearty Congrats!
    And blow up some Alien Scum for me, will ya!
    I finally put in my SCWCD and cleared with 92% (that too with barely 2 weeks of preparation!) . I have to acknowledge the resource content this forum provides for such learning. The referrences provided here were instrumrntal, esp Mikalai Zaikin's exam guides! Mikalai, you're the BEST!!!
    I'm working on my SCBCD and WS now! I just wish I could contribute a little more to the JavaRanch Big Moose Saloon . I promise I'll try!

    Once again, THANK YOU ALL !!
    Assertion (1) is right; since the 'session' attribute of the 'page' directive defaults to 'true', the implicit variable session was initialized with a new ly created session.

    WRT the NullPointerException, if you're talking about the following statement...

    ... that's an assignment, not a downcast.
    Hey Gregg,
    It's just an idea, but wouldn't this kind of sprite animation be better off included in the Image Producer/Consumer API ??
    19 years ago
    Hey Gregg,
    It's just an idea, but wouldn't this kind of sprite animation be better off included in the Image Producer/Consumer API ??
    19 years ago
    OK, first of all, I said i wanted only one entry in the ActionMap. Something like...

    But, that's OK since you used the same instace for all 4 mappings.

    What I have ral reservations about is wiring into the KeyboardFocusManager's KeyEventDispatch'er just to capture the character typed. I could have done that by registering keystrokes using

    I didn't want to use this factory method since I want to provide other Functions the scope to register KeyStrokes with modifiers.
    Besides, my 'bulky' workaround turned out to be better than this and I also managed to find the more appropriate solution to the problem.
    I'll tell you more about that in the next post. Gotta run now!
    19 years ago
    Swing now allows for an abstract mapping between KeyStroke's and Action's by setting up the InputMap and ActionMap for the JComponent in question. One problem I faced recently goes something like this.
    Suppose we mapped several KeyStrokes to the same ActionMap key like so... does the Action Object associated with 'myActionKey' determine exactly which KeyStroke triggered it.
    As obvious from the code, I was toying with a Calculator model. Initially I tried pulling it out of the ActionCommand of the ActionEvent, but that doesn't form a sufficiently unique pattern, for example the two mappings above generate an ActionCommand of "+", but I intended to create a generic Action to handle the contract for all functions in the calculator (=, -, *, /, memory, etc.) with actual functionality abstracted into implementations of a Function interface.
    I managed a rather bulky workaround, but had to redesign significantly. My original design was to maintain a KeyStroke to Function factory map that could be used to manufacture Function instances corresponding to KeyStrokes generated.
    So, getting back to the point, do any of u guys have any idea as to how we can derive the KeyStroke the triggered a particular Action?
    19 years ago
    The ComboBox Arrow Icon is UI specific. If you're looking for the one in the Metal LnF, it's here.
    19 years ago
    If you're creating your own UI classes, you could benefit from reading up on the PLAF packages. The UIManager follows an intricae contract when determining and configuring the UI delegates for a JComponent.
    19 years ago
    The other day I was trying to set up the InputMap for my app and ran into some 'strange looking' behaviour.
    I needed to map to the + and - keys but didn't want to use the KeyStroke.getKeystroke(char) factory method. I had decided on the KeyStroke.getKeystroke(keyCode, modifiers) method.
    So I went ahead and mapped my action key to KeyEvent.VK_PLUS & VK_MINUS key codes. But, when I ran the app the action refused to fire. On further investigation, I realized that the corect mappingwas to the KeyEvent.VK_ADD & KeyEvent.VK_SUBTRACT key codes.
    What I would like to know is why we seem to have seemingly duplicate codes in the KeyEvent class.
    What keys do the KeyEvent.VK_PLUS & KeyEvent.VK_MINUS codes map to?
    [ May 24, 2004: Message edited by: saager mhatre ]
    19 years ago