public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
Exemplo n.º 2
0
  // init
  private static void init() {
    if (frame != null) frame.setVisible(false);

    frame = new JFrame();
    offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    onscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    offscreen = offscreenImage.createGraphics();
    onscreen = onscreenImage.createGraphics();
    setXscale();
    setYscale();
    offscreen.setColor(DEFAULT_CLEAR_COLOR);
    offscreen.fillRect(0, 0, width, height);
    setPenColor();
    setPenRadius();
    setFont();
    clear();

    // add anti-aliasing
    RenderingHints hints =
        new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    offscreen.addRenderingHints(hints);

    // frame stuff
    ImageIcon icon = new ImageIcon(onscreenImage);
    JLabel draw = new JLabel(icon);

    draw.addMouseListener(std);
    draw.addMouseMotionListener(std);

    frame.setContentPane(draw);
    frame.addKeyListener(std); // JLabel cannot get keyboard focus
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // closes all windows
    // frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // closes only current window
    frame.setTitle("Standard Draw");
    frame.setJMenuBar(createMenuBar());
    frame.pack();
    frame.requestFocusInWindow();
    frame.setVisible(true);
  }
Exemplo n.º 3
0
  public Senso() {
    super("Senso");
    this.setSize(640, 480);
    this.setLocation(100, 100);
    this.getContentPane().setBackground(Color.black);
    this.setUndecorated(true);
    this.setBackground(Color.white);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setResizable(false);
    this.setLayout(null);
    this.setAlwaysOnTop(true);

    klicks = new JLabel();
    klicks.setSize(150, 25);
    klicks.setLocation(20, 300);
    klicks.setFont(new Font("Impact", 5, 25));
    klicks.setForeground(Color.lightGray);
    this.add(klicks);

    start = new JLabel();
    start.setSize(350, 50);
    start.setLocation(350, 200);
    start.setFont(new Font("Impact", 5, 50));
    start.setForeground(Color.lightGray);
    this.add(start);

    lblVerloren = new JLabel();
    lblVerloren.setSize(350, 30);
    lblVerloren.setLocation(200, 215);
    lblVerloren.setFont(new Font("Impact", 5, 30));
    lblVerloren.setForeground(Color.lightGray);
    this.add(lblVerloren);

    neustart = new JLabel("Neustart");
    neustart.setSize(100, 30);
    neustart.setLocation(20, 200);
    neustart.setFont(new Font("Impact", 5, 25));
    neustart.setForeground(Color.darkGray);
    neustart.addMouseListener(this);
    this.add(neustart);

    beenden = new JLabel("Beenden");
    beenden.setSize(100, 30);
    beenden.setLocation(20, 390);
    beenden.setFont(new Font("Impact", 5, 25));
    beenden.setForeground(Color.gray);
    beenden.addMouseListener(this);
    this.add(beenden);

    us = new JLabel("Senso");
    us.setSize(150, 35);
    us.setLocation(10, 30);
    us.setFont(new Font("Impact", 1, 35));
    us.setForeground(Color.white);
    this.add(us);

    punkte = new JLabel("Score: " + String.valueOf(points));
    punkte.setSize(200, 20);
    punkte.setLocation(400, 400);
    punkte.setFont(new Font("Impact", 0, 20));
    punkte.setForeground(Color.white);
    this.add(punkte);

    rot = new JLabel(new ImageIcon("files/Minigames/Senso/red_0.png"));
    rot.setSize(216, 207);
    rot.setLocation(150, 25);
    rot.setBackground(Color.darkGray);
    rot.addMouseListener(this);
    this.add(rot);

    gruen = new JLabel(new ImageIcon("files/Minigames/Senso/green_0.png"));
    gruen.setSize(216, 207);
    gruen.setLocation(366, 25);
    gruen.setBackground(Color.darkGray);
    gruen.addMouseListener(this);
    this.add(gruen);

    gelb = new JLabel(new ImageIcon("files/Minigames/Senso/yellow_0.png"));
    gelb.setSize(216, 207);
    gelb.setLocation(366, 232);
    gelb.setBackground(Color.darkGray);
    gelb.addMouseListener(this);
    this.add(gelb);

    blau = new JLabel(new ImageIcon("files/Minigames/Senso/blue_0.png"));
    blau.setSize(216, 207);
    blau.setLocation(150, 232);
    blau.setBackground(Color.darkGray);
    blau.addMouseListener(this);
    this.add(blau);

    this.addMouseListener(this);

    // spiel = new Thread(this);
    zufall = new Random();

    läuft = false;

    zahl = zufall.nextInt(4);
    // this.setVisible(true);
    soundR = new File("files/Minigames/Senso/rot.wav");
    soundG = new File("files/Minigames/Senso/gruen.wav");
    soundB = new File("files/Minigames/Senso/blau.wav");
    soundY = new File("files/Minigames/Senso/gelb.wav");
    soundF = new File("files/Minigames/Senso/falsch.wav");
  }
