1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* EmailSender2.java
*
* Created on 2010-04-14, 20:31:07
*/
package EmailSender;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JHTMLEditor;
import chrriis.dj.nativeswing.swtimpl.components.JHTMLEditor.HTMLEditorImplementation;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.StringTokenizer;
/**
*
* @author Robert
*/
public class SendEmail extends javax.swing.JFrame {
/** Creates new form EmailSender2 */
public SendEmail() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
smtpServer = new javax.swing.JTextField();
port = new javax.swing.JTextField();
username = new javax.swing.JTextField();
from = new javax.swing.JTextField();
to = new javax.swing.JTextField();
subject = new javax.swing.JTextField();
password = new javax.swing.JPasswordField();
jPanel2 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
sendEmail = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("JEmail Client with FCKEditor");
jPanel1.setPreferredSize(new java.awt.Dimension(468, 150));
jPanel1.setLayout(null);
jLabel1.setText("Serwer smtp:");
jPanel1.add(jLabel1);
jLabel1.setBounds(10, 14, 64, 14);
jLabel3.setText("Port:");
jPanel1.add(jLabel3);
jLabel3.setBounds(180, 10, 24, 20);
jLabel2.setText("Użytkownik:");
jPanel1.add(jLabel2);
jLabel2.setBounds(10, 40, 58, 14);
jLabel4.setText("Hasło:");
jPanel1.add(jLabel4);
jLabel4.setBounds(183, 71, 31, 14);
jLabel5.setText("Twoj email:");
jPanel1.add(jLabel5);
jLabel5.setBounds(10, 71, 54, 14);
jLabel6.setText("Do kogo:");
jPanel1.add(jLabel6);
jLabel6.setBounds(10, 97, 43, 14);
jLabel7.setText("Temat:");
jPanel1.add(jLabel7);
jLabel7.setBounds(10, 128, 34, 14);
smtpServer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
smtpServerActionPerformed(evt);
}
});
jPanel1.add(smtpServer);
smtpServer.setBounds(92, 11, 80, 20);
jPanel1.add(port);
port.setBounds(220, 10, 40, 20);
jPanel1.add(username);
username.setBounds(92, 37, 80, 20);
from.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fromActionPerformed(evt);
}
});
jPanel1.add(from);
from.setBounds(93, 68, 80, 20);
jPanel1.add(to);
to.setBounds(93, 94, 325, 20);
jPanel1.add(subject);
subject.setBounds(93, 125, 325, 20);
password.setPreferredSize(new java.awt.Dimension(100, 20));
jPanel1.add(password);
password.setBounds(220, 70, 200, 20);
getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);
jPanel2.setLayout(new java.awt.BorderLayout());
sendEmail.setText("Wyślij");
sendEmail.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendEmailActionPerformed(evt);
}
});
jButton2.setText("Zamknij");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(sendEmail)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2)
.addContainerGap(319, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sendEmail)
.addComponent(jButton2))
.addContainerGap(19, Short.MAX_VALUE))
);
jPanel2.add(jPanel3, java.awt.BorderLayout.SOUTH);
getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_END);
pack();
}// </editor-fold>
private void smtpServerActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void fromActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void sendEmailActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
StringTokenizer recepientsTokenizer = new StringTokenizer(to.getText(), ",");
final String[] recipientsString = new String[recepientsTokenizer.countTokens()];
for (int i = 0; i < recipientsString.length; i++) {
recipientsString[i] = recepientsTokenizer.nextToken();
}
final EmailSender emailer = new EmailSender(smtpServer.getText(),
port.getText(), username.getText(),
password.getPassword().toString(),
"true", from.getText());
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
emailer.sendEmail(subject.getText(),
htmlEditor.getHTMLContent(),
recipientsString);
}
});
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
UIUtils.setPreferredLookAndFeel();
NativeInterface.open();
final String configurationScript =
"FCKConfig.ToolbarSets[\"Default\"] = [\n" +
"['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],\n" +
"['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],\n" +
"['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],\n" +
"['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],\n" +
"'/',\n" +
"['Style','FontFormat','FontName','FontSize'],\n" +
"['TextColor','BGColor'],\n" +
"'/',\n" +
"['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],\n" +
"['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],\n" +
"['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],\n" +
"['Link','Unlink','Anchor'],\n" +
"['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak', '-', 'ShowBlocks'],\n" +
"];\n" +
"FCKConfig.ToolbarCanCollapse = false;\n";
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
htmlEditor = new JHTMLEditor(HTMLEditorImplementation.FCKEditor,
JHTMLEditor.FCKEditorOptions.setCustomJavascriptConfiguration(configurationScript));
SendEmail es2 = new SendEmail();
es2.setSize(new Dimension(800,600));
es2.add(htmlEditor,BorderLayout.CENTER);
es2.setLocationByPlatform(true);
es2.setVisible(true);
}
});
}
private static JHTMLEditor htmlEditor;
// Variables declaration - do not modify
private javax.swing.JTextField from;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPasswordField password;
private javax.swing.JTextField port;
private javax.swing.JButton sendEmail;
private javax.swing.JTextField smtpServer;
private javax.swing.JTextField subject;
private javax.swing.JTextField to;
private javax.swing.JTextField username;
// End of variables declaration
} |