The Controller in Java

Printer Data Matrix in Java The Controller
5
Printing ECC200 In Java
Using Barcode encoder for Java Control to generate, create DataMatrix image in Java applications.
The WmvcController supports functionality for subclasses that will implement menu items and tool bar controls The basic support includes handling tool tips, and providing the implementation for the WmvcExecutor class There is a subclass for each type of Swing component: normal menu, check box menu, and tool bar button It would be simple to support other Swing components by adding new subclasses of WmvcController There are many details that are "hidden" in this code to simplify using these components for the framework user Listing 5-8 WmvcControllerjava
Painting Bar Code In Java
Using Barcode encoder for Java Control to generate, create barcode image in Java applications.
The Controller
Reading Barcode In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
/* * WmvcController - implements a general purpose Swing based * Controller using the Command pattern - for Wmvc framework * Used to simplify Swing controls * * (c) 2001, Bruce E Wampler */ import import import import javaawt*; javaawtevent*; javaxswing*; javaxswingevent*;
Making Data Matrix 2d Barcode In Visual C#
Using Barcode generator for .NET framework Control to generate, create Data Matrix image in .NET applications.
public class WmvcController implements ActionListener, ItemListener { protected JComponent myComponent; private WmvcExecutor wmvcExecutor; // The Executor object // This constructor is use by the subobjects public WmvcController(JComponent comp, // the component String tip, WmvcExecutor wExec) { myComponent = comp; wmvcExecutor = wExec; if (tip != null) myComponentsetToolTipText(tip); }
DataMatrix Printer In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
file:///C|/oobook/5html (29 of 44) [13/03/2003 02:55:25 }
Data Matrix ECC200 Printer In .NET
Using Barcode creator for .NET framework Control to generate, create Data Matrix 2d barcode image in .NET applications.
5
Encoding DataMatrix In Visual Basic .NET
Using Barcode generator for Visual Studio .NET Control to generate, create Data Matrix image in VS .NET applications.
public WmvcExecutor getWmvcExecutor() { return wmvcExecutor; } /* -----------------------------------------------------* Implement the Listeners for components * Each listener will send a message to the appropriate * execute method from the associated WmvcExecutor Type * of event determines the signature of the execute method */ // implment the ActionListener public void actionPerformed(ActionEvent event) { if (wmvcExecutor != null) wmvcExecutorexecute(event); } // implement ItemLisetener public void itemStateChanged(ItemEvent event) { if (wmvcExecutor != null) wmvcExecutorexecute(event); } } The following are subclasses of WmvcController and implement menu items, checked menu items, and tool bar buttons Listing 5-9 WmvcMenuItemCtljava
Generate Barcode In Java
Using Barcode printer for Java Control to generate, create barcode image in Java applications.
Controller subclass for JMenuItem
Code 128A Generator In Java
Using Barcode generator for Java Control to generate, create USS Code 128 image in Java applications.
/* * WmvcMenuItemCtl - implements JMenuItem controller * (c) 2001, Bruce E Wampler */ import javaawt*; import javaawtevent*; import javaxswing*; import javaxswingevent*; public class WmvcMenuItemCtl extends WmvcController
Print Code 3/9 In Java
Using Barcode generation for Java Control to generate, create Code-39 image in Java applications.
file:///C|/oobook/5html (30 of 44) [13/03/2003 02:55:25 }
EAN-13 Supplement 5 Printer In Java
Using Barcode creator for Java Control to generate, create EAN-13 Supplement 5 image in Java applications.
5
Barcode Maker In Java
Using Barcode generation for Java Control to generate, create barcode image in Java applications.
{ private JMenu myMenu; private JMenuItem menuItem; // Constructor for JMenu item: Standard JMenuItem public WmvcMenuItemCtl(JMenu menu, // JMenu I go with String text, // Button's text String icon, // the icon's name char mnemonic, // Button's mnemonic String accel, // accelerator WmvcExecutor wExec) { super((JComponent)new JMenuItem(), null, wExec); myMenu = menu; menuItem = (JMenuItem) myComponent; if (text != null) menuItemsetText(text); if (mnemonic != ' ' && mnemonic != 0) menuItemsetMnemonic(mnemonic); if (accel != null) { KeyStroke ks = KeyStrokegetKeyStroke(accel); menuItemsetAccelerator(ks); } if (icon != null) { Icon theIcon = new ImageIcon(icon); menuItemsetIcon(theIcon); } menuItemaddActionListener(this); // Add listeners menuItemaddItemListener(this); menuadd(menuItem); // Finally, add to menu } public void setEnabled(boolean enable) { menuItemsetEnabled(enable); } public JMenu getJMenu() { return myMenu; }
Printing NW-7 In Java
Using Barcode creation for Java Control to generate, create Code-27 image in Java applications.
file:///C|/oobook/5html (31 of 44) [13/03/2003 02:55:25 }
Read Code 128 Code Set B In VS .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET applications.
5
Decode Barcode In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
public JMenuItem getJMenuItem() { return menuItem; } }
Encoding Barcode In VB.NET
Using Barcode maker for .NET Control to generate, create bar code image in Visual Studio .NET applications.
Listing 5-10 WmvcChkMenuItemCtljava
Making Code-39 In Visual C#
Using Barcode creator for .NET framework Control to generate, create Code 3/9 image in Visual Studio .NET applications.
Controller subclass for JCheckBoxMenuItem
Scan UPC Code In .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in VS .NET applications.
/* * WmvcChkMenuItemCtl - implements JCheckBoxMenuItem controller * (c) 2001, Bruce E Wampler */ import import import import javaawt*; javaawtevent*; javaxswing*; javaxswingevent*;
Create UPC A In .NET Framework
Using Barcode maker for .NET Control to generate, create Universal Product Code version A image in Visual Studio .NET applications.
public class WmvcChkMenuItemCtl extends WmvcController { private JMenu myMenu; private JCheckBoxMenuItem checkBoxItem; // Constructor for JMenu item: JCheckBoxMenuItem public WmvcController(JMenu menu, // JMenu I go with String text, // Button's text String icon, // the icon's name char mnemonic, // Button's mnemonic String accel, // accelerator boolean checked, // initial state WmvcExecutor wExec) { super((JComponent)new JCheckBoxMenuItem(), null, wExec); myMenu = menu; checkBoxMenuItem = (JCheckBoxMenuItem) myComponent; if (text != null) checkBoxItemsetText(text); if (mnemonic != ' ' && mnemonic != 0) checkBoxItemsetMnemonic(mnemonic); if (accel != null) {
Draw USS Code 128 In VB.NET
Using Barcode generator for VS .NET Control to generate, create USS Code 128 image in .NET applications.
file:///C|/oobook/5html (32 of 44) [13/03/2003 02:55:25 }
5
KeyStroke ks = KeyStrokegetKeyStroke(accel); checkBoxItemsetAccelerator(ks); } if (icon != null) { Icon theIcon = new ImageIcon(icon); checkBoxItemsetIcon(theIcon); } checkBoxItemsetState(checked); checkBoxItemaddActionListener(this); // Add listeners checkBoxItemaddItemListener(this); myMenuadd(checkBoxItem); // Finally, add to menu } public boolean getState() { return checkBoxItemgetState(); } public void setState(boolean checked) { checkBoxItemsetState(checked); } public void setEnabled(boolean enable) { checkBoxItemsetEnabled(enable); } public JMenu getJMenu() { return myMenu; } public JCheckBoxMenuItem getJCheckBoxMenuItem() { return checkBoxItem; } }