27 tháng 11 2006

Learn Photoshop 01

This task we’ll learn to create a logotype for Music Records Company.

First create a new file 550x400 px and 72 dpi.
Draw a circle now, using the instrument . The parameters should be the same from the picture.

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Now make small circles inside the previous one with the same parameters form the picture.

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

In the Layers Window set Fill 0%. Use the function Free Transform to minimize the circles. The last circle has the same adjustments like in the picture.

Create Professional Logo for Music Records Company in Photoshop CS

The instrument will help us to create figures like the next ones.

Create Professional Logo for Music Records Company in Photoshop CS

Parameters…

Create Professional Logo for Music Records Company in Photoshop CS

Use the same instrument to create a flame. The parameters are also indicated in the pictures.

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Create Professional Logo for Music Records Company in Photoshop CS

Copy and turn it around horizontally, using Free Transform.

Create Professional Logo for Music Records Company in Photoshop CS

Add the text in the end with the instrument . The font should be Verdana.

Create Professional Logo for Music Records Company in Photoshop CS

The final result.

21 tháng 11 2006

Swing: How to show JPopupMenu on Empty JTable ?

Swing: How to show JPopupMenu on Empty JTable ?

At 7:03 PM on Sep 15, 2005, Santhosh Kumar T DeveloperZone Top 100 wrote:

It looks like as simple as writing a MouseListener implementation and register with JTable where the MouseListener implementation shows JPopupMenu.

But this doesn't works if there are no rows in JTable. Why so? The height of the JTable is zero when there are no rows, Thus the area where user clicks is not JTable, it is JViewPort.

This can be solved by overriding the method getScrollableTracksViewportHeight () of Scrollable interface. JTable already implements Scrollable interface. So we just override that method and make the table height same as that of view-port if its preferred size is smaller than view-port size

JTable table = new JTable(0, 5){
public boolean getScrollableTracksViewportHeight() {
return getPreferredSize().height < getParent().getHeight();
}
};
This is how JTextComponent handles this. You can checkout JTextComponent.java and see getScrollableTracksViewportHeight() implementation.

Any JComponent can be scrollable by adding to JScrollable. Then what is Scrollable interface is for ? Scrollable interface which gives some hints to perform better scrolling, such as how many pixels to move per mouse-click or page up or page down.



The demo contains two tables. and both tables have the same MouseListener registered. But only the bottom table shows JPopupMenu on right mouse click. The bottom table overrides getScrollableTracksViewportHeight() as explained above.

Select scroll new item

tbList.getSelectionModel().setSelectionInterval(
tbList.getRowCount()-1, tbList.getRowCount()-1
);

tbList.scrollCellToVisible(tbList.getRowCount() - 1,tbList.getRowCount() - 1);

TableModel Standard

class MyModel extends AbstractTableModel{

private String[] _columns = new String[]{"Id", "Name"};
private Class[] _classnames = new Class[]{Integer.class,String.class};
private Vector _data ;

public MyModel( Vector data ){
_data = data;
}

public int getRowCount() {
return _data.size();
}

public int getColumnCount() {
return _columns.length;
}

public Object getValueAt(int rowIndex, int columnIndex) {
MyObject obj = _data.get( rowIndex );
switch ( columnIndex ){
case 0:
return obj.getId();
case 1:
return obj.getName();
}
return null;
}

public String getColumnName(int col)
{
return _columns[col];
}

public Class getColumnClass(int col)
{
return _classnames[ col ];
}

public void addNewItem( MyObject obj ){
_data.add( obj );
this.fireTableRowsInserted( this.getRowCount(), this.getRowCount() );
this.fireTableDataChanged();
}
}

class MyObject{
private int _id;
private String _name;

public void setId( int id ){
_id = id;
}

public void setName ( String name ){
_name = name;
}

public int getId(){
return _id;
}

public String getName(){
return _name;
}
}

Goat and Fox

Fox was brought up by goat's milk