C
ChristianR1
Gast
Hallo,
ich habe die JAVA Datei Fenster gleichbewegen aus Code-Schnipsel mir gerausgebickt, und verändert, sodass das Fenster 1 (Audioplayer) mit Fenster 2 ( z.B. Playlist) gleich verschoben wird, so dass jedoch die Playlist unterhalb des Audioplayers bleibt.
Die Y Verschiebung klappt einwandfrei. Sobald man aber in X Richtung das ganze verschiebt, funzt nixmehr !!!
Vielleicht kann mir jemand helfen!
/*
* GleichBewegen_Test.java
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GleichBewegen_Test extends JFrame {
public GleichBewegen_Test() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(400, 300);
setLocation(200, 200);
setVisible(true);
dialog = new JDialog(this, false);
dialog.setSize(200, 200);
dialog.setLocation(200, 200);
dialog.setVisible(true);
new GleichBewegen(this, dialog);
}
public static void main(String args[]) {
new GleichBewegen_Test();
}
private JDialog dialog;
}
class GleichBewegen extends ComponentAdapter {
public GleichBewegen(Window winA, Window winB) {
this.winA = winA;
this.winB = winB;
winA.addComponentListener(this);
winB.addComponentListener(this);
}
public void componentMoved(ComponentEvent e) {
Window win = (Window) e.getComponent();
int mainx, mainy;
double x;
double y;
int startwinAkoordx;
int startwinAkoordy;
Point winBlocX = null;
Point winBlocY = null;
winBlocX = winA.getLocation();
x = winBlocX.getX();
int xint = new Double(x).intValue();
winBlocY = winA.getLocation();
y = winBlocY.getY();
int yint = new Double(x).intValue();
startwinAkoordx = xint;
startwinAkoordy = yint;
winA.removeComponentListener(this);
x = winBlocX.getX();
System.out.println(x);
y = winBlocY.getY();
System.out.println(y);
int xx = new Double(x).intValue();
int yy = new Double(y).intValue();
winB.setLocation(xx + startwinAkoordx, yy + startwinAkoordy);
winA.addComponentListener(this);
}
private Window winA, winB;
private int startkoordWinAX, startkoordWinAY;
}
ich habe die JAVA Datei Fenster gleichbewegen aus Code-Schnipsel mir gerausgebickt, und verändert, sodass das Fenster 1 (Audioplayer) mit Fenster 2 ( z.B. Playlist) gleich verschoben wird, so dass jedoch die Playlist unterhalb des Audioplayers bleibt.
Die Y Verschiebung klappt einwandfrei. Sobald man aber in X Richtung das ganze verschiebt, funzt nixmehr !!!
Vielleicht kann mir jemand helfen!
/*
* GleichBewegen_Test.java
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GleichBewegen_Test extends JFrame {
public GleichBewegen_Test() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(400, 300);
setLocation(200, 200);
setVisible(true);
dialog = new JDialog(this, false);
dialog.setSize(200, 200);
dialog.setLocation(200, 200);
dialog.setVisible(true);
new GleichBewegen(this, dialog);
}
public static void main(String args[]) {
new GleichBewegen_Test();
}
private JDialog dialog;
}
class GleichBewegen extends ComponentAdapter {
public GleichBewegen(Window winA, Window winB) {
this.winA = winA;
this.winB = winB;
winA.addComponentListener(this);
winB.addComponentListener(this);
}
public void componentMoved(ComponentEvent e) {
Window win = (Window) e.getComponent();
int mainx, mainy;
double x;
double y;
int startwinAkoordx;
int startwinAkoordy;
Point winBlocX = null;
Point winBlocY = null;
winBlocX = winA.getLocation();
x = winBlocX.getX();
int xint = new Double(x).intValue();
winBlocY = winA.getLocation();
y = winBlocY.getY();
int yint = new Double(x).intValue();
startwinAkoordx = xint;
startwinAkoordy = yint;
winA.removeComponentListener(this);
x = winBlocX.getX();
System.out.println(x);
y = winBlocY.getY();
System.out.println(y);
int xx = new Double(x).intValue();
int yy = new Double(y).intValue();
winB.setLocation(xx + startwinAkoordx, yy + startwinAkoordy);
winA.addComponentListener(this);
}
private Window winA, winB;
private int startkoordWinAX, startkoordWinAY;
}