From 6ce0a8db7ce7521a4f7ae040196fd0416af8309f Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Wed, 12 Dec 2007 18:50:25 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@596 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../medicina/processo/mail/MailPanel.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailPanel.java diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailPanel.java new file mode 100644 index 00000000..b780e4da --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailPanel.java @@ -0,0 +1,83 @@ +package siprp.medicina.processo.mail; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.Action; +import javax.swing.ActionMap; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextPane; +import javax.swing.text.DefaultEditorKit; +import javax.swing.text.html.HTMLEditorKit; + +public class MailPanel extends JPanel +{ + protected JTextPane bodyPane; + + public static void main( String args[] ) + { + JFrame frm = new JFrame(); + frm.getContentPane().setLayout( new GridLayout( 1, 1 ) ); + frm.getContentPane().add( new MailPanel() ); + frm.addWindowListener( new WindowAdapter(){ + public void windowClosing( WindowEvent e ) + { + System.exit( 0 ); + } + } ); + frm.setSize( 1024, 768 ); + frm.setVisible( true ); + } + + public MailPanel() + { + setupComponents(); + } + + private void setupComponents() + { + HTMLEditorKit kit = new HTMLEditorKit(); + bodyPane = new JTextPane(); + bodyPane.setEditorKit( kit ); + ActionMap actionMap = bodyPane.getActionMap(); + + Action cutAction = actionMap.get( DefaultEditorKit.cutAction ); + Action copyAction = actionMap.get( DefaultEditorKit.copyAction ); + Action pasteAction = actionMap.get( DefaultEditorKit.pasteAction ); + + Action boldAction = actionMap.get( HTMLEditorKit.BOLD_ACTION ); + Action italicAction = actionMap.get( HTMLEditorKit.ITALIC_ACTION ); + Action underlineAction = actionMap.get( "font-underline" ); + Action smallerAction = actionMap.get( HTMLEditorKit.FONT_CHANGE_SMALLER ); + Action biggerAction = actionMap.get( HTMLEditorKit.FONT_CHANGE_BIGGER ); + + Action alignLeftAction = actionMap.get( HTMLEditorKit.PARA_INDENT_LEFT ); + Action alignCenterAction = actionMap.get( "center-justify" ); + Action alignRightAction = actionMap.get( HTMLEditorKit.PARA_INDENT_RIGHT ); + + JPanel upperPanel = new JPanel(); + upperPanel.setLayout( new FlowLayout( FlowLayout.LEFT ) ); + upperPanel.add( new JButton( cutAction ) ); + upperPanel.add( new JButton( copyAction ) ); + upperPanel.add( new JButton( pasteAction ) ); + upperPanel.add( new JButton( boldAction ) ); + upperPanel.add( new JButton( italicAction ) ); + upperPanel.add( new JButton( underlineAction ) ); + upperPanel.add( new JButton( smallerAction ) ); + upperPanel.add( new JButton( biggerAction ) ); + upperPanel.add( new JButton( alignLeftAction ) ); + upperPanel.add( new JButton( alignCenterAction ) ); + upperPanel.add( new JButton( alignRightAction ) ); + + + setLayout( new BorderLayout() ); + + add( upperPanel, BorderLayout.NORTH ); + add( bodyPane, BorderLayout.CENTER ); + } +}