###前提・実現したいこと
javaとSwingを使ってLauncherを作っています。
開発環境はeclipse。OSはwindows 10です。
イメージとしては、
Magic Formationというlauncher(アイコンの配置が丸を描いているもの)を基盤とし、マウスのホイールを転がすとその円になっているアイコンが回り、一番手前に来ているもののみ選択できるというものです。
形は楕円にし、立体感を出したいと思っています。
※イメージはMagic Formationではありません。
###発生している問題・エラーメッセージ
円の真ん中にもう一つボタンを用意し、それをドラッグすることでこのlauncherをデスクトップのどこにでも移動させたいのですがやり方がわかりません。
アイコンを回転させることができません。
エラーメッセージ
###該当のソースコード
import java.awt.;
import java.awt.event.;
import javax.swing.*;
public class Swingidou {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
createAndShowGUI();
}
});
}
public static void createAndShowGUI() {
DragWindowListener dwl = new DragWindowListener();
JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.addMouseListener(dwl);
frame.addMouseMotionListener(dwl);
frame.setSize(320, 240);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
class DragWindowListener extends MouseAdapter {
private final Point startPt = new Point();
private Window window;
@Override public void mousePressed(MouseEvent me) {
if (window == null) {
Object o = me.getSource();
if (o instanceof Window) {
window = (Window) o;
} else if (o instanceof JComponent) {
window = SwingUtilities.windowForComponent(me.getComponent());
}
}
startPt.setLocation(me.getPoint());
}
@Override public void mouseDragged(MouseEvent me) {
if (window != null) {
Point eventLocationOnScreen = me.getLocationOnScreen();
window.setLocation(eventLocationOnScreen.x - startPt.x,
eventLocationOnScreen.y - startPt.y);
}
}
}
移動についてです。これは完全にネットに転がっていたものです。
これを利用して、launcherの移動ができませんか・・・?
###試したこと
###補足情報(言語/FW/ツール等のバージョンなど)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。