This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Id implements Serializable { | |
private final int hashCode; | |
public Id() { | |
hashCode = super.hashCode(); | |
} | |
@Override | |
public int hashCode() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (locksMap.get(recNo) != null) { | |
condition.await(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Properties properties = new Properties(); | |
FileInputStream istream = new FileInputStream(Constants.PROPERTIES_FILE); | |
properties.load(istream); | |
String value = properties.getProperty("db.location"); | |
istream.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |