Wednesday, October 03, 2007
CopyOnWriteMap
I finally got around to writing an implementation of java.util.Map, which provides a fast, concurrent way to access a Map. Write operations are more expensive, but you would only want to use this class if reading is your primary objective. I had found a few other implementations of a copy-on-write Map, but I did not think they were quite right. With some help from the MINA team, I have the class in the trunk of MINA and all is well.
Thursday, September 13, 2007
Andy McKee
This guy is simply amazing. If you appreciate music even a little, you will love what Andy Mckee
can do with a guitar. He has many of his songs on youtube, and you can also get his music on iTunes.
can do with a guitar. He has many of his songs on youtube, and you can also get his music on iTunes.
Tuesday, September 11, 2007
Abstract Dialog Class
Here is the code from a class that I have used for years. This class extends JDialog in a way that adding components to it is very painless, since it uses GridBagLayout. I hope to soon comment it better and add an example, but for now you will have to look at the code to see what is going on.
package org.markwebb.gui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
/**
* This is an abstract class which takes many of the pains out of
* GridBagLayout. The Dialog is set to modal.
*
* @author Mark Webb
*
*/
public abstract class AbstractDialog extends JDialog implements ActionListener {
protected static final String ACCEPT = "Accept";
protected static final String CANCEL = "Cancel";
protected static final String CLOSE = "Close";
protected JPanel mainPanel;
protected GridBagConstraints c;
private int row, col;
public AbstractDialog( JFrame parent, String title, String borderTitle ){
super( parent, title, true );
setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(5,5,5,5);
row = 0;
col = 0;
mainPanel = new JPanel();
mainPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black, 1),
borderTitle, TitledBorder.LEFT, TitledBorder.TOP ));
mainPanel.setLayout( new GridBagLayout() );
add( mainPanel, BorderLayout.CENTER );
JPanel buttons = new JPanel();
JButton accept = new JButton( ACCEPT );
accept.addActionListener( this );
buttons.add( accept );
JButton cancel = new JButton( CANCEL );
cancel.addActionListener( this );
buttons.add( cancel );
JButton close = new JButton( CLOSE );
close.addActionListener( this );
buttons.add( close );
add( buttons, BorderLayout.SOUTH );
}
public void addToRow( JComponent comp, int width ){
// add the component
addItem( col, row, width , comp );
// increment the column number
col++;
}
public void addToNewRow( JComponent comp, int width ){
// increment the row number
row++;
// reset the column number
col = 0;
// add the component
addItem( col, row, width , comp );
// increment the column number
col++;
}
private void addItem( int x, int y, int w, JComponent comp )
{
c.gridx = x;
c.gridy = y;
c.gridwidth = w;
mainPanel.add( comp, c );
}
public void actionPerformed( ActionEvent e ){
if( e.getActionCommand().equals( ACCEPT )){
doAccept();
} else if( e.getActionCommand().equals( CANCEL )){
doCancel();
} else if( e.getActionCommand().equals( CLOSE )){
doClose();
}
}
private void doClose(){
setVisible( false );
}
protected abstract void doAccept();
protected abstract void doCancel();
}
Sunday, September 09, 2007
My Visual DNA
I tried this site, and it is amazing how well it works. Try it out! http://dna.imagini.net/friends
Free Database Models
At this site - Library of Free Data Models, you can find database schemas for just about anything that you can think of. I find this the most important part of creating a database driven system. If you don''t get the database back-end set up right, your program will not work to its potential.
Photoshop tutorial
This guys puts together the most incredible, step-by-step photoshop tutorial I have ever seen. The image is so lifelike at the end. Really a must see...Me & Louie''s Sister - Page 1
Spring Framework
This is a great introduction to the Spring Framework. It describes a basic Java application that uses JDBC, and then the same program using Spring. java.net: Why Spring JDBC? As for JDBC, using Spring and Hibernate together makes the most sense. There is an article in the May 2006 edition covering Hibernate, Eclipse, WTP and Struts. Check it out.
C++ for java programmers
Here is a great C++ tutorial for Java programmers. Click here to check out the tutorial. There are many references to the differences between C++ and Java. Most of the time, programmers migrate from C++ to Java, but I have found that this site is a great start for Java developers to learn, or in my case, re-learn C++.
Try and beat this...
- Pool table installed
- Bar nearly complete
- Bar stocked
Thursday, September 06, 2007
hell yeah
I got some polish in me, I wonder if they want a little more polish in them ???
Top 10 Most Beautiful Polish Women
Top 10 Most Beautiful Polish Women
Wordpress to hell
So for the last few years, I have been managing my own blog at my site. Just in the last few days, the database got hosed and I finally said fuck it. I have had this site for years and now it is where I will place all my blogs.
Subscribe to:
Posts (Atom)