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
package ilist.ui; | |
import ilist.ui.generic.components.TransparentPanel; | |
import java.awt.BorderLayout; | |
import java.awt.Color; | |
import java.awt.Component; | |
import java.awt.Dimension; | |
import java.awt.Frame; |
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
someComponent.addPropertyChangeListener(new PropertyChangeListener() { | |
public void propertyChange(PropertyChangeEvent evt) { | |
if (evt.getPropertyName().equals("color") && evt.getNewValue() instanceof Color) { | |
Color color = (Color) evt.getNewValue(); | |
someComponent.setColor(color); | |
someComponent.repaint(); | |
} | |
} | |
}); |
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 static final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver"; | |
public static final String PROTOCOL = "jdbc:derby:"; | |
public static final String DATABASE_NAME = "myGreatDatabase"; | |
private Connection connection = null; | |
private void () { | |
try { | |
Class.forName(DRIVER).newInstance(); | |
connection = DriverManager.getConnection(PROTOCOL + DATABASE_NAME + ";create=true"); |
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 void shutdown() { | |
try { | |
connection.close(); | |
DriverManager.getConnection(PROTOCOL + ";shutdown=true"); | |
} catch (SQLException se) { | |
// an exception is thrown even if the database is closed correctly, | |
// so we have to check the current state to see if something failed | |
if (!"XJ015".equals(se.getSQLState())) | |
se.printStacktrace(); |
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 void initTables() { | |
Statement statement1 = null; | |
PreparedStatement statement2 = null; | |
try { | |
statement1 = connection.createStatement(); | |
statement1.execute("create table people(name varchar(40) not null, age int)"); | |
connection.commit(); | |
statement2 = connection.prepareStatement("insert into people values (?, ?)"); |