-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from rememberber/develop
Develop
- Loading branch information
Showing
16 changed files
with
452 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-Dswing.aatext=true | ||
-XX:+UseZGC | ||
-XX:+ZGenerational |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/com/luoboduner/moo/tool/ui/component/JPopupMenuMouseAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.luoboduner.moo.tool.ui.component; | ||
|
||
import cn.hutool.log.Log; | ||
import cn.hutool.log.LogFactory; | ||
import com.luoboduner.moo.tool.App; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.MouseAdapter; | ||
import java.awt.event.MouseEvent; | ||
|
||
public class JPopupMenuMouseAdapter extends MouseAdapter { | ||
|
||
private static final Log logger = LogFactory.get(); | ||
|
||
private JPopupMenu popupMenu; | ||
|
||
public JPopupMenuMouseAdapter(JPopupMenu popupMenu) { | ||
this.popupMenu = popupMenu; | ||
} | ||
|
||
@Override | ||
public void mouseReleased(MouseEvent e) { | ||
maybeShowPopup(e); | ||
} | ||
|
||
@Override | ||
public void mousePressed(MouseEvent e) { | ||
maybeShowPopup(e); | ||
} | ||
|
||
@Override | ||
public void mouseClicked(MouseEvent e) { | ||
switch (e.getButton()) { | ||
case MouseEvent.BUTTON1: { | ||
showMainFrame(); | ||
break; | ||
} | ||
case MouseEvent.BUTTON2: { | ||
logger.debug("托盘图标中键事件"); | ||
break; | ||
} | ||
case MouseEvent.BUTTON3: { | ||
logger.debug("托盘图标右键事件"); | ||
break; | ||
} | ||
default: { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
private void maybeShowPopup(MouseEvent e) { | ||
if (e.isPopupTrigger()) { | ||
Dimension size = popupMenu.getPreferredSize(); | ||
popupMenu.setLocation(e.getX() - size.width, e.getY() - size.height); | ||
popupMenu.setInvoker(popupMenu); | ||
popupMenu.setVisible(true); | ||
} | ||
} | ||
|
||
public static void showMainFrame() { | ||
App.mainFrame.setVisible(true); | ||
if (App.mainFrame.getExtendedState() == Frame.ICONIFIED) { | ||
App.mainFrame.setExtendedState(Frame.NORMAL); | ||
} else if (App.mainFrame.getExtendedState() == 7) { | ||
App.mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH); | ||
} | ||
App.mainFrame.requestFocus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.