Java로 둥근 모서리 윈도우 만들기

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.RoundRectangle2D;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;

public class ShapedWindow extends JFrame implements ComponentListener {
	private static final long serialVersionUID = 1L;

	private static RoundRectangle2D.Double shape;
	private static Window w;

	public ShapedWindow() {
		super("Test oval-shaped window");
		this.setLayout(new FlowLayout());
		this.add(new JButton("test"));
		this.add(new JCheckBox("test"));
		this.add(new JRadioButton("test"));
		this.add(new JProgressBar(0, 100));

		this.setSize(new Dimension(400, 300));
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		this.addComponentListener(this);
	}

	public static void main(String[] args) {
		JFrame.setDefaultLookAndFeelDecorated(true);
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				w = new ShapedWindow();
				w.setVisible(true);

				shape = new RoundRectangle2D.Double(0, 0, w.getWidth(), w.getHeight(), 20, 20);

				com.sun.awt.AWTUtilities.setWindowShape(w, shape);
			}
		});
	}

	@Override
	public void componentResized(ComponentEvent e) {
		shape.width = w.getWidth();
		shape.height = w.getHeight();
		com.sun.awt.AWTUtilities.setWindowShape(w, shape);
	}

	@Override
	public void componentHidden(ComponentEvent e) {
	}

	@Override
	public void componentMoved(ComponentEvent e) {
	}

	@Override
	public void componentShown(ComponentEvent e) {
	}
}
사용자 삽입 이미지

Posted by 밤치

2009/05/18 14:54 2009/05/18 14:54
,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/127

XPath 삽질기

XPath로 Node를 찾아내려는데 div[ ] 라는 표현법을 사용할 수 있다.
Obejct[ ] 로 리턴해주기 때문에 [ ] 안의 숫자는 당연히 0 부터 시작할 줄 알았는데 1 부터 시작이더라..

결국 삽질 많이~ 했다는 이야기다.

Object[] obj = node.evaluateXPath("//body/div[3]/div[4]/div/div[11]/div/ul/li");

Posted by 밤치

2009/03/26 15:49 2009/03/26 15:49
, ,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/120

TabbedPane Round처리 - BCRoundTabPanel

탭을 기준으로 둥근 모서리로 테두리를 그려주는 BCRoundTabPanel

사용자 삽입 이미지
사용자 삽입 이미지

BCRoundTabPanel 이 상단 이미지보다 작아질경우 아래와 같이 깨질수 있으니 주의!

사용자 삽입 이미지


import java.awt.Color;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class BCRoundTabPanel extends JPanel {
	private static final long serialVersionUID = 1L;

	int y;
	int r;
	int hr;
	int iconWidth;
	int iconHeight;
	Color c;

	ImageIcon topImg;

	public BCRoundTabPanel(ImageIcon imgIcon, int r) {
		this.topImg = imgIcon;
		this.r = r;
		hr = r / 2;
		y = topImg.getIconHeight();
		iconWidth = topImg.getIconWidth();
		iconHeight = topImg.getIconHeight();
	}

	@Override
	public void paint(Graphics g) {
		super.paintComponents(g);

		g.setColor(c);
		g.drawArc(0, getHeight() - r - 1, r, r, 180, 90);
		g.drawArc(getWidth() - r - 1, getHeight() - r - 1, r, r, 270, 90);
		g.drawArc(getWidth() - r - 1, iconHeight, r, r, 0, 90);
		g.drawLine(iconWidth, iconHeight, getWidth() - hr, iconHeight);
		g.drawLine(0, 0, 0, getHeight() - hr);
		g.drawLine(getWidth() - 1, iconHeight + hr, getWidth() - 1, getHeight() - hr - 1);
		g.drawLine(hr, getHeight() - 1, getWidth() - hr, getHeight() - 1);

		g.drawImage(topImg.getImage(), 0, 0, iconWidth, iconHeight, null);
	}

	public Color getC() {
		return c;
	}

	public void setC(Color c) {
		this.c = c;
	}
}

Posted by 밤치

2009/03/24 21:56 2009/03/24 21:56
, ,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/118

[ IPView ]


나는 항상 집에 있는 PC를 켜 놓고 서버, 데이터저장소, 인터넷뱅킹용으로 사용하고 있다.

그러나 아이피가 자주 바뀌기 때문에 매일매일 아이피를 확인하고 외출을 해야하는 단점이 있어서 아이피뷰 프로그램을 만들게 되었다.

아이피뷰를 실행해 놓으면 주기적으로 Real IP를 얻어와 DB에 업데이트를 해준다.
업데이트된 IP는 언제든지 웹을 통해 확인이 가능하기 때문에 편리하다.

아이피뷰는 Java로 개발되었으므로 Java Runtime Environment 1.5 이상이 필요하다.

http://ip.3vs2.com 에 접속하여 아이디를 만들고 아이피뷰를 실행하면 된다.


[ Screenshot ]


사용자 삽입 이미지

사용자 삽입 이미지

사용자 삽입 이미지

Posted by 밤치

2009/03/23 10:53 2009/03/23 10:53
, ,
Response
No Trackback , 2 Comments
RSS :
http://bamchi.com/blog/rss/response/117