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 {
|
||||
|
||||
private ArrayList<String> levels = new ArrayList<String>();
|
||||
private static ArrayList<String> levels = new ArrayList<String>();
|
||||
|
||||
public void getGithubString() throws IOException {
|
||||
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 {
|
||||
|
||||
FetchData data = new FetchData();
|
||||
|
||||
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
||||
File[] filelengthindex = filelength.listFiles();
|
||||
|
@ -37,7 +38,7 @@ public class GuiData {
|
|||
System.out.println(filelengthindex.length);
|
||||
|
||||
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("\\", "");
|
||||
|
||||
JSONObject obj = new JSONObject(jsonstring);
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import gui.MainGUI;
|
||||
|
||||
import gui.MissingLevels;
|
||||
|
||||
public class ManageFiles {
|
||||
|
@ -14,7 +15,6 @@ public class ManageFiles {
|
|||
private static ArrayList<String> missinglevels = new ArrayList<String>(); // fehlende noch zu herunterladende level
|
||||
private int missing = 0;
|
||||
|
||||
|
||||
public static ArrayList<String> getMissinglevels() {
|
||||
return missinglevels;
|
||||
}
|
||||
|
@ -23,9 +23,6 @@ public class ManageFiles {
|
|||
missinglevels.add(levelname);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void compareArrays() throws IOException { // downloadedlevels und onlinelevels werden verglichen und die fehlenden level in missinglevels gepackt
|
||||
|
||||
fetch.getGithubString();
|
||||
|
@ -46,12 +43,10 @@ public class ManageFiles {
|
|||
} else {
|
||||
MainGUI gui = new MainGUI();
|
||||
gui.build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> missingLevels() { // missinglevels wird zurückgegeben
|
||||
return missinglevels;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@ package gui;
|
|||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
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 javax.swing.BorderFactory;
|
||||
|
@ -11,45 +15,52 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import data.GuiData;
|
||||
|
||||
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 {
|
||||
|
||||
GuiData data = new GuiData();
|
||||
data.IndexLevelName();
|
||||
|
||||
|
||||
|
||||
main.setSize(900, 700);
|
||||
main.setLayout(null);
|
||||
main.setResizable(false);
|
||||
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JProgressBar progress = new JProgressBar();
|
||||
|
||||
progress.setBounds(200, 300, 500, 30);
|
||||
progress.setStringPainted(true);
|
||||
progress.setMaximum(data.getLocalLength());
|
||||
|
||||
JLabel info = new JLabel("Die Liste wird geladen");
|
||||
|
||||
info.setBounds(380, 270, 300, 30);
|
||||
|
||||
JLabel currentLevel = new JLabel();
|
||||
|
||||
currentLevel.setBounds(200, 330, 200, 30);
|
||||
|
||||
JPanel levelpanel = new JPanel();
|
||||
levelpanel.setBackground(Color.LIGHT_GRAY);
|
||||
levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
levelpanel.setLayout(new GridLayout(data.getLocalLevels().size(), 1));
|
||||
|
||||
JScrollPane scroll = new JScrollPane(levelpanel);
|
||||
|
||||
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scroll.setBounds(0, 61, 700, 600);
|
||||
scroll.getVerticalScrollBar().setUnitIncrement(16);
|
||||
scroll.setVisible(false);
|
||||
|
||||
search.setBounds(1, 1, 700, 60);
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -59,13 +70,75 @@ public class MainGUI {
|
|||
|
||||
currentLevel.setText(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.BLACK));
|
||||
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() {
|
||||
|
||||
JLabel levelname = new JLabel(data.getLocalLevels().get(i));
|
||||
@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(rank);
|
||||
levelpanel.add(contents);
|
||||
|
||||
}
|
||||
|
@ -78,6 +151,9 @@ public class MainGUI {
|
|||
});
|
||||
thread.start();
|
||||
|
||||
|
||||
|
||||
main.add(search);
|
||||
main.add(currentLevel);
|
||||
main.add(info);
|
||||
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