nicer code

This commit is contained in:
potzplitz 2024-03-04 11:43:50 +01:00
parent 4a69b801e3
commit a153db2c4c

View file

@ -97,8 +97,6 @@ public class MainGUI {
level.setBounds(10, 10, 200, 30); level.setBounds(10, 10, 200, 30);
level.setFont(level.getFont().deriveFont(15f)); level.setFont(level.getFont().deriveFont(15f));
filtercompleted.setBounds(720, 15, 200, 30); filtercompleted.setBounds(720, 15, 200, 30);
progress.setBounds(200, 300, 500, 30); progress.setBounds(200, 300, 500, 30);
@ -146,10 +144,8 @@ public class MainGUI {
show.setBounds(500, 1, 200, 60); show.setBounds(500, 1, 200, 60);
recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -165,8 +161,6 @@ public class MainGUI {
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
contents.setLayout(null); contents.setLayout(null);
JButton completed = new JButton("x"); JButton completed = new JButton("x");
completed.setBounds(640, 17, 17, 17); completed.setBounds(640, 17, 17, 17);
completed.setMargin(new Insets(0,0,0,0)); completed.setMargin(new Insets(0,0,0,0));
@ -175,18 +169,12 @@ public class MainGUI {
uncompleted.setBounds(640, 17, 17, 17); uncompleted.setBounds(640, 17, 17, 17);
uncompleted.setMargin(new Insets(0,0,0,0)); uncompleted.setMargin(new Insets(0,0,0,0));
File file = new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json"); File file = new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json");
completed.addActionListener(new ActionListener() { completed.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
contents.setBackground(Color.decode("#cbffbf")); contents.setBackground(Color.decode("#cbffbf"));
completed.setVisible(false); completed.setVisible(false);
uncompleted.setVisible(true); uncompleted.setVisible(true);
@ -196,22 +184,17 @@ public class MainGUI {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
});
});
uncompleted.addActionListener(new ActionListener() { uncompleted.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
contents.setBackground(Color.WHITE); contents.setBackground(Color.WHITE);
uncompleted.setVisible(false); uncompleted.setVisible(false);
completed.setVisible(true); completed.setVisible(true);
file.delete(); file.delete();
} }
}); });
if(new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json").exists()) { if(new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json").exists()) {
@ -223,7 +206,6 @@ public class MainGUI {
contents.addMouseListener(new MouseListener() { contents.addMouseListener(new MouseListener() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
showinfos.addActionListener(new ActionListener() { showinfos.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -233,10 +215,6 @@ public class MainGUI {
} }
}); });
level.setText(data.getLocalLevels().get(index)); level.setText(data.getLocalLevels().get(index));
verifier.setText("Verifier: " + data.getVerifier().get(index)); verifier.setText("Verifier: " + data.getVerifier().get(index));
creator.setText("Creator: " + data.getCreator().get(index)); creator.setText("Creator: " + data.getCreator().get(index));
@ -246,7 +224,6 @@ public class MainGUI {
FetchData fetchData = new FetchData(); FetchData fetchData = new FetchData();
try { try {
recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1)); recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1));
} catch (IOException e1) { } catch (IOException e1) {
@ -286,23 +263,16 @@ public class MainGUI {
recordspanel.revalidate(); recordspanel.revalidate();
copyid.addActionListener(new ActionListener() { copyid.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
StringSelection stringSelection = new StringSelection(data.getId().get(index)); StringSelection stringSelection = new StringSelection(data.getId().get(index));
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null); clipboard.setContents(stringSelection, null);
} }
}); });
} }
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
@ -325,7 +295,6 @@ public class MainGUI {
rank.setName(i + ""); rank.setName(i + "");
show.addActionListener(new ActionListener() { show.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
levelpanel.add(contents, 0); levelpanel.add(contents, 0);
@ -368,8 +337,6 @@ public class MainGUI {
}); });
levelname = new JLabel(); levelname = new JLabel();
levelname.setText(data.getLocalLevels().get(i)); levelname.setText(data.getLocalLevels().get(i));
levelname.setBounds(290, 10, 300, 30); levelname.setBounds(290, 10, 300, 30);
@ -419,8 +386,6 @@ public class MainGUI {
} }
}); });
contents.add(levelname); contents.add(levelname);
contents.add(rank); contents.add(rank);
contents.add(completed); contents.add(completed);
@ -429,8 +394,6 @@ public class MainGUI {
} }
scroll.setVisible(true); scroll.setVisible(true);
elements.infopanel().setVisible(true); elements.infopanel().setVisible(true);
progress.setVisible(false); progress.setVisible(false);
@ -453,10 +416,8 @@ public class MainGUI {
elements.infopanel().add(idshow); elements.infopanel().add(idshow);
elements.infopanel().add(qualify); elements.infopanel().add(qualify);
elements.infopanel().add(victor); elements.infopanel().add(victor);
// elements.infopanel().add(ytthumbnail);
elements.infopanel().add(showinfos); elements.infopanel().add(showinfos);
main.add(search); main.add(search);
main.add(currentLevel); main.add(currentLevel);
main.add(info); main.add(info);
@ -467,5 +428,4 @@ public class MainGUI {
main.add(elements.infopanel()); main.add(elements.infopanel());
main.setVisible(true); main.setVisible(true);
} }
} }