Created the functionality for deleting a legal notice.
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
+ <Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
- <Group type="103" groupAlignment="1" attributes="0">
- <Group type="102" attributes="0">
- <Component id="buttonApply" min="-2" pref="106" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- <Component id="buttonCancel" min="-2" pref="106" max="-2" attributes="0"/>
- </Group>
- <Group type="103" groupAlignment="0" max="-2" attributes="0">
- <Component id="checkClarificationPending" max="32767" attributes="0"/>
- <Component id="jLabel1" max="32767" attributes="0"/>
- <Component id="jScrollPane1" pref="369" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jScrollPane1" min="-2" pref="378" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="buttonApply" min="-2" pref="106" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="buttonCancel" min="-2" pref="106" max="-2" attributes="0"/>
+ </Group>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="checkClarificationPending" pref="369" max="32767" attributes="0"/>
+ <Component id="jLabel1" max="32767" attributes="0"/>
+ </Group>
</Group>
</Group>
- <EmptySpace pref="21" max="32767" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
- <Component id="jScrollPane1" min="-2" pref="96" max="-2" attributes="0"/>
- <EmptySpace pref="17" max="32767" attributes="0"/>
+ <Component id="jScrollPane1" pref="83" max="32767" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonApply" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(checkClarificationPending, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)))
- .addContainerGap(21, Short.MAX_VALUE))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 378, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(checkClarificationPending, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonApply)
.addComponent(buttonCancel))
Utility.retrieveConnectionURL();
try {
- UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
Logger.getLogger(Habeas.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDescriptionActionPerformed"/>
</Events>
</MenuItem>
+ <MenuItem class="javax.swing.JMenuItem" name="menuClarificationDetails">
+ <Properties>
+ <Property name="mnemonic" type="int" value="114"/>
+ <Property name="text" type="java.lang.String" value="Clarification Details..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuClarificationDetailsActionPerformed"/>
+ </Events>
+ </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuDraftStatus">
<Properties>
<Property name="mnemonic" type="int" value="68"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuBillDetailsActionPerformed"/>
</Events>
</MenuItem>
- <MenuItem class="javax.swing.JMenuItem" name="menuClarificationDetails">
+ <Component class="javax.swing.JPopupMenu$Separator" name="jSeparator1">
+ </Component>
+ <MenuItem class="javax.swing.JMenuItem" name="menuDelete">
<Properties>
- <Property name="mnemonic" type="int" value="114"/>
- <Property name="text" type="java.lang.String" value="Clarification Details..."/>
+ <Property name="text" type="java.lang.String" value="Delete"/>
</Properties>
<Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuClarificationDetailsActionPerformed"/>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDeleteActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Date;
+import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
popMenu = new javax.swing.JPopupMenu();
menuDescription = new javax.swing.JMenuItem();
+ menuClarificationDetails = new javax.swing.JMenuItem();
menuDraftStatus = new javax.swing.JMenuItem();
menuDispatchDetails = new javax.swing.JMenuItem();
menuBillDetails = new javax.swing.JMenuItem();
- menuClarificationDetails = new javax.swing.JMenuItem();
+ jSeparator1 = new javax.swing.JPopupMenu.Separator();
+ menuDelete = new javax.swing.JMenuItem();
jScrollPane1 = new javax.swing.JScrollPane();
tableNotices = new javax.swing.JTable();
});
popMenu.add(menuDescription);
+ menuClarificationDetails.setMnemonic('r');
+ menuClarificationDetails.setText("Clarification Details...");
+ menuClarificationDetails.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ menuClarificationDetailsActionPerformed(evt);
+ }
+ });
+ popMenu.add(menuClarificationDetails);
+
menuDraftStatus.setMnemonic('D');
menuDraftStatus.setText("Draft Status...");
menuDraftStatus.setToolTipText("");
}
});
popMenu.add(menuBillDetails);
+ popMenu.add(jSeparator1);
- menuClarificationDetails.setMnemonic('r');
- menuClarificationDetails.setText("Clarification Details...");
- menuClarificationDetails.addActionListener(new java.awt.event.ActionListener() {
+ menuDelete.setText("Delete");
+ menuDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- menuClarificationDetailsActionPerformed(evt);
+ menuDeleteActionPerformed(evt);
}
});
- popMenu.add(menuClarificationDetails);
+ popMenu.add(menuDelete);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Manage Notices");
frm.setVisible(true);
}//GEN-LAST:event_menuClarificationDetailsActionPerformed
+ private void menuDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDeleteActionPerformed
+ int selid = getSelectedNotice();
+ if (selid == -1) return;
+ int conf = JOptionPane.showConfirmDialog((Frame)this.getParent(), CONFIRM_DELETE);
+ if (conf == JOptionPane.YES_OPTION) {
+ boolean rt = Utility.deleteNotice (selid);
+ if (rt == false)
+ JOptionPane.showMessageDialog(this, ERROR_DELETING);
+ else
+ populateNotices();
+ }
+ }//GEN-LAST:event_menuDeleteActionPerformed
+ private static final String ERROR_DELETING = "Error in deleting";
+ private static final String CONFIRM_DELETE = "Are you sure you wish to delete?";
+
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JSeparator jSeparator1;
private javax.swing.JMenuItem menuBillDetails;
private javax.swing.JMenuItem menuClarificationDetails;
+ private javax.swing.JMenuItem menuDelete;
private javax.swing.JMenuItem menuDescription;
private javax.swing.JMenuItem menuDispatchDetails;
private javax.swing.JMenuItem menuDraftStatus;
return false;
}
+ }
+
+ static boolean deleteNotice(int r) {
+ try {
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+ PreparedStatement st = conn.prepareStatement("DELETE FROM legalnotices"
+ + " WHERE id=?;");
+ st.setInt(1, r);
+ st.execute();
+ conn.close();
+ return true;
+ } catch (SQLException ex) {
+ Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+ return false;
+ }
+
}
public Utility () {