Wednesday, May 16, 2007

The bad co-worker: recognise him!

Everybody of us has experienced the phenomenon "bad co-worker", but let me explain what I learned from my experience (web-developing, coding, graphics):
  1. He (the bad co-worker) designs a layout and then he sends it to me for slicing. BUT when I open the layout in Photoshop, I realise that it consists of 200 layers, ungrouped and named with names "layer 1, layer 2, layer 3, ......., layer 200". Believe me pal it is much easier for me to deal with grouped layers in categories like Header, Footer etc and names like Title, sidebar background etc than guessing or right clicking its layout's component to find the appropriate layer.
  2. If I am out of luck at all the layout file is merged down and in .jpg format with the sample text (which should be deleted) on it.
  3. When he writed code, he does not use "ENTER" button for changing line. The code is a mess, without comments and looks like simple text.
  4. When his pc has a problem, he asks the others first and then tries to fix it on his own.
  5. He prefer asking the others for finding information (like a website's URL) than using Google.
  6. His computer is a mess. The desktop is full of icons and files are totally unorganised so he (and everybody else) cannot find them when it is needed.
  7. When a serious problem occurs in his pc, it means data-loss as he does not know the very simple word "BACKUP".
  8. He leaves on time even if he is a click away from completing a serious task.

Thursday, May 10, 2007

Create a drop-down menu for image selection using java

The following code uses JCombo class for creating a drop down menu that provides the user the ability to choose and see the selected image. Note that the images you want to inlcude in your app should be saved in the main directory of your program (if you use netbeans for example open the project folder and save the images there).

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class ComboBoxTest extends JFrame {
private JComboBox images;
private JLabel label;
private String names[] =
{ "cutlass_32.png", "pet-monkey_32.png",
"pirate-captain_32.png", "first-mate_32.png" };
private Icon icons[] =
{ new ImageIcon( names[ 0 ] ),
new ImageIcon( names[ 1 ] ),
new ImageIcon( names[ 2 ] ),
new ImageIcon( names[ 3 ] ) };

public ComboBoxTest()
super( "Psy2k-Photo Selection" );

Container c = getContentPane();
c.setLayout( new FlowLayout() );

images = new JComboBox( names );
images.setMaximumRowCount( 3 );

new ItemListener() {
public void itemStateChanged( ItemEvent e )
icons[ images.getSelectedIndex() ] );

c.add( images );

label = new JLabel( icons[ 0 ] );
c.add( label );

setSize( 350, 100 );

public static void main( String args[] )
ComboBoxTest app = new ComboBoxTest();

new WindowAdapter() {
public void windowClosing( WindowEvent e )
System.exit( 0 );
The icons I used in this app are from Iconbuffet's Amsterdam High Seas collection (pirate icon yeah). Iconbuffet is a free social community for trading small icons with others. If you would like to join the madness feel free. It is very addicting!