Java JDialog renderDialog(JDialog thedialog, String szMessage, int noffsetx, int noffsety)

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

Description

Calls renderDialog with Help in the title window for a dialog

License

Open Source License

Declaration

public static void renderDialog(JDialog thedialog, 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 {
    /**//from w  ww. j  av a2 s.  c o  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. makeJDialogCancellable(final Window w, final Action cancelAction, final boolean disposeOnCancel)
  2. messageDialog(String string, JDialog parentDialog)
  3. openDialog(final JDialog dialog)
  4. poseInsideScreen(JDialog component)
  5. positionDialogInContainer(JDialog dialog, Container frame, int horizontal, int vertical)
  6. resizeDialogToScreen(JDialog dialog)
  7. rptaConfirmDialog(JDialog pJDialog, String pMensaje)
  8. runProgressBar(final Runnable runnable, final JDialog dialog)
  9. setActionsMenu(JDialog dialog, MenuElement menu)