http://download.eclipse.org/windowbuilder/WB/integration/4.5/
'Java > Swing' 카테고리의 다른 글
JFrame 기본 (0) | 2014.12.08 |
---|---|
JTextField 를 상속받은 IPTextField Component 구현 (0) | 2014.12.03 |
http://download.eclipse.org/windowbuilder/WB/integration/4.5/
JFrame 기본 (0) | 2014.12.08 |
---|---|
JTextField 를 상속받은 IPTextField Component 구현 (0) | 2014.12.03 |
package org.test.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyJFrame extends JFrame{
public static void main(String[] args){
new MyJFrame();
}
public MyJFrame(){
super();
init();
}
public void init(){
setTitle("MyFrame");
addContent();
setSize(300,200);
//setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
close();
}
});
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) (screen.getWidth()/2 - getSize().getWidth()/2);
int y = (int) (screen.getHeight()/2 - getSize().getHeight()/2);
setLocation(x,y);
setVisible(true);
}
public void addContent(){
setLayout(new BorderLayout());
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Menu Bar");
menuBar.add(menu);
setJMenuBar(menuBar);
JPanel toolbar = new JPanel(new FlowLayout(FlowLayout.LEFT));
toolbar.add(new JLabel("Tool Bar"));
add(toolbar,BorderLayout.NORTH);
JPanel layout = new JPanel(new BorderLayout());
layout.add(new JLabel("Content"));
add(layout,BorderLayout.CENTER);
JPanel status = new JPanel(new FlowLayout(FlowLayout.RIGHT));
status.add(new JLabel("Status"));
add(status,BorderLayout.SOUTH);
}
public void close(){
dispose();
}
}
WindowBuilder (0) | 2016.12.16 |
---|---|
JTextField 를 상속받은 IPTextField Component 구현 (0) | 2014.12.03 |
public class IPTextField extends JTextField{
//0.0.0.0 ~ 255.255.255.255
int min = 7;
public IpTextField(String t){
super(15);
setText(t);
initListeners();
}
public void initListeners(){
addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {}
public void keyReleased(KeyEvent e) {
int column = getColumns();
int length = getText().length();
if(length>column){
setText(getText().substring(0,column));
JOptionPane.showMessageDialog(IPTextField.this, "IP Format Error :"+column);
return;
}
}
public void keyPressed(KeyEvent e) {}
});
addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
int length = getText().length();
if(min> length) {
JOptionPane.showMessageDialog(IPTextField.this, "Column Minimum Size:"+min);
return;
}
try{
InetAddress.getAllByName(getText());
}catch(Exception e1){
JOptionPane.showMessageDialog(IPTextField.this, e1);
return;
}
}
public void focusGained(FocusEvent e) {}
});
}
}
WindowBuilder (0) | 2016.12.16 |
---|---|
JFrame 기본 (0) | 2014.12.08 |