2009年9月24日 星期四

set font for UI

ex:

Font font = label.getFont();
label.setFont(font.deriveFont(12f) );
label.setFont(font.deriveFont(font.getStyle() ^ Font.BOLD) );

UI alignment

TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT,

LEFT_ALIGNMENT, RIGHT_ALIGNMENT

ex:

testLabel.setAlignmentX(Component.CENTER_ALIGNMENT);


eclise problem in snow leopard when running java 1.6

error:
"java.lang.NoClassDefFoundError: apple/laf/CoreUIControl"

solution:
add /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaRuntimeSupport.framework/Versions/A/Resources/Java/JavaRuntimeSupport.jar
to classpath of run configuration

enable root user in mac

open "Directory Utility"
click on Edit, click on "Enable root user"

2009年9月23日 星期三

java jtree

1. simple jtree example

public class SimpleTree extends JFrame {
public static void main(String[] args) {
new SimpleTree();
}

public SimpleTree() {
super("Creating a Simple JTree");

DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child 1");
root.add(child1);
DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child 2");
root.add(child2);
JTree tree = new JTree(root);
getContentPane().add(new JScrollPane(tree));
setSize(275, 300);
setVisible(true);
}
}

show directory size

du -h -d 1
-d means directory depth

install mac os from dmg file

need 2 partitions, one for installer, one will be where you install os
1. open disk utility
2. click restore tab
3. drag dmg file in source field
4. drag the partition for installer in destination field
5. click erase destination
6. click restore
7. open system preference --> startup disk --> installer partiton
8. restart to install os