Java JFrame calcLocation(JFrame main, JDialog dialog)

Here you can find the source of calcLocation(JFrame main, JDialog dialog)

Description

calc Location

License

LGPL

Declaration

public static Point calcLocation(JFrame main, JDialog dialog) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import javax.swing.*;
import java.awt.*;

public class Main {
    private static final int SCREEN_WIDTH = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();

    public static Point calcLocation(JFrame main, JDialog dialog) {
        int mainWidth = main.getWidth();
        int mainX = main.getX();
        int dialogWidth = dialog.getWidth();
        int x;//w ww . ja va2 s. c om
        if ((mainX + mainWidth + dialogWidth) > SCREEN_WIDTH) {
            x = mainX - dialogWidth - 50;
        } else {
            x = mainX + mainWidth + 50;
        }
        return new Point(x, 50);
    }
}

Related

  1. attachAccelerator(Action action, JFrame frame)
  2. btnMnemonicAndToolTip(JFrame frame, JButton a, JButton b, JButton c, JButton e, JButton h, JButton i, JButton l, JButton m, JButton o, JButton p, JButton s, JButton t, JButton enter, JButton altEnter)
  3. buildButton(String btnName, JFrame frame, int x, int y, int w, int h)
  4. buildLabel(JFrame frame, String txt, int x, int y, int w, int h)
  5. buildTxtField(JFrame frame, int x, int y, int w, int h)
  6. calculateMaxMenuItems(JFrame window)
  7. calculateMaxMenuItems(JFrame window)
  8. centre(JFrame frame)
  9. centreJustifyFrame(final JFrame frame, final int y_position)