Exemplo n.º 4
0
  void createFrame() {
    /* see Preferences.java */
    int GUI_BIG = 13;
    int GUI_BETWEEN = 10;
    int GUI_SMALL = 6;
    int FIELD_SIZE = 30;

    int left = GUI_BIG;
    int top = GUI_BIG;
    int right = 0;

    Dimension d;

    frame = new JFrame("Directives Editor");
    Container pane = frame.getContentPane();
    pane.setLayout(null);

    JLabel label = new JLabel("Click here to read about directives.");
    label.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            Base.openURL("http://processingjs.org/reference/pjs%20directive");
          }

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}
        });
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN + GUI_BETWEEN;

    // CRISP

    crispBox = new JCheckBox("\"crisp\": disable antialiasing for line(), triangle() and rect()");
    pane.add(crispBox);
    d = crispBox.getPreferredSize();
    crispBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // FONTS

    label = new JLabel("\"font\": to load (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    fontField = new JTextField(FIELD_SIZE);
    pane.add(fontField);
    d = fontField.getPreferredSize();
    fontField.setBounds(left, top, d.width, d.height);

    JButton button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanFonts();
          }
        });
    pane.add(button);
    Dimension d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // GLOBAL_KEY_EVENTS

    globalKeyEventsBox = new JCheckBox("\"globalKeyEvents\": receive global key events");
    pane.add(globalKeyEventsBox);
    d = globalKeyEventsBox.getPreferredSize();
    globalKeyEventsBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PAUSE_ON_BLUR

    pauseOnBlurBox = new JCheckBox("\"pauseOnBlur\": pause if applet loses focus");
    pane.add(pauseOnBlurBox);
    d = pauseOnBlurBox.getPreferredSize();
    pauseOnBlurBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PRELOAD images

    label = new JLabel("\"preload\": images (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    preloadField = new JTextField(FIELD_SIZE);
    pane.add(preloadField);
    d = preloadField.getPreferredSize();
    preloadField.setBounds(left, top, d.width, d.height);

    button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanImages();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // TRANSPARENT

    /*transparentBox =
         new JCheckBox("\"transparent\": set applet background to be transparent");
       pane.add(transparentBox);
    d = transparentBox.getPreferredSize();
       transparentBox.setBounds(left, top, d.width + 10, d.height);
       right = Math.max(right, left + d.width);
       top += d.height + GUI_BETWEEN;*/

    // APPLY / OK

    button = new JButton("OK");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyDirectives();
            hide();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    int BUTTON_HEIGHT = d2.height;
    int BUTTON_WIDTH = 80;

    int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
    h += BUTTON_WIDTH + GUI_SMALL;

    button = new JButton("Cancel");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hide();
          }
        });
    pane.add(button);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);

    top += BUTTON_HEIGHT + GUI_BETWEEN;

    // frame.getContentPane().add(box);
    frame.pack();
    Insets insets = frame.getInsets();
    frame.setSize(
        right + GUI_BIG + insets.left + insets.right, top + GUI_SMALL + insets.top + insets.bottom);

    // frame.setResizable(false);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            frame.setVisible(false);
          }
        });
    Toolkit.registerWindowCloseKeys(
        frame.getRootPane(),
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            frame.setVisible(false);
          }
        });
    Toolkit.setIcon(frame);
  }
  /** Initializes this panel. */
  private void init() {
    JPanel mainPanel = new TransparentPanel(new BorderLayout());

    mainPanel.setBorder(
        BorderFactory.createTitledBorder(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE")));

    JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1));

    JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1));

    JLabel usernameLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.USERNAME"));

    JLabel displayNameLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME"));

    JLabel passLabel =
        new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD"));

    JLabel retypePasswordLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD"));

    JLabel emailLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.EMAIL"));

    labelsPanel.add(displayNameLabel);
    labelsPanel.add(usernameLabel);
    labelsPanel.add(passLabel);
    labelsPanel.add(retypePasswordLabel);
    labelsPanel.add(emailLabel);

    valuesPanel.add(displayNameField);
    valuesPanel.add(usernameField);
    valuesPanel.add(passField);
    valuesPanel.add(retypePassField);
    valuesPanel.add(emailField);

    JLabel emailDescriptionLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"),
            SwingConstants.CENTER);
    emailDescriptionLabel.setForeground(Color.GRAY);
    emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
    emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10));

    initErrorArea();

    mainPanel.add(labelsPanel, BorderLayout.WEST);
    mainPanel.add(valuesPanel, BorderLayout.CENTER);
    mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH);

    this.add(mainPanel, BorderLayout.CENTER);

    JLabel infoLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"),
            SwingConstants.RIGHT);
    infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    infoLabel.setForeground(Color.GRAY);
    infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
    infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    infoLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info");
          }
        });

    this.add(infoLabel, BorderLayout.SOUTH);
  }
