Commit 6a1d776e authored by 9831111's avatar 9831111 🙂

Add initGamesPanel method.

parent bd19c451
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileReader;
import java.util.Scanner;
public class OnlineModeFrame extends JFrame {
private JComboBox serverBox;
......@@ -18,6 +21,7 @@ public class OnlineModeFrame extends JFrame {
setVisible(true);
}
public void initServerList() {
serverChoosePanel = new JPanel();
serverChoosePanel.setLayout(new FlowLayout());
......@@ -38,4 +42,24 @@ public class OnlineModeFrame extends JFrame {
}
public void initGamesPanel() {
gamesPanel = new JPanel();
gamesPanel.setLayout(new GridLayout(4, 2, 3, 3));
File accounts = new File("Games.txt");
try (Scanner scanner = new Scanner(new FileReader(accounts))) {
while (scanner.hasNextLine()) {
String account = "";
account += scanner.nextLine() + " ";
String[] inputs = account.split(" ");
showGames(gamesPanel, inputs[0], inputs[1], inputs[2], inputs[3], inputs[4], inputs[5], inputs[6], inputs[7]);
}
} catch (Exception ex) {
ex.printStackTrace();
}
add(gamesPanel, BorderLayout.CENTER);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment