Old school applet, why not embedded in Twitter, Instagram or Tumblr?

Recently I archived some old directories and came along some ancient 1.3 stuff.
Just for fun I was wondering if they would still work (in Java 8). After some copy-pasting, they ran right away, how nice!

(You might want to accept the domain in your Java security setting). Ay caramba, probably you’re not seeing the glass on your mobile.

Sooo, wouldn’t it be nice to allow Java applets or midlets in Twitter, Instagram or Tumblr. Opening tons of new possibilities (and security issues).
Sidenote: The glass you see is a Duralex glass, when I was a student we used to drink from these.

MySQL drop all tables using stored procedure

DELIMITER $$
DROP PROCEDURE IF EXISTS drop_all_tables $$
CREATE PROCEDURE drop_all_tables(IN scheme VARCHAR(255))
BEGIN
    DECLARE v_done INT DEFAULT FALSE;
    DECLARE v_tableName VARCHAR(255);
    DECLARE v_cursor CURSOR FOR
        SELECT table_name 
        FROM   information_schema.TABLES
        WHERE  table_schema = scheme;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;

    SET FOREIGN_KEY_CHECKS = 0;

    OPEN v_cursor;
    REPEAT FETCH v_cursor INTO v_tableName;

    IF NOT v_done THEN
        SET @stmt_sql = CONCAT('DROP TABLE ', v_tableName);
        PREPARE stmt1 FROM @stmt_sql;
        EXECUTE stmt1;
        DEALLOCATE PREPARE stmt1;
    END IF;

    UNTIL v_done END REPEAT;

    CLOSE v_cursor;
    SET FOREIGN_KEY_CHECKS = 1;
END$$
DELIMITER ;

Filtered type ahead JComboBox

Swing offers nice possibilities to use a JComboBox with some sort of pre-selecting or type ahead features. One of the major drawbacks is, it does not remove items who don-not match at all (when typing).

In one of my projects it was required to filter out possibilities from the JComboBox when the user starts typing, so the list gets smaller when the user starts typing (large lists!). Of course the list grows back again when backspace is pressed(*).

I’ve found several solutions around, but non of them are completely satisfactory for me, mostly because they are to specific or to complex (maybe my solution isn’t the best either).

Some features and some drawbacks are known for the version presented in this issue:

  • because of using backspace and rebuilding the JComboBox, all items must be present when an instance is created (* as shown earlier)
  • because the user can enter text, the first item should be an empty one to hold the search term
  • when no match occurs, getSelectedItem(0) is there to get the users query

For me it was important to use the getSelectedItem() method instead of the getSelectedIndex() method on an ActionEvent, since the user might have typed some text which was not present yet. The text from getSelectedItem() then is added to the database (in my application). Because of the filtering, double occurrences are minimized this way.

Link: FilteredTypeAheadComboBox.java
Link: FilteredTypeAheadDemo.java
Javawebstart: FilteredTypeAheadDemo.jnlp
(You might want to accept the domain in your Java security setting).