Exemplo n.º 6
0
  /** *********** Initialization of every component and variable being used ************* */
  IPToolKit() {

    cp = new Container();
    cp.setLayout(new BorderLayout());
    Main_pnl = new JPanel();
    jmb = new JMenuBar();
    m_File = new JMenu("File");
    m_Arith = new JMenu("Arithmetic");
    m_Filter = new JMenu("Filters");
    m_Open = new JMenuItem("Open");
    m_Save = new JMenuItem("Save");
    m_Exit = new JMenuItem("Exit");
    m_Add = new JMenu("Add");
    m_Sub = new JMenu("Subtract");
    m_Mul = new JMenu("Multiply");
    m_Div = new JMenu("Divide");
    edge = new JMenu("Edge Detection");
    mpre = new JMenu("Prewits");
    msob = new JMenu("Sobel");
    lbl_img = new JLabel("");
    lbl_gray = new JLabel("");
    lbl_res = new JLabel("");
    jfc = new JFileChooser();
    panel_image = new JPanel();
    panel_gray = new JPanel();
    panel_result = new JPanel();
    scrollPane = new JScrollPane();
    mAddConst = new JMenu("Constant");
    mSubConst = new JMenu("Constant");
    mMulConst = new JMenu("Constant");
    mDivConst = new JMenu("Constant");
    mAddSat = new JMenuItem("Saturation");
    mAddWrap = new JMenuItem("Wrap Around");
    mSubSat = new JMenuItem("Saturation");
    mSubWrap = new JMenuItem("Wrap Around");
    mMulSat = new JMenuItem("Saturation");
    mMulWrap = new JMenuItem("Wrap Around");
    mDivSat = new JMenuItem("Saturation");
    mDivWrap = new JMenuItem("Wrap Around");
    mAddImg = new JMenuItem("Image");
    mSubImg = new JMenuItem("Image");
    mMulImg = new JMenuItem("Image");
    mDivImg = new JMenuItem("Image");
    mlowPass = new JMenuItem("Low Pass");
    mhighPass = new JMenuItem("High Pass");
    mhighBoost = new JMenuItem("High Boost");
    median = new JMenuItem("Median");
    mBright = new JMenuItem("Brightness");
    mContrast = new JMenuItem("Contrast Stretch");
    mThreshold = new JMenuItem(" Threshold ");
    m_Enhance = new JMenu("Enhancement");
    mInvert = new JMenuItem("Negative");
    mpre_hor = new JMenuItem("Prewits Horizontal");
    mpre_ver = new JMenuItem("Prewits Vertical");
    mpre_both = new JMenuItem("Prewits Both");
    msob_hor = new JMenuItem("Sobel Horizontal");
    msob_ver = new JMenuItem("Sobel Vertical");
    msob_both = new JMenuItem("Sobel Both");
    ;
    mrob = new JMenuItem("Roberts");
    mean = new JMenuItem("Mean");
    mlap = new JMenuItem("Laplacian");
    other = new JMenu("Other");
    hist = new JMenuItem("Histogram Equalization");
    conect = new JMenuItem("Connected Component");
    mBlend = new JMenuItem("Blending");
    vsb = new JScrollBar(JScrollBar.VERTICAL);
    hsb = new JScrollBar(JScrollBar.HORIZONTAL);
    //	jsp = new JScrollPane();

    setJMenuBar(jmb);
    add(cp);

    //	setBackground(new Color(255,255,255));

    panel_image.setBackground(new Color(255, 0, 0));
    panel_gray.setBackground(new Color(0, 255, 0));
    panel_result.setBackground(new Color(0, 0, 255));

    jmb.add(m_File);
    jmb.add(m_Arith);
    jmb.add(m_Enhance);
    jmb.add(m_Filter);
    jmb.add(edge);
    jmb.add(other);

    cp.add(Main_pnl);

    Main_pnl.setLayout(new GridLayout(1, 3, 10, 10));

    Main_pnl.add(panel_image);
    Main_pnl.add(panel_gray);
    Main_pnl.add(panel_result);

    m_File.add(m_Open);
    m_File.add(m_Save);
    m_File.add(m_Exit);

    m_Arith.add(m_Add);
    m_Add.add(mAddImg);
    m_Add.add(mAddConst);
    mAddConst.add(mAddSat);
    mAddConst.add(mAddWrap);

    m_Arith.add(m_Sub);
    m_Sub.add(mSubImg);
    m_Sub.add(mSubConst);
    mSubConst.add(mSubSat);
    mSubConst.add(mSubWrap);

    m_Arith.add(m_Mul);
    m_Mul.add(mMulImg);
    m_Mul.add(mMulConst);
    mMulConst.add(mMulSat);
    mMulConst.add(mMulWrap);

    m_Arith.add(m_Div);
    m_Div.add(mDivImg);
    m_Div.add(mDivConst);
    mDivConst.add(mDivSat);
    mDivConst.add(mDivWrap);

    m_Filter.add(mlowPass);
    m_Filter.add(mhighPass);
    m_Filter.add(mhighBoost);
    m_Filter.add(median);
    m_Filter.add(mean);

    edge.add(mpre);
    edge.add(msob);
    mpre.add(mpre_hor);
    mpre.add(mpre_ver);
    mpre.add(mpre_both);
    msob.add(msob_hor);
    msob.add(msob_ver);
    msob.add(msob_both);
    edge.add(mrob);
    edge.add(mlap);

    m_Enhance.add(mBright);
    m_Enhance.add(mContrast);
    m_Enhance.add(mThreshold);
    m_Enhance.add(mInvert);
    m_Enhance.add(mBlend);

    other.add(hist);
    other.add(conect);

    m_Open.addActionListener(this);
    m_Save.addActionListener(this);
    m_Exit.addActionListener(this);

    mAddImg.addActionListener(this);
    mSubImg.addActionListener(this);
    mMulImg.addActionListener(this);
    mDivImg.addActionListener(this);

    mAddSat.addActionListener(this);
    mAddWrap.addActionListener(this);
    mSubSat.addActionListener(this);
    mSubWrap.addActionListener(this);
    mMulSat.addActionListener(this);
    mMulWrap.addActionListener(this);
    mDivSat.addActionListener(this);
    mDivWrap.addActionListener(this);

    mlowPass.addActionListener(this);
    mhighPass.addActionListener(this);
    mhighBoost.addActionListener(this);
    median.addActionListener(this);

    mBright.addActionListener(this);
    mContrast.addActionListener(this);
    mThreshold.addActionListener(this);
    mInvert.addActionListener(this);
    mBlend.addActionListener(this);

    mpre_hor.addActionListener(this);
    mpre_ver.addActionListener(this);
    mpre_both.addActionListener(this);
    msob_hor.addActionListener(this);
    msob_ver.addActionListener(this);
    msob_both.addActionListener(this);
    mrob.addActionListener(this);
    mean.addActionListener(this);
    mlap.addActionListener(this);

    hist.addActionListener(this);
    conect.addActionListener(this);

    lbl_gray.addMouseListener(this);

    panel_image.add(lbl_img);
    panel_gray.add(lbl_gray);
    panel_result.add(lbl_res);

    cp.add(vsb, BorderLayout.EAST);
    cp.add(hsb, BorderLayout.SOUTH);
    //	cp1 = getContentPane();

    cp = getContentPane();
    setSize(600, 400);
    setVisible(true);
  }
