Frame in dialog in appplet....

i think this is the right place for this posting...
Q. 1 Once the applet is opened, then after clicking on jButton1,why it does not display under NewJDialog... in other words I want NewJFrame to display in NewJDialog. Actually as you know Applet does not allow Frames to be "always on top" so i am changing my code and put all my frames in the NewJDialogs...rather than developing new gui in Dialogs..
Q. 2 After NewJDialog is opened (clicked on jButton1), if the entire application NewJApplet is hidden under any other application, clicking on NewJApplet application will not bring it to the forground. in other words .,. it should atleast come to the front on first click and on second click it should beep...
Q3. Just wander after NewJDialog is opened, is there anyway button1 is also clickable?
Thanks in advance
public class NewJApplet extends javax.swing.JApplet {
    /** Initializes the applet NewJApplet */
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
        } catch (Exception ex) {
            ex.printStackTrace();
    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        button1 = new java.awt.Button();
        getContentPane().setLayout(new java.awt.FlowLayout());
        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
        jPanel1.add(jButton1);
        button1.setLabel("button1");
        jPanel1.add(button1);
        getContentPane().add(jPanel1);
    // </editor-fold>
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
// TODO add your handling code here:
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJDialog(new javax.swing.JFrame(), true).setVisible(true);
    // Variables declaration - do not modify
    private java.awt.Button button1;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
public class NewJDialog extends javax.swing.JDialog {
    /** Creates new form NewJDialog */
    public NewJDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        getContentPane().setLayout(new java.awt.FlowLayout());
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        pack();
    // </editor-fold>
     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //new NewJDialog(new javax.swing.JFrame(), true).setVisible(true);
               new NewJDialog(new javax.swing.JFrame(), true).setVisible(true);
    // Variables declaration - do not modify
    // End of variables declaration
public class NewJFrame extends javax.swing.JFrame {
    /** Creates new form NewJFrame */
    public NewJFrame() {
        initComponents();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        textField1 = new java.awt.TextField();
        getContentPane().setLayout(new java.awt.FlowLayout());
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jButton1.setText("jButton1");
        getContentPane().add(jButton1);
        jLabel1.setText("jLabel1");
        getContentPane().add(jLabel1);
        textField1.setText("textField1");
        getContentPane().add(textField1);
        pack();
    // </editor-fold>
     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private java.awt.TextField textField1;
    // End of variables declaration
}

Crosspost: http://forum.java.sun.com/thread.jspa?threadID=5123587

Similar Messages

  • Frames and dialogs

    Okay when you make a dialog and tell i that the main frame of the application is its parent, how do I make sure that it is always visible, even if the user is working in the parent frame with out it being modal??
    I'm making a tool window, like in photoshop 6 where you have different windows that contain info.
    thanks

    If you are using javax.swing.* this will be very easy by using
    JFrame and JInternalFrame.
    (certainly, you have to edit some more to suit your needs, this is only one of the suggestions.)

  • Modal Frame or Dialog with Minimize/Maximize buttons

    I want to create a window (dialog or frame) that is modal and has the minimize/maximize buttons. Is it possible? How?
    I normally would use a dialog if I wanted the window to be modal, but a dialog does not have the minimize/maximize buttons. I normally would use a frame if I wanted the window have the minimize/maximize buttons, but a frame cannot be modal.
    Any suggestions, please?

    You can make your "modal panel" listener the window events from all others frames:
    public class YourModalFrame extends JFrame implements WindowListener{
      public YourModalFrame(JFrame owner){
        super("Modal Frame");
        this.owner = owner;
        // we put a glass panel into the main frame
        JPanel glassPanel = new JPanel();
        glassPanel.setOpaque(false);
        glassPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        // blocking the events!!!
        glassPanel.addKeyListener        (new KeyAdapter()        {});
        glassPanel.addMouseListener      (new MouseAdapter()      {});
        glassPanel.addMouseMotionListener(new MouseMotionAdapter(){});
        owner.setGlassPane(glassPanel);
        // the frame will listener owner windows events
        owner.addWindowListener(this);
      // Window Listener  //
       * Invoked the first time a window is made visible.
      public void windowOpened(WindowEvent e){}
       * Invoked when the user attempts to close the window
       * from the window's system menu.  If the program does not
       * explicitly hide or dispose the window while processing
       * this event, the window close operation will be cancelled.
      public void windowClosing(WindowEvent e){}
       * Invoked when a window has been closed as the result
       * of calling dispose on the window.
      public void windowClosed(WindowEvent e){}
       * Invoked when a window is changed from a normal to a
       * minimized state. For many platforms, a minimized window
       * is displayed as the icon specified in the window's
       * iconImage property.
       * @see java.awt.Frame#setIconImage
      public void windowIconified(WindowEvent e){
        // Do you want this too?
        //super.setState(JFrame.ICONIFIED);
       * Invoked when a window is changed from a minimized
       * to a normal state.
      public void windowDeiconified(WindowEvent e){
        if(super.getState() == JFrame.ICONIFIED)
          super.setState(JFrame.NORMAL);
        this.requestFocus();
       * Invoked when the window is set to be the user's
       * active window, which means the window (or one of its
       * subcomponents) will receive keyboard events.
      public void windowActivated(WindowEvent e){
        this.requestFocus();
       * Invoked when a window is no longer the user's active
       * window, which means that keyboard events will no longer
       * be delivered to the window or its subcomponents.
      public void windowDeactivated(WindowEvent e){}
    }

  • Pass parent frame to Dialog, from panel within CardLayout

    Hi!
    I have a main class that uses card layout (EntryPoint.java), and where I instantiate all my panels from. All my panels(cards) are seperate classes.
    I have a login class(card) that I call from my main class (LoginClass.java). When it displays and the user wants to change his/her password - I created a custom dialog to pop up and handle the request. This custom dialog is another class on it's own.
    My problem is I cant seem to pass the frame to my dialog. I created a frame only in my main class, seeing the login panel is only a card displayed in my Main class.
    I have followed the example at http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
    Can anyone please assist me? I would greatly appreciate it. ;o)
    Here is some code if it helps:
    EntryPoint.java -----------------------------
    public class EntryPoint extends JFrame {
        //instantiate the main frame
        public JFrame frame = new JFrame();
        //create a panel to add all of the components to
        private JPanel cards = new JPanel();   
        LoginClass lc = new LoginClass();
        public EntryPoint() {
            cards.add("login", lc);
            //add the panel to the frame
            frame.getContentPane().add(cards, BorderLayout.CENTER);
            frame.getContentPane().add(buttons, BorderLayout.PAGE_END);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
    }LoginClass.java ----------------------------------
    public class LoginClass extends JPanel  {
        private JButton loginB = new JButton("login"');
        CustomDialog customDialog;
        public boolean loginProceed = false;
        public LoginClass() {
            //this is where it shows in the example i have to pass parameters
    //        customDialog = new CustomDialog(frame, "geisel", this);
    //        customDialog.pack();
            this.setLayout(new GridLayout());
            this.add(loginBut);
            //set action listener to button ..................
        public boolean loginBut_actionPerformed(ActionEvent e) {
           //if password needs to be changed, invoke the dialog with this text
    //                        customDialog.setLocationRelativeTo(frame);
    //                        customDialog.setVisible(true);
    //                        String s = customDialog.getValidatedText();
    //                        if (s != null) {
    //                            //The text is valid.
    //                            setLabel("Congratulations!  "
    //                                     + "You entered \""
    //                                     + s
    //                                     + "\".");
    }My actual dialog is pretty much the same as
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/CustomDialog.java
    Thanx for your help and time ;o)

    Change the constructor for LoginClass and give it an argument:
    public LoginClass(JFrame frame) {
        customDialog = new CustomDialog(frame, "geisel", this); // this line looks weird but without the code I cannot say for sure that it is wrong.
        customDialog.pack();
        this.setLayout(new GridLayout());
        this.add(loginBut);
    }By the way.. if you are instantiating a JFrame in the main class, why does the main class also extend JFrame? Pick one pattern or the other and stick with it... I recommend that you NOT extend. So your JFrame oriented class should have a member JFrame and the JPanel oriented class should have a JPanel. This is not the way most people do it, but it is better design, even if only marginally so.
    Drake

  • Status frame or dialog when open an application

    Hi, guys,
    I want to have a status box (probrably built by a frame) when every time my java application is opened. it is like a initial status report, it is better to look like the text is scrolling down in a box (may be a textarea inside the frame) as the application checking the resources , and a status bar on top say 50% complete or something like that?
    Can anyone tell me if it is the right wway of building such thing? or may be a small sample
    Thanks in advance

    Hi, thank you for the ideas of a splach screen. that is what i need in principle. But i also would like
    it to display some data of my own , when my apploication is checking stuff during the load up.
    Can I use a JTextArea inside something to have the effect? i.e. the text is scrooling down

  • How to centre window (frame or dialog) relative to screen ?

    Hi all!
    Please, give me a tip on how to locate some window on the screen so it is centered on the screen ? One more reqirement is that it should be supported different screen resolutions.
    ThanX in advance,
    Anton.

    JFrame f = ...;
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    f.pack(); // or anything else
    f.setLocation((screenSize.width-f.getWidth())/2, ((screenSize.height-f.getHeight())/2);
    f.setVisible(true);Denis

  • J Frames and Dialogs

    Hi i have a swing application, the Main ui will open all the other ui's through menu selection, when i open a new ui , the main Ui should remain in the background covering the whole screen , and these child ui's will open over this . but untill i close this child ui the main UI should not be activated , i mean the user should not be allowed to perform any actions with the main Ui , How can i achive this ..!! any help in this regard will bill be appreciated .
    thank u...
    Sudhir

    Hi
    This 2 lines will set the main Ui size to max.
    Dimension scrsize = Toolkit.getDefaultToolkit().getScreenSize();
    Ui.setBounds(0,0,scrsize.width, scrsize.height);
    Use Ui.setEnabled(true) , Ui.setEnabled(false) to activate or deactivate your main Ui.
    Noah

  • IE11 can't post form data to specific frame or window dialog opened via window.open()

    Hello,
    Form POST targeting to specific frame or dialog popped up via window.open() no longer works in IE11.
    It worked fine in IE10 and all previous versions of IE.
    Please see screenshot attached with simple test that reproduces this problem.
    Direct Link to screenshot:
    http://173.231.98.44/cgi/TestFolder/IE_11_widow_frame_targeting_BUG.jpg
    Direct link to simple test page demonstrating this problem:
    http://173.231.98.44/cgi/TestFolder/page2.asp
    Note: IE11 doesn't report any errors, doesn't complain about anything, even when debugged via F12 developer tools. The only thing it complained initially was missing doc type declaration on top of page, but even after adding doc type definition, problem still
    persists, makes no difference.
    I tested this on fresh install of Windows 2012R2 while testing our web application with the new IE11.
    I believe doing this on Windows 8.1 with IE11 will result in same bug/problem.
    Our web application uses a technique whereby it launches a popup window via call to window.open(), passing blank URL and specifying a name for the new window. It then does a from post targeting the name of new dialog.
    In IE11 this functionality has been broken and no longer works.
    Problem is that IE11, instead of posting form to the newly created dialog, it launches a new instance of IE and then loads the requested form in this new instance of IE, while the dialog launched via window.open() remains on screen and is empty. If user repeats
    launching same form post request (via button click for example), IE 11 keeps creating new empty dialogs and new IE instance for every form post executed. This totally breaks our application because we use many so called "wizards" that encapsulate
    specific functionality in separate web page launched in a popup window.
    Another related problem is that if a dialog is launched with window.open(), the java script code in the dialog can not target the parent frame that opened the dialog anymore. In our application, when a dialog is closed, it typically needs to trigger a refresh
    of a specific frame within the parent window (again targeted by name) to reflect saved/updated info that user entered in the popup dialog. The result is that we can't refresh the parent frame after the pop up dialog closes. Instead, IE11 launches
    a new instance of IE (not just a tab, but a whole new instance) and loads the parent frame in it.
    The problem seems to be caused by broken frame name targeting mechanism in IE11.
    Note that we force IE to compatibility mode 5, but even without specifying any compatibility, the problem remains.
    Typical java script to reproduce this is:
    <input type="button" onClick="Popup(this.form);" name="btn2" value="Popup Dialog">
    function Popup(f){
        window.open("","MyNewDialogName","width=200,height=150");
        f.action = "page3.asp";
        f.target = "MyNewDialogName";
        f.submit();
    Expected: IE11 should correctly post form to and load targeted page in the newly popped up dialog, without opening new IE instance and new tab. Repeatedly posting form to existing popup window should reuse that window, not keep on launching more popup windows
    and then more IE instances.
    Steps to reproduce the problem (include URL if applicable):
    URL with sample page: http://173.231.98.44/cgi/TestFolder/page2.asp
    1) Create page1.htm: <html><body>display "I'm in a popup window now ..."</body></html>
    2) Create page2.htm with a button and onclick() event calling function to open dialog, and do form POST targeting new dialog calling page1.htm, like below.
    <input type="button" onClick="Popup(this.form);" name="btn2" value="Popup Dialog"> function Popup(f){
        window.open("","MyNewDialogName","width=200,height=150");
        f.action = "page1.asp";
        f.target = "MyNewDialogName";
        f.submit();
    3) Open IE11, navigate to page2.htm, click the "Popup Dialog" dialog button. IE 11 will popup the new dialog, but then it will also launch new instance of IE11 and display the page1.htm in it, instead of in the popup dialog.
    Has anyone else encountered this problem?
    Any insight or help is appreciated.
    Regards
    Peter

    the default action of <input type="button" is submit. Note also that the default type of <button> elements is 'submit' also.
    add a return false to the onclick inline event handler (which constructs the form submit attribues) to cancel the default form.submit behavior.
    form elements have a target value with which you can specify the name window into which you want the form to open in.
    <form action="process.aspx" target="popup">
    you can use the window.open method with a query uri to achieve the same outcome.
    window.open('process.aspx?s=search+term&amp;foo=bar','popup',{features})
    the outcomes of all scripted windows are affected by
    your IE Popup blocker and tabbed browsing settings
    which in turn is affected by your IE Security zone settings (for popup blocking handling)
    and the settings of any third-party popup blocker you may have installed and enabled... it may not necessarily be visible on your browser toolbar.
    The first step in troubleshooting web browser issues is to test in no-addons mode.
    Use the Developer Tool to find out what documentMode the test page is opening in on your system. On Modal/Modeless popup windows use the f12 key to display the Developer tool positioned on the contentWindow.
    Use File>Properties to find out what IE Security zone it maps to... there is a security setting to prevent navigation into zones of lower integrity.
    Rob^_^

  • Dialogs VS Frames

    I am creating a simple program that needs to make use of the modal facility of the "Dialog" class but at the same time have the same functionality of the "Frame" class. I've been looking into Dialogs on the web, and looked at the API spec. It says that both the "Frame" and "Dialog" class extend the window class, adding the border and the Title bar. I read on http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
    that "windows that are more limited than frames". But the only difference I can spot is that it doesn't have the "minimise" "iconify" buttons, but does have a close button-does that close button actually work? My question is, is that the only difference, or are there more? The windows that I want to create, that I want to be modal, will be using the AWT package and have a lot of controls on it!

    Windows basically have no decorations, including the taskbar button on the bottom of Windows systems, so any minimize or resize stuff needs to be handled yourself. Because of this, minimize might be difficult. Otherwise, I think for the most part, Windows are the same as Frames, as far as being top level containers. Dialogs have the modal capability, but not Frames or Windows. However, modal is relative. Relative to the the parent "window", that is. So you can't really create an application with 1 window and have that modal. I think you might mean "always on top", and there's no system level "always on top" mode for windows in Java. Maybe there is if you were to use the skins look & feel (http://www.l2fprod.com/). But I think this is only good on MS Windows.

  • How to printa frame or a dialog

    till now i have constructed JFrames andJDialogs in my project , now i would like to give an option to print the same , using a button at teh bottom of teh frame or dialog...how can i do it .....????

    1) create: class WFrame extends JFrame implements Printable
    2) import
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import java.lang.reflect.*;
    import java.awt.datatransfer.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import javax.swing.plaf.*;
    import javax.swing.plaf.metal.*;
    3) add these 3 methods to your class WFrame
         public void onPrint() throws PrinterException {
              PrinterJob printJob = PrinterJob.getPrinterJob();
              printJob.setPrintable(this);
              PageFormat pf = printJob.pageDialog(printJob.defaultPage());
              if (printJob.printDialog())
                   printJob.print();
         public int print(Graphics g, PageFormat pg, int i) throws PrinterException {
              int no = 1; //getNumberOfPages();
              if (i>-1 && i<no) {
                   g.translate((int)pg.getImageableX(), (int)(pg.getImageableY()+(pg.getImageableY()+pg.getImageableHeight())*i));
                   g.setClip(0, 0, getSize().width, getSize().height);
                   paint(g);
                   return PAGE_EXISTS;
              return NO_SUCH_PAGE;
         public void onCaptureScreen(String filename) throws IOException, FileNotFoundException, AWTException {
              FileOutputStream file = new FileOutputStream(new File(filename));
              JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file);
              Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
              encoder.encode(new Robot().createScreenCapture(rectangle));
              file.close();
    4) make code to call thoses methods

  • How do I set the frame size

    I am Making a program for purchasing games, with the basic layout alsot done, except on problem. When the purchase button is pressed, a dialog shows up but nothing is seen until i resize it. How would i set the frame size so that i do not need to resize it each time? below is the code for the files. Many thanks in advance.
    CreditDialog
    import java.awt.*;
    import java.awt.event.*;
    class CreditDialog extends Dialog implements ActionListener { // Begin Class
         private Label creditLabel = new Label("Message space here",Label.RIGHT);
         private String creditMessage;
         private TextField remove = new TextField(20);
         private Button okButton = new Button("OK");
         public CreditDialog(Frame frameIn, String message) { // Begin Public
              super(frameIn); // call the constructor of dialog
              creditLabel.setText(message);
              add("North",creditLabel);
              add("Center",remove);
              add("South",okButton);
              okButton.addActionListener(this);
              setLocation(150,150); // set the location of the dialog box
              setVisible(true); // make the dialog box visible
         } // End Public
         public void actionPerformed(ActionEvent e) { // Begin actionPerformed
    //          dispose(); // close dialog box
         } // End actionPerformed
    } // End Class
    MobileGame
    import java.awt.*;
    import java.awt.event.*;
    class MobileGame extends Panel implements ActionListener { // Begin Class
         The Buttons, Labels, TextFields, TextArea 
         and Panels will be created first.         
         private int noOfGames;
    //     private GameList list;
         private Panel topPanel = new Panel();
         private Panel middlePanel = new Panel();
         private Panel bottomPanel = new Panel();
         private Label saleLabel = new Label ("Java Games For Sale",Label.RIGHT);
         private TextArea saleArea = new TextArea(7, 25);
         private Button addButton = new Button("Add to Basket");
         private TextField add = new TextField(3);
         private Label currentLabel = new Label ("Java Games For Sale",Label.RIGHT);
         private TextArea currentArea = new TextArea(3, 25);
         private Button removeButton = new Button("Remove from Basket");
         private TextField remove = new TextField(3);
         private Button purchaseButton = new Button("Purchase");
         private ObjectList gameList = new ObjectList(20);
         Frame parentFrame; //needed to associate with dialog
         All the above will be added to the interface 
         so that they are visible to the user.        
         public MobileGame (Frame frameIn) { // Begin Constructor
              parentFrame = frameIn;
              topPanel.add(saleLabel);
              topPanel.add(saleArea);
              topPanel.add(addButton);
              topPanel.add(add);
              middlePanel.add(currentLabel);
              middlePanel.add(currentArea);
              bottomPanel.add(removeButton);
              bottomPanel.add(remove);
              bottomPanel.add(purchaseButton);
              this.add("North", topPanel);
              this.add("Center", middlePanel);
              this.add("South", bottomPanel);
              addButton.addActionListener(this);
              removeButton.addActionListener(this);
              purchaseButton.addActionListener(this);
              The following line of code below is 
              needed inorder for the games to be  
              loaded into the SaleArea            
         } // End Constructor
         All the operations which will be performed are  
         going to be written below. This includes the    
         Add, Remove and Purchase.                       
         public void actionPerformed (ActionEvent e) { // Begin actionPerformed
         If the Add to Basket Button is pressed, a       
         suitable message will appear to say if the game 
         was successfully added or not. If not, an       
         ErrorDialog box will appear stateing the error. 
              if(e.getSource() == addButton) { // Begin Add to Basket
    //          GameFileHandler.readRecords(list);
                   try { // Begin Try
                        String gameEntered = add.getText();
                        if (gameEntered.length() == 0 ) {
                             new ErrorDialog (parentFrame,"Feild Blank");
                        } else if (Integer.parseInt(gameEntered)< 0
                                  || Integer.parseInt(gameEntered)>noOfGames) { // Begin Else If
                             new ErrorDialog (parentFrame,"Invalid Game Number");
                        } else { // Begin Else If
                             //ADD GAME
                        } // End Else
                   } catch (NumberFormatException num) { // Begin Catch
                        new ErrorDialog(parentFrame,"Please enter an Integer only");
                   } // End Catch
              } // End Add to Basket
         If the Remove From Basket Button is pressed, a  
         a suitable message will appear to say if the    
         removal was successful or not. If not, an       
         ErrorDialog box will appear stateing the error. 
         if(e.getSource() == removeButton) { // Begin Remove from Basket
              try { // Begin Try
                        String gameEntered = remove.getText();
                        if (gameEntered.length() == 0 ) {
                             new ErrorDialog (parentFrame,"Feild Blank");
                        } else if (Integer.parseInt(gameEntered)< 1
                                  || Integer.parseInt(gameEntered)>noOfGames) { // Begin Else If
                             new ErrorDialog (parentFrame,"Invalid Game Number");
                        } else { // Begin Else If
                             //ADD GAME CODE
                        } // End Else
                   } catch (NumberFormatException num) { // Begin Catch
                        new ErrorDialog(parentFrame,"Please enter an Integer only");
                   } // End Catch
              } // End Remove from Basket
         If the purchase button is pressed, the          
         following is executed. NOTE: nothing is done    
         when the ok button is pressed, the window       
         just closes.                                    
              if(e.getSource() == purchaseButton) { // Begin Purchase
                   String gameEntered = currentArea.getText();
                   if (gameEntered.length() == 0 ) {
                        new ErrorDialog (parentFrame,"Nothing to Purchase");
                   } else { // Begin Else If
                        new CreditDialog(parentFrame,"Cost � 00.00. Please enter Credit Card Number");
                   } // End Else               
              } // End Purchase
         } // End actionPerformed
    } // End Class
    RunMobileGame
    import java.awt.*;
    public class RunMobileGame { // Begin Class
         public static void main (String[] args) { // Begin Main
              EasyFrame frame = new EasyFrame();
              frame.setTitle("Game Purchase for 3G Mobile Phone");
              MobileGame purchase = new MobileGame(frame); //need frame for dialog
              frame.setSize(500,300); // sets frame size
              frame.setBackground(Color.lightGray); // sets frame colour
              frame.add(purchase); // adds frame
              frame.setVisible(true); // makes the frame visible
         } // End Main
    } // End Class
    EasyFrame
    import java.awt.*;
    import java.awt.event.*;
    public class EasyFrame extends Frame implements WindowListener {
    public EasyFrame()
    addWindowListener(this);
    public EasyFrame(String msg)
    super(msg);
    addWindowListener(this);
    public void windowClosing(WindowEvent e)
    dispose();
    public void windowDeactivated(WindowEvent e)
    public void windowActivated(WindowEvent e)
    public void windowDeiconified(WindowEvent e)
    public void windowIconified(WindowEvent e)
    public void windowClosed(WindowEvent e)
    System.exit(0);
    public void windowOpened(WindowEvent e)
    } // end EasyFrame class
    ObjectList
    class ObjectList
    private Object[] object ;
    private int total ;
    public ObjectList(int sizeIn)
    object = new Object[sizeIn];
    total = 0;
    public boolean add(Object objectIn)
    if(!isFull())
    object[total] = objectIn;
    total++;
    return true;
    else
    return false;
    public boolean isEmpty()
    if(total==0)
    return true;
    else
    return false;
    public boolean isFull()
    if(total==object.length)
    return true;
    else
    return false;
    public Object getObject(int i)
    return object[i-1];
    public int getTotal()
    return total;
    public boolean remove(int numberIn)
    // check that a valid index has been supplied
    if(numberIn >= 1 && numberIn <= total)
    {   // overwrite object by shifting following objects along
    for(int i = numberIn-1; i <= total-2; i++)
    object[i] = object[i+1];
    total--; // Decrement total number of objects
    return true;
    else // remove was unsuccessful
    return false;
    ErrorDialog
    import java.awt.*;
    import java.awt.event.*;
    class ErrorDialog extends Dialog implements ActionListener {
    private Label errorLabel = new Label("Message space here",Label.CENTER);
    private String errorMessage;
    private Button okButton = new Button("OK");
    public ErrorDialog(Frame frameIn, String message) {
    /* call the constructor of Dialog with the associated
    frame as a parameter */
    super(frameIn);
    // add the components to the Dialog
              errorLabel.setText(message);
              add("North",errorLabel);
    add("South",okButton);
    // add the ActionListener
    okButton.addActionListener(this);
    /* set the location of the dialogue window, relative to the top
    left-hand corner of the frame */
    setLocation(100,100);
    // use the pack method to automatically size the dialogue window
    pack();
    // make the dialogue visible
    setVisible(true);
    /* the actionPerformed method determines what happens
    when the okButton is pressed */
    public void actionPerformed(ActionEvent e) {
    dispose(); // no other possible action!
    } // end class
    I Know there are alot of files. Any help will be much appreciated. Once again, Many thanks in advance

    setSize (600, 200);orpack ();Kind regards,
      Levi
    PS:
        int i;
    parses to
    int i;
    , but
    [code]    int i;[code[i]]
    parses to
        int i;

  • How to Show a Model Dialog box in a JApplet

    I have a JTable in a JApplet.
    I need to display a JDialog box as a Model Dialog. The JDialog expects a Frame as parent. How do I create a Frame and show my own dialog box? without a parent Frame the dialog shows up as a Modeless dialog box.
    Any help would be appreciated.

    I found the answer in
    http://www.jguru.com/faq/view.jsp?EID=27423

  • Changing Framemaker (8) dialog box size(s)

    We are using Framemaker 8.
    We have run into a problem because our files are embedded many layers down on our servers. If we move a folder, when Frame tries to relink the graphics (we always import as reference), the path name is ALWAYS truncated....not only is the path truncated, but sometimes the filename itself is cut off (we often have long file names).
    We were looking for a way to enlarge the dialog box...someone told us to check in the maker.ini file but (even according to the Customizing Frame Products document) all it seems you can do is change the position of the dialog, not the size.
    Even doing a List of References doesn't always show the full pathname properly.
    If anyone has any solutions, please let me know.

    RE: the Frame 7 dialog box modification from Klaus Daube...I emailed Klaus and here is his reply:
    "You all have asked for an updated version of the UI-modifactions for FrameMaker 8. I have fed you with hopes to the end of 2008/beginning of
    2009 ...
    In the meantime Adobe has released FrameMaker 9 which introduces a new user interface. IMHO it is very good although it needs some releraning (and still has its bugs). Some of the new dialogs (called pods, they are dockable palettes) looking quite similar to my modifications - so Adobe has heared the message. Other dialogs from the 'old' dialogue system are not modified to the user's benefit and I will look into these.
    You will understand that with these circumstances I will not modifiy FM-8 dialogs and concentrate on the new FM-9. There are still annoyances in this UI, but this is common to x.0 releases and we must wait whether our complaints are heard.
    Thank You for Your interest in my work and keep using FrameMaker, which IMHO _is_ the most valuable program for technical documentation (although I'm not a DITA enthusiast).
    Klaus Daube
    PS: If I really get fed up with the big annoyances of FM-9 (no indication what program/window is active; no title bar with the name of the active document ...) It may be possible that I will sit down for some days (about 50h) to tweak the FM-8 dialogs according to my previous work. But I can not promise anything."
    RE: The ResHacker program at http://www.angusj.com/resourcehacker/
    I (Jackie) was able to open the fmdlg.dll and find the dialog box in question, and even change the width of it. However, upon saving the new DLL and placing it in the correct folder (yes we saved a copy of our original file), I received the message from Frame "fmdlg.dll is either missing or corrupted". Not sure if having a new save date is what causes the error...any additional advice????

  • What's the best way of using dialogs?

    Let's guess that we have frame and dialog,
    dialog is really complicated and have many components like JTextField, JTextArea check bottons etc...
    What's right way to return all information from dialog to frame when user fill all components and push OK? I thought that it'd better to create an object put all information in there and return it to frame, but I didn't find how to set user return object to dialogs..
    What do you usually do?

    Let's guess that we have frame and dialog...
    What do you usually do? I look at the API specs and Tutorials to see if I missed something in using dialogs, if I still can't figure it out, then I post a question here with sample code and error messages...
    Otherwise it a huge GUESS as to what the problem is...
    The Java Tutorial
    http://java.sun.com/docs/books/tutorial/index.html
    Essentials of the Java Programming Language: A Hands-On Guide, Part 1 and 2
    http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/
    http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/
    Language Essentials Short Course
    http://java.sun.com/developer/onlineTraining/JavaIntro/contents.html
    Tutorial Index
    http://java.sun.com/developer/onlineTraining/index.html
    J2SE API Specification Index
    http://java.sun.com/reference/api/index.html
    Setting the class path
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    - MaxxDmg...

  • Application Dialog fonts change with change in Themes....

    Hi
    In my Application, alongwith other items like frame and dialog titles, the dialog controls like labels and buttons also change with the change in font styles and sizes.
    Expected behaviour: The texts on the buttons and other controls of the dialogs should not change....
    Please suggest...??
    I am not explicitly setting any font sizes to the controls of the dialogs (only taking the default values assigned) , do i need to set them explicitly or is there any other solution,,,?

    You can't change the fonts.
    In preferences you can modify the darkness and lightness of the whole program. Go to Edit > Preferences > User Interface and move the brightness slider. You might find a spot where the text is easier to read.

Maybe you are looking for