Skip to content

Instantly share code, notes, and snippets.

View bjpeterdelacruz's full-sized avatar

BJ Dela Cruz bjpeterdelacruz

View GitHub Profile
public class Id implements Serializable {
private final int hashCode;
public Id() {
hashCode = super.hashCode();
}
@Override
public int hashCode() {
String msg = "Are you sure you want to cancel the selected bookings?";
String[] options = new String[] { "Yes", "No" };
int option = JOptionPane.showOptionDialog(null, msg, "Confirm Unbooking", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);
if (option == 1) {
return;
}
/**
* Tests the locking mechanism in this class.
*
* @param args None.
* @throws Exception If there are problems.
*/
public static void main(String... args) throws Exception {
ExecutorService threadPool = Executors.newFixedThreadPool(5);
while (locksMap.get(recNo) != null) {
condition.await();
}
Properties properties = new Properties();
FileInputStream istream = new FileInputStream(Constants.PROPERTIES_FILE);
properties.load(istream);
String value = properties.getProperty("db.location");
istream.close();
Properties properties = new Properties();
properties.setProperty("db.location", "/path/to/db-2x1.db");
FileOutputStream ostream = new FileOutputStream(Constants.PROPERTIES_FILE);
String msg = " This file stores properties for both the client and server.";
properties.store(ostream, msg);
ostream.close();
checkbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent event) {
if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(parentComponent, "...", "...", JOptionPane.YES_NO_OPTION) {
return;
}
// Programmatically click on the Apply Changes button.
}
checkbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(parentComponent, "...", "...", JOptionPane.YES_NO_OPTION) {
return;
}
// Programmatically click on the Apply Changes button.
}
/**
* @author BJ Peter DeLaCruz
*/
public JTree createTree() {
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setClosedIcon(null);
renderer.setLeafIcon(null);
renderer.setOpenIcon(null);
JTree tree = new JTree();
tree.setCellRenderer(renderer);
// This method will concatenate a list of Number objects.
public <T extends Number> List<T> concat(List<T> list1, List<T> list2) {
List<T> list = new ArrayList<T>();
list.addAll(list1);
list.addAll(list2);
return list;
}