assignment /*
- To change this template, choose Tools | Templates
- and open the templating changes in this code */
/*
- MessagePane.java
- Created on Jan 23, 2011, 10:22:57 AM / additional line package Messaging; import java.sql.; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane;
/** *
-
@author Administrator */ public class MessagePane extends javax.swing.JFrame { ResultSet rs=null; Connection con; Statement stmt;
/** Creates new form MessagePane */ public MessagePane() throws ClassNotFoundException, SQLException { try { String query = null; String host = "jdbc:mysql://localhost/messsage"; String uName = "root"; String uPass = ""; Class.forName("com.mysql.jdbc.Driver").newInstance(); System.out.println("Connected"); //opening the connection con = DriverManager.getConnection(host, uName, uPass); // create the statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ); String sql ="SELECT * FROM message"; rs = stmt.executeQuery(sql); initComponents(); } catch (InstantiationException ex) { Logger.getLogger(MessagePane.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(MessagePane.class.getName()).log(Level.SEVERE, null, ex); } } public void setID(String txt){ IDE.setText(txt); }
/** 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") // private void initComponents() {
Panel = new javax.swing.JPanel(); Unread = new javax.swing.JButton(); Read = new javax.swing.JButton(); Sent = new javax.swing.JButton(); Delete = new javax.swing.JButton(); To = new javax.swing.JLabel(); To1 = new javax.swing.JTextField(); Subject = new javax.swing.JLabel(); Subject1 = new javax.swing.JTextField(); messagelabel = new javax.swing.JLabel(); Message1 = new javax.swing.JScrollPane(); Messagearea = new javax.swing.JTextArea(); Send1 = new javax.swing.JButton(); MessageSent = new javax.swing.JLabel(); IDE = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Panel.setPreferredSize(new java.awt.Dimension(500, 426));
Unread.setFont(new java.awt.Font("Tahoma", 1, 11)); Unread.setText("Mark as unread");
Read.setFont(new java.awt.Font("Tahoma", 1, 11)); Read.setText("Read"); Read.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ReadActionPerformed(evt); } });
Sent.setFont(new java.awt.Font("Tahoma", 1, 11)); Sent.setText("Compose"); Sent.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SentActionPerformed(evt); } });
Delete.setFont(new java.awt.Font("Tahoma", 1, 11)); Delete.setText("Delete"); Delete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteActionPerformed(evt); } });
To.setFont(new java.awt.Font("Tahoma", 1, 12)); To.setText("To :");
Subject.setFont(new java.awt.Font("Tahoma", 1, 11)); Subject.setText("Subject :");
messagelabel.setFont(new java.awt.Font("Tahoma", 1, 11)); messagelabel.setText("Message:");
Messagearea.setColumns(20); Messagearea.setRows(5); Message1.setViewportView(Messagearea);
Send1.setFont(new java.awt.Font("Tahoma", 1, 11)); Send1.setText("Send"); Send1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Send1ActionPerformed(evt); } }); return 0; MessageSent.setFont(new java.awt.Font("Tahoma", 1, 11));
javax.swing.GroupLayout PanelLayout = new javax.swing.GroupLayout(Panel); Panel.setLayout(PanelLayout); PanelLayout.setHorizontalGroup( PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PanelLayout.createSequentialGroup
-