Java JFrame renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety)

Here you can find the source of renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety)

Description

Calls renderDialog with Help in the title window for a JFrame

License

Open Source License

Declaration

public static void renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;

import java.awt.*;

import javax.swing.*;

public class Main {
    /**/*w  w w. jav  a  2  s.co  m*/
     *Calls renderDialog with Help in the title window for a dialog
     */
    public static void renderDialog(JDialog thedialog, String szMessage, int noffsetx, int noffsety) {
        renderDialog(thedialog, szMessage, noffsetx, noffsety, "Help");
    }

    /**
     * Calls  renderDialog with Help in the title window for a JFrame
     */
    public static void renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety) {
        //textArea ==> szMessage
        renderDialog(theframe, szMessage, noffsetx, noffsety, "Help");
    }

    /**
     * Renders a dialog window with szMessage attached to thedialog at location (noffsetx,noffsety)
     * with title szTtitle
     */
    public static void renderDialog(JDialog thedialog, String szMessage, int noffsetx, int noffsety,
            String szTitle) {
        final JDialog thedialogf = thedialog;
        final JTextArea textAreaf = new JTextArea(szMessage);
        final int noffsetxf = noffsetx;
        final int noffsetyf = noffsety;
        final String szTitlef = szTitle;
        final int nlengthf = szMessage.length();
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JDialog helpDialog = new JDialog(thedialogf, szTitlef, false);
                Container theHelpDialogPane = helpDialog.getContentPane();

                helpDialog.setBackground(Color.white);
                theHelpDialogPane.setBackground(Color.white);

                textAreaf.setLineWrap(true);
                textAreaf.setWrapStyleWord(true);

                textAreaf.setBackground(Color.white);
                textAreaf.setEditable(false);
                JScrollPane jsp = new JScrollPane(textAreaf);

                theHelpDialogPane.add(jsp);

                helpDialog.setLocation(thedialogf.getX() + noffsetxf, thedialogf.getY() + noffsetyf);

                if (nlengthf < 600) {
                    helpDialog.setSize(700, 150);
                } else if (nlengthf < 1000) {
                    helpDialog.setSize(700, 250);
                } else {
                    helpDialog.setSize(700, 350);
                }

                helpDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                helpDialog.setVisible(true);
            }
        });
    }

    /**
     * Calls renderDialog with an offset X value of 25 and an offset Y value of 10
     */
    public static void renderDialog(JFrame theframe, String szMessage) {
        renderDialog(theframe, szMessage, 25, 10, "Help");
    }

    /**
     * Renders a dialog window with szMessage attached to theframe at location (noffsetx,noffsety)
     * with title szTtitle
     */
    public static void renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety, String szTitle) {
        final JFrame theframef = theframe;
        final JTextArea textAreaf = new JTextArea(szMessage);
        final int noffsetxf = noffsetx;
        final int noffsetyf = noffsety;
        final String szTitlef = szTitle;
        final int nlengthf = szMessage.length();
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JDialog helpDialog = new JDialog(theframef, szTitlef, false);
                Container theHelpDialogPane = helpDialog.getContentPane();

                helpDialog.setBackground(Color.white);
                theHelpDialogPane.setBackground(Color.white);

                textAreaf.setLineWrap(true);
                textAreaf.setWrapStyleWord(true);

                textAreaf.setBackground(Color.white);
                textAreaf.setEditable(false);
                JScrollPane jsp = new JScrollPane(textAreaf);
                theHelpDialogPane.add(jsp);

                helpDialog.setLocation(theframef.getX() + noffsetxf, theframef.getY() + noffsetyf);

                if (nlengthf < 600) {
                    helpDialog.setSize(700, 150);
                } else if (nlengthf < 1000) {
                    helpDialog.setSize(700, 250);
                } else {
                    helpDialog.setSize(700, 350);
                }

                helpDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                helpDialog.setVisible(true);
            }
        });
    }
}

Related

  1. position(JFrame f)
  2. putOnWidestScreen(JFrame frame)
  3. refreshShape(final JFrame frame)
  4. registerCloseAction(final JFrame dialog, KeyStroke keyStroke)
  5. registerMenuShortcut(String uniqueActionName, Action action, int keyCode, JFrame frame)
  6. replaceGlassPane(JFrame frame, Component newGlassPane)
  7. restoreFrame(Class pClass, final JFrame pFrame, String pFrameId)
  8. restoreFrame(JFrame frame)
  9. rightShiftDialog(JDialog dialog, JFrame parent)