- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Figure 228: Sample output from the MenuDemo applet in Java
Figure 228: Sample output from the MenuDemo applet QR Code JIS X 0510 Encoder In Java Using Barcode generation for Java Control to generate, create QR Code ISO/IEC18004 image in Java applications. QR Code JIS X 0510 Decoder In Java Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications. There is one other menu-related class that you might find interesting: PopupMenu It works just like Menu but produces a menu that can be displayed at a specific location PopupMenu provides a flexible, useful alternative for some types of menuing situations Encoding Bar Code In Java Using Barcode maker for Java Control to generate, create barcode image in Java applications. Bar Code Reader In Java Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications. Dialog Boxes
QR Maker In Visual C# Using Barcode creation for .NET framework Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications. QR Creator In VS .NET Using Barcode maker for ASP.NET Control to generate, create QR Code image in ASP.NET applications. Often, you will want to use a dialog box to hold a set of related controls Dialog boxes are primarily used to obtain user input They are similar to frame windows, except that dialog boxes are always child windows of a top-level window Also, dialog boxes don't have menu bars In other respects, dialog boxes function like frame windows (You can add controls to them, for example, in the same way that you add controls to a frame window) Dialog boxes may be modal or modeless When a modal dialog box is active, all input is directed to it until it is closed This means that you cannot access other parts of your program until you have closed the dialog box When a modeless dialog box is active, input focus can be directed to another window in your program Thus, other parts of your program remain active and accessible Dialog boxes are of type Dialog The most commonly used constructors are shown here: Dialog(Frame parentWindow, boolean mode) Dialog(Frame parentWindow, String title, boolean mode) Here, parentWindow is the owner of the dialog box If mode is true, the dialog box is modal Otherwise, it is modeless The title of the dialog box can be passed in title Generally, you will subclass Dialog, adding the functionality required by your application Following is a modified version of the preceding menu program that displays a modeless dialog box when the New option is chosen Notice that when the dialog box is closed, dispose( ) is called This method is defined by Window, and it frees all system resources associated with the dialog box window // Demonstrate Dialog box import javaawt*; import javaawtevent*; import javaapplet*; /* <applet code="DialogDemo" width=250 height=250> </applet> */ // Create a subclass of Dialog class SampleDialog extends Dialog implements ActionListener { SampleDialog(Frame parent, String title) { super(parent, title, false); setLayout(new FlowLayout()); setSize(300, 200); add(new Label("Press this button:")); QR-Code Creator In .NET Framework Using Barcode creator for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications. Quick Response Code Printer In Visual Basic .NET Using Barcode creation for Visual Studio .NET Control to generate, create QR-Code image in .NET framework applications. - 532 - UPC Code Encoder In Java Using Barcode printer for Java Control to generate, create UPC Code image in Java applications. UPC-A Supplement 2 Generator In Java Using Barcode creation for Java Control to generate, create UPC Symbol image in Java applications. Button b; add(b = new Button("Cancel")); baddActionListener(this); Data Matrix ECC200 Printer In Java Using Barcode generator for Java Control to generate, create ECC200 image in Java applications. Data Matrix ECC200 Generator In Java Using Barcode printer for Java Control to generate, create ECC200 image in Java applications. public void actionPerformed(ActionEvent ae) { dispose(); } public void paint(Graphics g) { gdrawString("This is in the dialog box", 10, 70); } USPS PLANET Barcode Generator In Java Using Barcode drawer for Java Control to generate, create Planet image in Java applications. Data Matrix Encoder In None Using Barcode maker for Font Control to generate, create Data Matrix image in Font applications. // Create a subclass of Frame class MenuFrame extends Frame { String msg = ""; CheckboxMenuItem debug, test; MenuFrame(String title) { super(title); // create menu bar and add it to frame MenuBar mbar = new MenuBar(); setMenuBar(mbar); // create the menu items Menu file = new Menu("File"); MenuItem item1, item2, item3, item4; fileadd(item1 = new MenuItem("New")); fileadd(item2 = new MenuItem("Open")); fileadd(item3 = new MenuItem("Close")); fileadd(new MenuItem("-")); fileadd(item4 = new MenuItem("Quit")); mbaradd(file); Menu edit = new Menu("Edit"); MenuItem item5, item6, item7; editadd(item5 = new MenuItem("Cut")); editadd(item6 = new MenuItem("Copy")); editadd(item7 = new MenuItem("Paste")); editadd(new MenuItem("-")); Menu sub = new Menu("Special", true); MenuItem item8, item9, item10; subadd(item8 = new MenuItem("First")); subadd(item9 = new MenuItem("Second")); subadd(item10 = new MenuItem("Third")); editadd(sub); // these are checkable menu items debug = new CheckboxMenuItem("Debug"); editadd(debug); test = new CheckboxMenuItem("Testing"); editadd(test); mbaradd(edit); // create an object to handle action and item events MyMenuHandler handler = new MyMenuHandler(this); // register it to receive those events item1addActionListener(handler); item2addActionListener(handler); DataMatrix Recognizer In None Using Barcode scanner for Software Control to read, scan read, scan image in Software applications. ANSI/AIM Code 39 Decoder In Visual C#.NET Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications. - 533 - Barcode Creator In Java Using Barcode encoder for BIRT reports Control to generate, create bar code image in Eclipse BIRT applications. Decoding Bar Code In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. item3addActionListener(handler); item4addActionListener(handler); item5addActionListener(handler); item6addActionListener(handler); item7addActionListener(handler); item8addActionListener(handler); item9addActionListener(handler); item10addActionListener(handler); debugaddItemListener(handler); testaddItemListener(handler); // create an object to handle window events MyWindowAdapter adapter = new MyWindowAdapter(this); // register it to receive those events addWindowListener(adapter); Code128 Creator In Objective-C Using Barcode generation for iPad Control to generate, create Code 128B image in iPad applications. Bar Code Drawer In None Using Barcode printer for Word Control to generate, create barcode image in Word applications. } public void paint(Graphics g) { gdrawString(msg, 10, 200); if(debuggetState()) gdrawString("Debug is on", 10, 220); else gdrawString("Debug is off", 10, 220); if(testgetState()) gdrawString("Testing is on", 10, 240); else gdrawString("Testing is off", 10, 240); class MyWindowAdapter extends WindowAdapter { MenuFrame menuFrame; public MyWindowAdapter(MenuFrame menuFrame) { thismenuFrame = menuFrame; } public void windowClosing(WindowEvent we) { menuFramedispose(); } } class MyMenuHandler implements ActionListener, ItemListener { MenuFrame menuFrame; public MyMenuHandler(MenuFrame menuFrame) { thismenuFrame = menuFrame; } // Handle action events public void actionPerformed(ActionEvent ae) { String msg = "You selected "; String arg = (String)aegetActionCommand(); // Activate a dialog box when New is selected if(argequals("New")) { msg += "New"; SampleDialog d = new SampleDialog(menuFrame, "New Dialog Box"); dsetVisible(true); } // Try defining other dialog boxes for these options else if(argequals("Open")) msg += "Open"; else if(argequals("Close")) msg += "Close"; else if(argequals("Quit")) - 534 - } public void itemStateChanged(ItemEvent ie) { menuFramerepaint(); } msg += "Quit"; else if(argequals("Edit")) msg += "Edit"; else if(argequals("Cut")) msg += "Cut"; else if(argequals("Copy")) msg += "Copy"; else if(argequals("Paste")) msg += "Paste"; else if(argequals("First")) msg += "First"; else if(argequals("Second")) msg += "Second"; else if(argequals("Third")) msg += "Third"; else if(argequals("Debug")) msg += "Debug"; else if(argequals("Testing")) msg += "Testing"; menuFramemsg = msg; menuFramerepaint(); // Create frame window public class DialogDemo extends Applet { Frame f; public void init() { f = new MenuFrame("Menu Demo"); int width = IntegerparseInt(getParameter("width")); int height = IntegerparseInt(getParameter("height")); setSize(width, height); fsetSize(width, height); fsetVisible(true); public void start() { fsetVisible(true); } public void stop() { fsetVisible(false); Here is sample output from the DialogDemo applet: - 535 -
|
|