use of java.awt.Toolkit in project yyl_example by Relucent.
the class TankGame method initBounds.
private void initBounds(JFrame frame) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
int fw = Constant.Canvas_WIDTH + 8;
int fh = Constant.Canvas_HEIGHT + 34;
int fx = (screenSize.width - fw) / 2;
int fy = (screenSize.height - fh) / 2;
frame.setBounds(fx, fy, fw, fh);
}
use of java.awt.Toolkit in project yyl_example by Relucent.
the class TakePictures method initBounds.
private void initBounds(JFrame frame) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
int fw = 800;
int fh = 600;
int fx = (screenSize.width - fw) / 2;
int fy = (screenSize.height - fh) / 2;
frame.setBounds(fx, fy, fw, fh);
}
use of java.awt.Toolkit in project jadx by skylot.
the class MainWindow method registerMouseNavigationButtons.
private void registerMouseNavigationButtons() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
toolkit.addAWTEventListener(event -> {
if (event instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent) event;
if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
int rawButton = mouseEvent.getButton();
if (rawButton <= 3) {
return;
}
int button = remapMouseButton(rawButton);
switch(button) {
case 4:
tabbedPane.navBack();
break;
case 5:
tabbedPane.navForward();
break;
}
}
}
}, AWTEvent.MOUSE_EVENT_MASK);
}
use of java.awt.Toolkit in project binnavi by google.
the class GuiHelper method centerChildToParent.
/**
* Centers the child component relative to it's parent component
*
* @param parent
* @param child
* @param bStayOnScreen
*/
public static final void centerChildToParent(final Component parent, final Component child, final boolean bStayOnScreen) {
int x = (parent.getX() + (parent.getWidth() / 2)) - (child.getWidth() / 2);
int y = (parent.getY() + (parent.getHeight() / 2)) - (child.getHeight() / 2);
if (bStayOnScreen) {
final Toolkit tk = Toolkit.getDefaultToolkit();
final Dimension ss = new Dimension(tk.getScreenSize());
if ((x + child.getWidth()) > ss.getWidth()) {
x = (int) (ss.getWidth() - child.getWidth());
}
if ((y + child.getHeight()) > ss.getHeight()) {
y = (int) (ss.getHeight() - child.getHeight());
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
child.setLocation(x, y);
}
use of java.awt.Toolkit in project binnavi by google.
the class GuiHelper method centerChildToParent.
/**
* Centers the child component relative to its parent component.
*/
public static final void centerChildToParent(final Component parent, final Component child, final boolean bStayOnScreen) {
int x = (parent.getX() + (parent.getWidth() / 2)) - (child.getWidth() / 2);
int y = (parent.getY() + (parent.getHeight() / 2)) - (child.getHeight() / 2);
if (bStayOnScreen) {
final Toolkit tk = Toolkit.getDefaultToolkit();
final Dimension ss = new Dimension(tk.getScreenSize());
if ((x + child.getWidth()) > ss.getWidth()) {
x = (int) (ss.getWidth() - child.getWidth());
}
if ((y + child.getHeight()) > ss.getHeight()) {
y = (int) (ss.getHeight() - child.getHeight());
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
child.setLocation(x, y);
}
Aggregations