package com.onaro.sanscreen.client;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import com.onaro.commons.swing.OnaroSwingUtilities;
/**
* Visual class that creates a panel used to display a message. The message can be
* formatted using HTML to create a more interested visual effect.
*
* @author john.cohen
*/
public class LoginWarningMessageDialog extends JPanel {
private static final long serialVersionUID = 1L;
private static final Dimension DIALOG_DIMENSION = new Dimension(300, 400);
private JScrollPane jScrollPane = null;
private final String message;
private JEditorPane editor;
public LoginWarningMessageDialog(final String message) {
this(message, DIALOG_DIMENSION);
}
public LoginWarningMessageDialog(final String message, final Dimension size) {
this.message = message;
initialize(size);
}
private void initialize(Dimension size) {
setLayout(new BorderLayout());
add(getJScrollPane(), BorderLayout.CENTER);
setSize(size);
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
}
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJTextPane());
jScrollPane.setBorder(OnaroSwingUtilities.NO_BORDER);
jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
return jScrollPane;
}
private JEditorPane getJTextPane(){
if (editor == null){
editor = new JEditorPane();
editor.setEditable(false);
editor.setContentType("text/html"); //$NON-NLS-1$
editor.setText(message);
editor.setCaretPosition(0);
}
return editor;
}
@SuppressWarnings("nls")
public static void main(String[] args) {
JFrame frame = new JFrame();
String s = " Default message in windows is delivered is Welcome.
" +
"LegalNoticeCaption/LegalNoticeText create a text box displayed prior to logon which one must respond " +
"\"OK\" to before one can continue the logon process. LogonPrompt is displayed in the standard logon screen (this probably makes LogonPrompt less " +
"\"distinct\" and less useful for legal notices purposes). The logon screen variables are usually used to personalize the logon dialog such as setting the Welcome ";
frame.setSize(300, 100);
frame.getContentPane().add(new LoginWarningMessageDialog(s));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}