My single test SWT vs Swing
December 21st, 2008code goes like this
[swt]
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
public class HelloWorld {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
int hunter = 0;
int house = 0;
for (int counter = 0; counter <= 400; counter++) {
Button b = new Button(shell, SWT.CENTER);
b.setText(counter+”");
b.setBounds(house, hunter, 40, 40);
hunter += 40;
if (hunter >= 600) {
hunter = 0;
house += 40;
}
}
// label.setText(”Hello, World”);
// label.setBounds(shell.getClientArea());
shell.open();
shell.setText(”what is this”);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
[swing]
import javax.swing.JButton;
import javax.swing.JFrame;
public class Swing {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setLayout(null);
int hunter = 0;
int house = 0;
for (int counter = 0; counter <= 400; counter++) {
JButton b = new JButton();
b.setText(counter + “”);
b.setBounds(house, hunter, 50, 50);
frame.add(b);
hunter += 50;
if (hunter >= 600) {
hunter = 0;
house += 50;
}
}
}
}
Viewing memory taken in windows vista with jdk1.6 update 10
SWT takes about 10,160 KB
Swing takes about 16,429 KB
So i am planning to go with SWT and leave spring finally now
Thanks