레이아웃 생성자로 만들기
2019. 5. 31. 16:31
Programing/Java
package kr.ac.jj.report;
import java.awt.GridLayout;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class MyConst {
public static final String DRIVER = "org.gjt.mm.mysql.Driver"; //= "oracle.jdbc.driver.OracleDriver";
public static final String URL = "jdbc:mysql://localhost:3306/test"; //= "jdbc:oracle:thin:@192.168.0.3:1521:ORCL";
public static final String USER = "test"; // DB ID
public static final String PASS = "test123"; // DB 占쎈솭占쎈뮞占쎌뜖占쎈굡
public static JLabel makeLabel(String cap, int x, int y, int width, int height) {
JLabel lbl = new JLabel(cap);
lbl.setBounds(x, y, width, height);
return lbl;
}
public static JTextField makeTextField(int size, int x, int y, int width, int height) {
JTextField txt = new JTextField(size);
txt.setBounds(x, y, width, height);
return txt;
}
public static JTextArea makeTextArea(int cols, int rows, int x, int y, int width, int height) {
JTextArea txt = new JTextArea(cols, rows);
txt.setBounds(x, y, width, height);
return txt;
}
public static JPanel makeRadioButton(String[] cap, int x, int y, int width, int height) {
JRadioButton[] rdo = new JRadioButton[cap.length];
ButtonGroup bg = new ButtonGroup();
JPanel panel = new JPanel(new GridLayout(1, cap.length));
panel.setBounds(x, y, width, height);
for (int i = 0; i < cap.length; i++) {
rdo[i] = new JRadioButton(cap[i], true);
bg.add(rdo[i]);
panel.add(rdo[i]);
}
return panel;
}
public static JComboBox<String> makeComboBox(String[] cap, int x, int y, int width, int height) {
JComboBox<String> cmb = new JComboBox<String>(cap);
cmb.setBounds(x, y, width, height);
return cmb;
}
public static JList<String> makeList(String[] cap, int x, int y, int width, int height) {
JList<String> lst = new JList<String>(cap);
lst.setBounds(x, y, width, height);
return lst;
}
}
'Programing > Java' 카테고리의 다른 글
ReportF, ReportH 파일 (0) | 2019.06.08 |
---|---|
채팅 프로그램 (0) | 2019.05.31 |
S007_Sungjuk _허용할 범위_public, private, protect 개념 (0) | 2019.05.14 |
S007_Sungjuk_UnivStudent 대학성적 계산예제 (0) | 2019.05.14 |
S007_Sungjuk 성적계산 및 입출력 (0) | 2019.05.14 |