private static void Panel() {
String[] why = Code.read(new File("main"+sep+"config", "main.page"));
Code.pl(why);
//JFrame frame = Swingbuild.newJFrameMax("Main");
//setHash("white", Swingbuild.newJPanel(Color.WHITE));
JFrame frame = Swingbuild.newJFrame("Main", 1000,600);
setHash("frame", frame);
JButton closeAll = closebutton(frame,"Select",null);
JSplitPane jsp = Swingbuild.newJSplitPane("Firstpanel","VT",50);
jsp.setEnabled(false);//Divider bewegen?
JPanel Maintop = Swingbuild.newJPanel(Color.WHITE);
JPanel Mainbottom = Swingbuild.newJPanel(maincolor);
JComboBox<String> choice = new JComboBox<String>();
String[] file = Code.read(new File("main"+sep+"config","main.page"));
for(int i=13;i<file.length;) {
choice.addItem(file[i]);
Code.pl(file[i]);
file[i] = file[i].substring(0, file[i].length()-1);
Code.pl(file[i]);
fach(file[i], Color.WHITE);
i++;
}
/*
choice.addItem("Mathe");
fach("Mathe",mathecolor);
choice.addItem("Bio");
fach("Bio",biocolor);
choice.addItem("Latein");
fach("Latein", lateincolor);
choice.addItem("Englisch");
fach("Englisch", englishcolor);//*/
JButton choicebutton = Swingbuild.newJButton("Weiter");
Mainbottom.add(choice);
Mainbottom.add(choicebutton);
choicebutton.addMouseListener(new MouseAdapter () {
@Override public void mouseClicked( MouseEvent e) {
String what = choice.getItemAt(choice.getSelectedIndex());
log.log2("READ", what);
jtp.addTab(what, getHash(what));
}
});
JButton reloadbutton = Swingbuild.newJButton("Reload");
reloadbutton.addMouseListener(new MouseAdapter () {
@Override public void mouseClicked( MouseEvent e) {
jtp.removeAll();
jtp.addTab("Main",getHash("jsp"));
log.log2("Info","Reload JTP");
}});
Maintop.add(reloadbutton);
Mainbottom.add(Swingbuild.newJLabel("<html><h1>Wähle das Fach</h1><p></p><h3>Funktionierend: - Mathe </h3></html>"));
addlr(Maintop, Mainbottom, jsp);
frame.add(jtp);
setHash("jsp", jsp);
jtp.addTab("Main", jsp);
log.log2("Info","Created JFrame, added jtp(with Main).");
closeAll.setForeground( Color.BLACK);
frame.setVisible(true);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
log.log2("Info","Try to close");
if (JOptionPane.showConfirmDialog(frame,
"Sicher, das du das Fenster schließen willst?", "Applikation beenden?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){
log.log2("MAIN","System.exit caller 0");
System.exit(0);}//*/
//log.log2("Main", "EXIT");
//System.exit(0);
}
});
}
private static JPanel newpanel(String name, Color color) {
JPanel ret = Swingbuild.newJPanel(name, color);
ret.add(close(ret));
return ret;}
private static void fach(String which, Color color) {
log.log2("MAIN","Try to open following: "+which);
Code.pl("Opentry");
System.out.println(new File("main"+sep+"Data"+sep+which,"1.page").toString());
if(!new File("main"+sep+"Data"+sep+which,"1.page").exists()) {
log.err2("The file don't exist. Open an inexistent file and you get an copy of the first page.");
return;
}
JPanel top = Swingbuild.newJPanel(which,Color.WHITE);
JPanel down = Swingbuild.newJPanel(which, color);
JSplitPane returnsplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
returnsplit.setContinuousLayout(false);
returnsplit.setDividerLocation(40);
top.add(close(returnsplit));
addlr(top, down, returnsplit);
String[] read = Code.read(new File("main"+sep+"Data"+sep+which,"1.page"));
Code.pl(read);
String[] box = new String[read.length-5];
for(int i=5; i<read.length;) {
box[i-5] = read[i];
i++;
}
JComboBox<String> mathebox = combobox(box);
down.add(mathebox);
JButton open = Swingbuild.newJButton("Open");
open.addMouseListener(new MouseAdapter () {
@Override
public void mouseClicked( MouseEvent e) {
String boxstring = mathebox.getSelectedItem().toString();
Code.pr(boxstring);
boxstring = boxstring.substring(0, boxstring.length()-1);
Code.pr(boxstring.length());
JPanel add = new JPanel();
String ps = Code.readone(new File("main"+sep+"Data"+sep+which,boxstring+".page"));
if(ps.contains("--Comment--")) {
}
else {
JLabel label = new JLabel();
label.setText(ps);
add.add(label);
}
jtp.addTab(mathebox.getSelectedItem().toString(), add);
}
});
down.add(open);
setHash(which, returnsplit);
}
public static JButton close(Component comp) {
JButton ret = new JButton();
ret.setText("Close Page");
ret.addMouseListener(new MouseAdapter () {
@Override
public void mouseClicked( MouseEvent e) {
jtp.remove(comp);
log.log2("PAGE","Closed "+comp);
}
});
return ret;
}
private static JButton closebutton(JFrame frame,String panelname, Component panel) {
JButton exit = help.newJButton("EXIT", Color.WHITE, 45,27);
exit.setText("RELOAD");
exit.addMouseListener(new MouseAdapter () {
@Override public void mouseClicked( MouseEvent e) {
jtp.removeAll();
jtp.addTab(panelname, panel);
log.log2("Info","Reload JTP");
}});
return exit;
}