-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientGUI.java
More file actions
49 lines (37 loc) · 1.55 KB
/
Copy pathClientGUI.java
File metadata and controls
49 lines (37 loc) · 1.55 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
import javax.swing.*;
import java.util.ArrayList;
public class ClientGUI {
private AuctionClient client; // Link to Client
// Main Containers
private JFrame frame; // JFrame - root container
private JTabbedPane tab; // Tabbed Pane - Switches between pages
private ArrayList<GUIPage> pages; // List of pages to add to tabbed pane
public ClientGUI(AuctionClient c) {
client = c;
// Initialise Swing Components
frame = new JFrame();
tab = new JTabbedPane();
pages = new ArrayList<>();
// Add desired GUI pages
pages.add(new AllListingsGUI(client));
pages.add(new MyListingsGUI(client));
pages.add(new BidsGUI(client));
pages.add(new SearchIdGUI(client));
// Adds pages to Tabbed Pane
pages.forEach((page) -> tab.addTab(page.getTitle(), page));
GroupLayout layout = new GroupLayout(frame.getContentPane());
frame.getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(tab)
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(tab, GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setTitle("Auction");
frame.pack();
frame.setVisible(true);
}
}