LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to implement an about box in java gui (https://www.linuxquestions.org/questions/programming-9/how-to-implement-an-about-box-in-java-gui-4175416887/)

mia_tech 07-15-2012 07:52 PM

how to implement an about box in java gui
 
guys, I have a gui designed in netbeans, and I want to implement an about dialog box underneath the help menu. How could I do that?

Thanks

dwhitney67 07-17-2012 05:26 AM

Here's a snip of code that shows how to display an "about" dialog for a GUI.
Code:

    public MyGUI()
    {
        JMenuBar menubar = new JMenuBar(); // create menu bar
        ...
        JMenu help = new JMenu("Help");  // create help menu
        JMenuItem about = new JMenuItem("About MyGUI");  // create help menu item
        help.add(about);  // add that item to the menu
        ...
        menubar.add(help);  // add the help menu to the menubar
        ...
        // set the action listener to call the method aboutMyGUI()
        about.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    aboutMyGUI();
                                } });
        ...
    }


    /**
    * Displays a pop-up dialog with information about my GUI.
    */
    private void aboutMyGUI()
    {
        final String title  = "About GUI Tool";
        final String message = "Tool Version 1.0\n\n" +
                              "For support, contact: LinuxQuestions.org";

        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
            }
        });
    }

P.S. Why don't you procure a text book that covers the basics of Java Swing Programming? Some of the questions you ask are soooo basic. One book that comes to mind is "Introduction to Java Programming" by Y. Daniel Liang.

mia_tech 07-21-2012 12:50 AM

Quote:

Originally Posted by dwhitney67 (Post 4730397)
P.S. Why don't you procure a text book that covers the basics of Java Swing Programming? Some of the questions you ask are soooo basic. One book that comes to mind is "Introduction to Java Programming" by Y. Daniel Liang.

yeah, this is fine and all, but I remember doing this from the gui(dragging the menus) sometime ago, and that's what I was looking for


All times are GMT -5. The time now is 09:53 AM.