gui
This commit is contained in:
parent
fd45e1a263
commit
050c0233ad
5 changed files with 112 additions and 22 deletions
|
@ -8,7 +8,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class FetchData {
|
public class FetchData {
|
||||||
|
|
||||||
private ArrayList<String> levels = new ArrayList<String>();
|
private static ArrayList<String> levels = new ArrayList<String>();
|
||||||
|
|
||||||
public void getGithubString() throws IOException {
|
public void getGithubString() throws IOException {
|
||||||
String link = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/_list.json";
|
String link = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/_list.json";
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class GuiData {
|
||||||
|
|
||||||
public void IndexLevelName() throws IOException {
|
public void IndexLevelName() throws IOException {
|
||||||
|
|
||||||
|
FetchData data = new FetchData();
|
||||||
|
|
||||||
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
||||||
File[] filelengthindex = filelength.listFiles();
|
File[] filelengthindex = filelength.listFiles();
|
||||||
|
@ -37,7 +38,7 @@ public class GuiData {
|
||||||
System.out.println(filelengthindex.length);
|
System.out.println(filelengthindex.length);
|
||||||
|
|
||||||
for(int i = 0; i < filelengthindex.length; i++) {
|
for(int i = 0; i < filelengthindex.length; i++) {
|
||||||
jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + filelengthindex[i].getName()), StandardCharsets.UTF_8);
|
jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8);
|
||||||
jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
|
jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(jsonstring);
|
JSONObject obj = new JSONObject(jsonstring);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import gui.MainGUI;
|
import gui.MainGUI;
|
||||||
|
|
||||||
import gui.MissingLevels;
|
import gui.MissingLevels;
|
||||||
|
|
||||||
public class ManageFiles {
|
public class ManageFiles {
|
||||||
|
@ -14,7 +15,6 @@ public class ManageFiles {
|
||||||
private static ArrayList<String> missinglevels = new ArrayList<String>(); // fehlende noch zu herunterladende level
|
private static ArrayList<String> missinglevels = new ArrayList<String>(); // fehlende noch zu herunterladende level
|
||||||
private int missing = 0;
|
private int missing = 0;
|
||||||
|
|
||||||
|
|
||||||
public static ArrayList<String> getMissinglevels() {
|
public static ArrayList<String> getMissinglevels() {
|
||||||
return missinglevels;
|
return missinglevels;
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,6 @@ public class ManageFiles {
|
||||||
missinglevels.add(levelname);
|
missinglevels.add(levelname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void compareArrays() throws IOException { // downloadedlevels und onlinelevels werden verglichen und die fehlenden level in missinglevels gepackt
|
public void compareArrays() throws IOException { // downloadedlevels und onlinelevels werden verglichen und die fehlenden level in missinglevels gepackt
|
||||||
|
|
||||||
fetch.getGithubString();
|
fetch.getGithubString();
|
||||||
|
@ -47,11 +44,9 @@ public class ManageFiles {
|
||||||
MainGUI gui = new MainGUI();
|
MainGUI gui = new MainGUI();
|
||||||
gui.build();
|
gui.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> missingLevels() { // missinglevels wird zurückgegeben
|
public ArrayList<String> missingLevels() { // missinglevels wird zurückgegeben
|
||||||
return missinglevels;
|
return missinglevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@ package gui;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
@ -11,46 +15,53 @@ import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import data.GuiData;
|
import data.GuiData;
|
||||||
|
|
||||||
public class MainGUI {
|
public class MainGUI {
|
||||||
|
|
||||||
public JFrame main = new JFrame();
|
public JFrame main = new JFrame("Extreme Demon List");
|
||||||
|
public JProgressBar progress = new JProgressBar();
|
||||||
|
public JLabel info = new JLabel("Die Liste wird geladen");
|
||||||
|
public JLabel currentLevel = new JLabel();
|
||||||
|
public JPanel levelpanel = new JPanel();
|
||||||
|
public JScrollPane scroll = new JScrollPane(levelpanel);
|
||||||
|
public JTextField search = new JTextField();
|
||||||
|
public JLabel levelname;
|
||||||
|
|
||||||
|
|
||||||
public void build() throws IOException {
|
public void build() throws IOException {
|
||||||
|
|
||||||
GuiData data = new GuiData();
|
GuiData data = new GuiData();
|
||||||
data.IndexLevelName();
|
data.IndexLevelName();
|
||||||
|
|
||||||
|
|
||||||
main.setSize(900, 700);
|
main.setSize(900, 700);
|
||||||
main.setLayout(null);
|
main.setLayout(null);
|
||||||
main.setResizable(false);
|
main.setResizable(false);
|
||||||
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
JProgressBar progress = new JProgressBar();
|
|
||||||
progress.setBounds(200, 300, 500, 30);
|
progress.setBounds(200, 300, 500, 30);
|
||||||
progress.setStringPainted(true);
|
progress.setStringPainted(true);
|
||||||
progress.setMaximum(data.getLocalLength());
|
progress.setMaximum(data.getLocalLength());
|
||||||
|
|
||||||
JLabel info = new JLabel("Die Liste wird geladen");
|
|
||||||
info.setBounds(380, 270, 300, 30);
|
info.setBounds(380, 270, 300, 30);
|
||||||
|
|
||||||
JLabel currentLevel = new JLabel();
|
|
||||||
currentLevel.setBounds(200, 330, 200, 30);
|
currentLevel.setBounds(200, 330, 200, 30);
|
||||||
|
|
||||||
JPanel levelpanel = new JPanel();
|
|
||||||
levelpanel.setBackground(Color.LIGHT_GRAY);
|
levelpanel.setBackground(Color.LIGHT_GRAY);
|
||||||
levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
levelpanel.setLayout(new GridLayout(data.getLocalLevels().size(), 1));
|
levelpanel.setLayout(new GridLayout(data.getLocalLevels().size(), 1));
|
||||||
|
|
||||||
JScrollPane scroll = new JScrollPane(levelpanel);
|
|
||||||
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||||
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
scroll.setBounds(0, 61, 700, 600);
|
scroll.setBounds(0, 61, 700, 600);
|
||||||
|
scroll.getVerticalScrollBar().setUnitIncrement(16);
|
||||||
scroll.setVisible(false);
|
scroll.setVisible(false);
|
||||||
|
|
||||||
|
search.setBounds(1, 1, 700, 60);
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -59,13 +70,75 @@ public class MainGUI {
|
||||||
|
|
||||||
currentLevel.setText(data.getLocalLevels().get(i));
|
currentLevel.setText(data.getLocalLevels().get(i));
|
||||||
|
|
||||||
JPanel contents = new JPanel();
|
|
||||||
contents.setPreferredSize(new Dimension(600, 50));
|
|
||||||
contents.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
|
||||||
|
|
||||||
JLabel levelname = new JLabel(data.getLocalLevels().get(i));
|
|
||||||
|
JPanel contents = new JPanel();
|
||||||
|
contents.setName(data.getLocalLevels().get(i));
|
||||||
|
contents.setPreferredSize(new Dimension(600, 50));
|
||||||
|
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
||||||
|
contents.setLayout(null);
|
||||||
|
|
||||||
|
contents.addMouseListener(new MouseListener() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
contents.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
levelname = new JLabel();
|
||||||
|
levelname.setText(data.getLocalLevels().get(i));
|
||||||
|
levelname.setBounds(10, 10, 300, 30);
|
||||||
|
|
||||||
|
search.addKeyListener(new KeyListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
if(!contents.getName().toLowerCase().contains(search.getText().toLowerCase())) {
|
||||||
|
levelpanel.remove(contents);
|
||||||
|
levelpanel.repaint();
|
||||||
|
levelpanel.revalidate();
|
||||||
|
} else if(contents.getName().toLowerCase().contains(search.getText().toLowerCase())) {
|
||||||
|
levelpanel.add(contents);
|
||||||
|
levelpanel.repaint();
|
||||||
|
levelpanel.revalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JLabel rank = new JLabel("#" + (i + 1));
|
||||||
|
rank.setBounds(640, 10, 40, 30);
|
||||||
|
|
||||||
contents.add(levelname);
|
contents.add(levelname);
|
||||||
|
contents.add(rank);
|
||||||
levelpanel.add(contents);
|
levelpanel.add(contents);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,6 +151,9 @@ public class MainGUI {
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
main.add(search);
|
||||||
main.add(currentLevel);
|
main.add(currentLevel);
|
||||||
main.add(info);
|
main.add(info);
|
||||||
main.add(scroll);
|
main.add(scroll);
|
||||||
|
|
18
src/gui/SearchEngine.java
Normal file
18
src/gui/SearchEngine.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package gui;
|
||||||
|
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
public class SearchEngine {
|
||||||
|
|
||||||
|
MainGUI gui = new MainGUI();
|
||||||
|
|
||||||
|
JTextField searchbar = gui.search;
|
||||||
|
|
||||||
|
public void Filter(String query) {
|
||||||
|
System.out.println(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue