Proper window screen centering

Graph dialog proper window size
Graph dialog scroll speed increased
This commit is contained in:
Jindra Petřík
2021-01-23 15:27:28 +01:00
parent 8f856fefe4
commit 4e6b59e2ac
3 changed files with 21 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
@@ -120,6 +122,7 @@ public class GraphDialog extends AppDialog {
setTitle(translate("graph") + " " + name);
JScrollPane scrollPane = new JScrollPane(gp);
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
cnt.add(scrollPane, BorderLayout.CENTER);
@@ -191,7 +194,9 @@ public class GraphDialog extends AppDialog {
public void setVisible(boolean b) {
super.setVisible(b);
Dimension screen = getToolkit().getScreenSize();
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
Dimension screen = new Dimension(screenBounds.width - insets.left - insets.right, screenBounds.height - insets.top - insets.bottom);
Dimension dim = new Dimension(0, 0);
Dimension panDim = gp.getPreferredSize();
// add some magic constants
@@ -203,13 +208,13 @@ public class GraphDialog extends AppDialog {
if (panDim.width + frameWidthDiff < screen.width) {
dim.width = panDim.width;
} else {
dim.width = screen.width;
dim.width = screen.width - frameWidthDiff;
tooWide = true;
}
if (panDim.height + frameHeightDiff < screen.height) {
dim.height = panDim.height;
} else {
dim.height = screen.height;
dim.height = screen.height - frameHeightDiff;
tooHigh = true;
}