Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
public class MyWindowListener2 implements WindowListener
{
private JFrame jframe;
public int[][] fensterpos = {
// Format {<xpos>,<ypos>,<belegt=1/nichtbelegt=0>}
// 1. Reihe
{ 200, 284, 0 }, { 250, 334, 0 },
{ 300, 384, 0 }, { 350, 434, 0 },
{ 400, 484, 0 }, { 450, 534, 0 },
// 2. Reihe
{ 350, 284, 0 }, { 400, 334, 0 },
{ 450, 384, 0 }, { 500, 434, 0 },
{ 550, 484, 0 }, { 600, 534, 0 },
// 3. Reihe
{ 500, 284, 0 }, { 550, 334, 0 },
{ 600, 384, 0 }, { 650, 434, 0 },
{ 700, 484, 0 }, { 750, 534, 0 },
};
public void windowClosing(WindowEvent e) {
jframe.setVisible(false);
}
...
public MyWindowListener2 (JFrame frame)
{
this.jframe = frame;
}
public class window_sec01beta extends FilesEinlesen {
JFrame frame_01b = new JFrame("01-beta");
MyWindowListener2 mywl2 = new MyWindowListener2(frame_01b);
public int arraypoint;
Panel panel = new Panel();
public window_sec01beta() throws IOException {
String[] array = this.e_s01b();
JButton[] buttons = new JButton[20];
frame_01b.setSize(140,500);
for (int i = 0; i < 18; i++) {
if ( mywl2.fensterpos[i][2] == 0) {
frame_01b.setLocation(mywl2.fensterpos[i][0],mywl2.fensterpos[i][1]);
mywl2.fensterpos[i][2] = 1;
this.arraypoint = i;
break;
}
}
Ergo soll ich am besten das Positionenarray in eine andere, eigene Klasse setzen?
public class FensterPositions {
public int[][] fensterpos = {
// Format {<xpos>,<ypos>,<belegt=1/nichtbelegt=0>}
// 1. Reihe
{ 200, 284, 0 }, { 250, 334, 0 },
{ 300, 384, 0 }, { 350, 434, 0 },
{ 400, 484, 0 }, { 450, 534, 0 },
// 2. Reihe
{ 350, 284, 0 }, { 400, 334, 0 },
{ 450, 384, 0 }, { 500, 434, 0 },
{ 550, 484, 0 }, { 600, 534, 0 },
// 3. Reihe
{ 500, 284, 0 }, { 550, 334, 0 },
{ 600, 384, 0 }, { 650, 434, 0 },
{ 700, 484, 0 }, { 750, 534, 0 },
};
}
public class window_sec01beta extends FensterPositions {
JFrame frame_01b = new JFrame("01-beta");
FilesEinlesen fe = new FilesEinlesen();
MyWindowListener2 mywl2 = new MyWindowListener2(frame_01b);
public int arraypoint;
Panel panel = new Panel();
public window_sec01beta() throws IOException {
String[] array = fe.e_s01b();
JButton[] buttons = new JButton[20];
frame_01b.setSize(140,500);
for (int i = 0; i < 18; i++) {
if ( this.fensterpos[i][2] == 0) {
frame_01b.setLocation(this.fensterpos[i][0],this.fensterpos[i][1]);
this.fensterpos[i][2] = 1;
this.arraypoint = i;
break;
}
}
public class mainClass {
public static void main(String[] Arguments) {
ArrayClass arrayClass = new ArrayClass();
ExampleClass ex1 = new ExampleClass();
ExampleClass ex2 = new ExampleClass();
String[] tempArray = arrayClass.getArray();
ex1.ausgabe(tempArray);
ex2.ausgabe(tempArray);
}
}
public class ExampleClass {
public void ausgabe(String[] array) {
for(int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}
public class ArrayClass {
public String[] array = new String[] {"test1","test2","test3"};
public String[] getArray() {
return(this.array);
}
}
FRAGE: Was ist ein Getter? Was ein static-Getter?
public class FensterPositions {
public static int[][] fensterpos = {
// Format {<xpos>,<ypos>,<belegt=1/nichtbelegt=0>}
// 1. Reihe
{ 200, 284, 0 }, { 250, 334, 0 },
{ 300, 384, 0 }, { 350, 434, 0 },
{ 400, 484, 0 }, { 450, 534, 0 },
// 2. Reihe
{ 350, 284, 0 }, { 400, 334, 0 },
{ 450, 384, 0 }, { 500, 434, 0 },
{ 550, 484, 0 }, { 600, 534, 0 },
// 3. Reihe
{ 500, 284, 0 }, { 550, 334, 0 },
{ 600, 384, 0 }, { 650, 434, 0 },
{ 700, 484, 0 }, { 750, 534, 0 },
};
public static int[] getFreePosi() {
int[] position = new int[2];
for (int i = 0; i < 18; i++) {
if (fensterpos[i][2] == 0) {
position[0] = fensterpos[i][0];
position[1] = fensterpos[i][1];
fensterpos[i][2] = 1;
break;
}
}
return position;
}
public void status() {
for (int k=0; k<5; k++) {
System.out.println("Feld "+(k+1)+": "+fensterpos[k][2]);
}
}
}