-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer_myTacticsMe_setpiece.java
More file actions
142 lines (120 loc) · 4.13 KB
/
player_myTacticsMe_setpiece.java
File metadata and controls
142 lines (120 loc) · 4.13 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package DB2025Team09;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class player_myTacticsMe_setpiece extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTable table;
private int idTeam, idPlayer;
/**
* Launch the application.
*/
//테스트용 메인함수입니다.
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
player_myTacticsMe_setpiece frame = new player_myTacticsMe_setpiece(1,1);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
//데이터베이스속 데이터 로드
private void loadsetpieceData() {
//3-2 내가 동원된 전술 목록 조회 - 세트 피스 전술
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0); // 기존 테이블 초기화
String sql =
"SELECT DISTINCT " +
" S.idTactic AS setpieceTacticId, " +
" S.tacticName AS tacticName, " +
" S.tacticFormation AS tacticFormation " +
"FROM " +
" DB2025_Squad Q " +
"JOIN " +
" DB2025_Player P ON Q.idPlayer = P.idPlayer " +
"JOIN " +
" DB2025_view_GameSummary G ON Q.idGame = G.idGame " +
"JOIN " +
" DB2025_Tactics S ON G.idSetpiece = S.idTactic " +
"WHERE " +
" P.idPlayer = ? " +
" AND S.tacticType = 'Setpiece' " +
" AND S.idTeam = P.idTeam";
try (Connection conn = DBUtil.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setInt(1, idPlayer); // 바인딩
try (ResultSet rs = pstmt.executeQuery()) {
while (rs.next()) {
int tacticId = rs.getInt("setpieceTacticId");
String tacticName = rs.getString("tacticName");
String formation = rs.getString("tacticFormation");
model.addRow(new Object[]{tacticId, tacticName, formation});
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* Create the frame.
*/
public player_myTacticsMe_setpiece(int idTeam, int idPlayer) {
//선수 메뉴
//3. 전술 정보 조회
// 3-2 내가 동원된 전술 목록 조회 - 세트피스 전술
this.idTeam = idTeam;
this.idPlayer = idPlayer;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//뒤로 가기 버튼
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new player_myTacticsMe(idTeam, idPlayer).setVisible(true); dispose();
}
});
btnNewButton.setBounds(6, 6, 117, 29);
contentPane.add(btnNewButton);
JLabel lblNewLabel = new JLabel("세트피스 전술");
lblNewLabel.setFont(new Font("Lucida Grande", Font.BOLD, 18));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setBounds(6, 32, 438, 29);
contentPane.add(lblNewLabel);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(6, 73, 438, 193);
contentPane.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"\uC138\uD2B8\uD53C\uC2A4 \uC804\uC220 ID", "\uC804\uC220 \uC774\uB984", "\uD3EC\uBA54\uC774\uC158"
}
));
scrollPane.setViewportView(table);
loadsetpieceData();
}
}