FvCalculator new FvAsWing component

Hi all, a new component has just been added to FvAsWing framework.

The FvCalculator

The FvCalculator is a simple JFrame based component showing a calculator user interface.

As we don't really need many calculators at the same time, implementation model is based on the Design Pattern Singleton one.
So, to get a FvCalculator instance, we need to do :

var calculator : FvCalculator = FvCalculator.getInstance();


A JMenubar is installed to allow user to :

  • Copy the calculator result to the clipboard
  • Switch between the classic and the scientific calculator view.


In most case, the "copy to clipboard" is a sufficient way to retreive result, but if you want to really recover the result with the closing of the component, you have to use :

//for example, result is returned to a JTextField
var field : JTextField = new JTextField();

var calculator : FvCalculator = FvCalculator.getInstance();
calculator.connect( AccessorFactory.getInstance( field, field.setText, field.getText ) );
calculator.open();


You can use your Keyboard NumPAD when FvCalculator window has the focus

FvCalculator is connected to the Localisation API to translate correctly all necessaries label.


Demo source code :

class Demo implements FeverApplication
{
     //-------------------------------------------------------------------------
     // Public API
     //-------------------------------------------------------------------------
          
     /**
      * Constructor.
      */
     public function Demo()
     {
          
     }
     
     public function run() : Void
     {
          var input : JTextField = new JTextField();
          var button : JButton = new JButton( "calculator" );
          button.addActionListener( _open, this );
          button.setPreferredWidth( 100 );
          
          var o : JFrame = new JFrame( FvAsWingStage.getRootMovieClip(), "", false );
          o.getContentPane().setLayout( new SoftBoxLayout( SoftBoxLayout.Y_AXIS, 5 ) );
          o.getContentPane().setBorder( new EmptyBorder( null, new Insets( 5,5,5,5 ) ) );
          
          o.getContentPane().append( input );
          o.getContentPane().append( button );
          o.setClosable( false );
          o.setResizable( false );
          o.pack();
          o.show();
          
          FvCalculator.getInstance().connect(
               AccessorFactory.getInstance( input, input.setText, input.getText )
          );
     }

     //-------------------------------------------------------------------------
     // Private implementation
     //-------------------------------------------------------------------------
     
     private function _open( source : JButton ) : Void
     {
          FvCalculator.getInstance().open(); 
     }   
}


Cheers

Comments
wow's Gravatar <a href="http://www.feelingame.com/">wow power leveling</a>
<a href="http://www.feelingame.com">wow powerleveling</a>
<a href="http://www.feelingame.com/wow-power-leveling.asp">wow power leveling</a>
<a href="http://www.feelingame.com/wow-gold.asp">wow gold</a>
<a href="http://www.feelingame.com/wow-items.asp">wow items</a>
<a href="http://www.feelingame.com/about-us.asp" target="_blank">http://www.feelingame.com/about-us.asp">feelingame.com</a>
<a href="http://www.feelingame.com/wow-tips.asp" target="_blank">http://www.feelingame.com/wow-tips.asp">wow tips</a>
<a href="http://www.feelingame.com/most-valuable.asp" target="_blank">http://www.feelingame.com/most-valuable.asp">Most Valuable WOW Power Leveling Service</a>
<a href="http://www.feelingame.com/faq.asp">wow power leveling faq</a>
<a href="http://www.cheap-wow-power-leveling.com">cheap wow power leveling</a>
<a href="http://www.cheap-wow-power-leveling.com/">wow power leveling</a>
<a href="http://www.cheap-wow-power-leveling.com/">wow powerleveling</a>
<a href="http://www.cheap-wow-power-leveling.com/">wow power lvl</a>
# Posted By wow | 12/10/07 1:13 AM
# Posted By oil painter | 4/13/08 1:29 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.5.006.