MXcode » java http://mxcode.com All about coding Wed, 23 Jun 2010 09:30:25 +0000 http://wordpress.org/?v=2.7.1 en hourly 1 Flex draw http://mxcode.com/2010/06/flex-draw/ http://mxcode.com/2010/06/flex-draw/#comments Fri, 04 Jun 2010 09:39:27 +0000 MXcode http://mxcode.com/2010/06/flex-draw/

]]>
http://mxcode.com/2010/06/flex-draw/feed/
create a swing application http://mxcode.com/2009/09/create-a-swing-application/ http://mxcode.com/2009/09/create-a-swing-application/#comments Fri, 11 Sep 2009 07:34:26 +0000 MXcode http://mxcode.com/2009/09/create-a-swing-application/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
 
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
 
public class Test3 extends JApplet {
 
	public void init() {
		Container contentPane = getContentPane();
 
		Icon icon = new ImageIcon(ClassLoader.getSystemResource("swing.gif")); 
		JLabel label = new JLabel(icon);
//		java.net.URL codebase = getClass().getResource("../swing.gif");
//		JLabel label = new JLabel(new ImageIcon(codebase));
 
		contentPane.setLayout(new FlowLayout());
		contentPane.add(label);
	}
 
	public static void main(String args[]) {
		final JFrame f = new JFrame();
		JApplet applet = new Test3();
 
		applet.init();
 
		f.setContentPane(applet.getContentPane());
		f.setBounds(100, 100, 308, 199);
		f.setTitle("An Application");
		f.setVisible(true);
 
		f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
 
		f.addWindowListener(new WindowAdapter() {
			public void windowClosed(WindowEvent e) {
				System.exit(0);
			}
		});
	}
}
]]>
http://mxcode.com/2009/09/create-a-swing-application/feed/
how to read a url http://mxcode.com/2009/09/how-to-read-a-url/ http://mxcode.com/2009/09/how-to-read-a-url/#comments Tue, 01 Sep 2009 05:15:45 +0000 MXcode http://mxcode.com/2009/09/hwo-to-read-a-url/
String s = request.getRequestURL().toString();
URL url = new URL(s);
BufferedReader bf = new BufferedReader(new InputStreamReader(url.openStream()));
]]>
http://mxcode.com/2009/09/how-to-read-a-url/feed/
how to build .properties http://mxcode.com/2009/07/how-to-build-properties/ http://mxcode.com/2009/07/how-to-build-properties/#comments Thu, 02 Jul 2009 04:16:06 +0000 MXcode http://mxcode.com/?p=1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if (null == transactionCodeConfig) {
	transactionCodeConfig = new Properties();
	transactionCodeConfig.load(Obj2XMLBuilderXSD.class
			.getResourceAsStream("/config/transactionCodeConfig.properties"));
	xsdMap = new HashMap();
	for (Iterator iterator = transactionCodeConfig.entrySet().iterator(); iterator.hasNext();) {
		Entry entry = (Entry) iterator.next();
		BufferedReader br = new BufferedReader(new InputStreamReader(
				Obj2XMLBuilderXSD.class.getResourceAsStream("/config/xsd/" + entry.getValue())));
		String aLine;
		StringBuffer xsdContent = new StringBuffer("");
		aLine = br.readLine();
		while (null != aLine) {
			xsdContent.append(aLine);
			aLine = br.readLine();
		}
		br.close();
		xsdMap.put(entry.getKey(), xsdContent.toString());
	}
}
]]>
http://mxcode.com/2009/07/how-to-build-properties/feed/