Exemplo n.º 7
0
  private void _displayImgInFrame() {

    final JFrame frame = new JFrame("Google Static Map");
    GUIUtils.setAppIcon(frame, "71.png");
    // frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JLabel imgLbl = new JLabel(new ImageIcon(_img));
    imgLbl.setToolTipText(
        MessageFormat.format(
            "<html>Image downloaded from URI<br>size: w={0}, h={1}</html>",
            _img.getWidth(), _img.getHeight()));

    GUIUtils.centerOnScreen(frame);
    frame.setVisible(true);
    frame.setContentPane(imgLbl);
    frame.pack();
    frame.setResizable(false);

    imgLbl.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {

            System.out.println("Mouse Listener:  Mouse Clicked!");
            mapIsUp = 1;
            sentX = 0.00;
            clickX = e.getX(); // Latitude
            clickY = e.getY(); // Longitude
            if ((clickX < (_img.getWidth() / 2))
                && (clickY < (_img.getHeight() / 2))) { // 1st quadrant positive values
              sentX =
                  Double.parseDouble(ttfLati.getText())
                      + (((-1 * (_img.getWidth() / 2)) + clickX) * pixelX); // Add to latitude
              sentY =
                  Double.parseDouble(ttfLongi.getText())
                      + (((_img.getHeight() / 2) - clickY) * pixelY); // Add to Longitude
              System.out.println("Top left");
            } else if ((clickX > (_img.getWidth() / 2))
                && (clickY > (_img.getHeight() / 2))) { // 2nd quadrant negative values
              sentX =
                  Double.parseDouble(ttfLati.getText())
                      + (((-1 * (_img.getHeight() / 2)) + clickX) * pixelX);
              sentY =
                  Double.parseDouble(ttfLongi.getText())
                      + (((_img.getHeight() / 2) - clickY) * pixelY);
              System.out.println("Bottom Right");
            } else if ((clickX < (_img.getWidth() / 2))
                && (clickY > (_img.getHeight() / 2))) { // 3rd quadrant 1 positive 1 negative
              sentX =
                  Double.parseDouble(ttfLati.getText())
                      + (((-1 * (_img.getWidth() / 2)) + clickX) * pixelX);
              sentY =
                  Double.parseDouble(ttfLongi.getText())
                      + (((_img.getHeight() / 2) - clickY) * pixelY);
              System.out.println("Bottom Left");
            } else { // 3rd quadrant 1 positive 1 negative
              sentX =
                  Double.parseDouble(ttfLati.getText())
                      + (((-1 * (_img.getHeight() / 2)) + clickX) * pixelX);
              sentY =
                  Double.parseDouble(ttfLongi.getText())
                      + (((_img.getHeight() / 2) - clickY) * pixelY);
              System.out.println("Top Right");
            }

            BigDecimal toCoordsX = new BigDecimal(sentX);
            BigDecimal toCoordsY = new BigDecimal(sentY);

            sentX =
                (toCoordsX.setScale(6, BigDecimal.ROUND_HALF_UP))
                    .doubleValue(); // allows values of up to 6 decimal places
            sentY = (toCoordsY.setScale(6, BigDecimal.ROUND_HALF_UP)).doubleValue();
            getCoords = sentX + " " + sentY;
            ttfLati.setText(Double.toString(sentX));
            ttfLongi.setText(Double.toString(sentY));

            System.out.println("... saving Coordinates");
            saveLocation(
                getCoords); // pass getCoords through saveLocation. this string is appended to the
                            // savedLocations file.
            System.out.println("... savedCoordinates");

            // Update the Locations ComboBox with new additions
            ttfSave.removeAllItems(); // re-populate the ComboBox
            System.out.println("removed items");

            getSavedLocations(); // run through file to get all locations
            for (int i = 0; i < loc.size(); i++) ttfSave.addItem(loc.get(i));
            System.out.println("update combobox");
            mapIsUp = 0;
            frame.dispose(); // closes window
            startTaskAction(); // pops up a new window
          }

          public void saveLocation(String xy) {
            BufferedWriter f = null; // created a bufferedWriter object

            try {
              f =
                  new BufferedWriter(
                      new FileWriter(
                          "savedLocations.txt",
                          true)); // evaluated true if file has not been created yet
              f.write(xy); // append passed coordinates and append to file if exists
              f.newLine();
              f.flush();
            } catch (IOException ioe) {
              ioe.printStackTrace();
            } finally { // close the file
              if (f != null) {

                try {
                  f.close();
                } catch (IOException e) { // any error, catch exception
                  System.err.println("Error: " + e.getMessage());
                }
              }
            }
          }

          public void mouseReleased(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}
        });
  }