Example usage for java.awt Dimension getWidth

List of usage examples for java.awt Dimension getWidth

Introduction

In this page you can find the example usage for java.awt Dimension getWidth.

Prototype

public double getWidth() 

Source Link

Usage

From source file:view.WorkspacePanel.java

private void btnApplySignatureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplySignatureActionPerformed
    if (tempCCAlias != null) {
        signatureSettings.setPageNumber(imagePanel.getPageNumber());
        signatureSettings.setCcAlias(tempCCAlias);
        signatureSettings.setReason(tfReason.getText());
        signatureSettings.setLocation(tfLocation.getText());
        if (jRadioButton1.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
        } else if (jRadioButton2.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
        } else if (jRadioButton3.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING);
        } else if (jRadioButton4.isSelected()) {
            signatureSettings/* w ww.  ja va 2 s.c om*/
                    .setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS);
        }
        signatureSettings.setOcspClient(true);
        if (cbTimestamp.isSelected()) {
            signatureSettings.setTimestamp(true);
            if (tfTimestamp.getText().isEmpty()) {
                JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.timestampEmpty"),
                        "", JOptionPane.ERROR_MESSAGE);
                return;
            } else {
                signatureSettings.setTimestampServer(tfTimestamp.getText());
            }
        } else {
            signatureSettings.setTimestamp(false);
            cbTimestamp.setSelected(false);
            tfTimestamp.setVisible(false);
        }
        signatureSettings.setVisibleSignature(cbVisibleSignature.isSelected());

        if (cbVisibleSignature.isSelected()) {
            Point p = tempSignature.getScaledPositionOnDocument();
            Dimension d = tempSignature.getScaledSizeOnDocument();
            float p1 = (float) p.getX();
            float p3 = (float) d.getWidth() + p1;
            float p2 = (float) ((document.getPageDimension(imagePanel.getPageNumber(), 0).getHeight())
                    - (p.getY() + d.getHeight()));
            float p4 = (float) d.getHeight() + p2;

            signatureSettings.setVisibleSignature(true);
            if (tempSignature.getImageLocation() != null) {
                signatureSettings.getAppearance().setImageLocation(tempSignature.getImageLocation());
            }
            Rectangle rect = new Rectangle(p1, p2, p3, p4);
            signatureSettings.setSignaturePositionOnDocument(rect);
            signatureSettings.setText(tfText.getText());
        } else {
            signatureSettings.setVisibleSignature(false);
        }
        if (mainWindow.getOpenedFiles().size() > 1) {
            Object[] options = { Bundle.getBundle().getString("menuItem.allDocuments"),
                    Bundle.getBundle().getString("menuItem.onlyThis"),
                    Bundle.getBundle().getString("btn.cancel") };
            int i = JOptionPane.showOptionDialog(null,
                    Bundle.getBundle().getString("msg.multipleDocumentsOpened"),
                    Bundle.getBundle().getString("msg.multipleDocumentsOpenedTitle"),
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (i == 0) {
                signBatch(signatureSettings);
            } else if (i == 1) {
                signDocument(document, true, true);
            }
        } else {
            signDocument(document, true, true);
        }
    } else {
        JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("noSmartcardFound"),
                WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE);
        changeCard(CardEnum.SIGN_PANEL, false);
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Paints the component by drawing the chart to fill the entire component, but allowing for the
 * insets (which will be non-zero if a border has been set for this component). To increase
 * performance (at the expense of memory), an off-screen buffer image can be used.
 * /*  w  ww  . j  a va  2  s .c o m*/
 * @param g
 *            the graphics device for drawing on.
 */
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (this.chart == null) {
        return;
    }
    Graphics2D g2 = (Graphics2D) g.create();

    // first determine the size of the chart rendering area...
    Dimension size = getSize();
    Insets insets = getInsets();
    Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top,
            size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom);

    // work out if scaling is required...
    boolean scale = false;
    double drawWidth = available.getWidth();
    double drawHeight = available.getHeight();
    this.scaleX = 1.0;
    this.scaleY = 1.0;

    if (drawWidth < this.minimumDrawWidth) {
        this.scaleX = drawWidth / this.minimumDrawWidth;
        drawWidth = this.minimumDrawWidth;
        scale = true;
    } else if (drawWidth > this.maximumDrawWidth) {
        this.scaleX = drawWidth / this.maximumDrawWidth;
        drawWidth = this.maximumDrawWidth;
        scale = true;
    }

    if (drawHeight < this.minimumDrawHeight) {
        this.scaleY = drawHeight / this.minimumDrawHeight;
        drawHeight = this.minimumDrawHeight;
        scale = true;
    } else if (drawHeight > this.maximumDrawHeight) {
        this.scaleY = drawHeight / this.maximumDrawHeight;
        drawHeight = this.maximumDrawHeight;
        scale = true;
    }

    Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight);

    // are we using the chart buffer?
    if (this.useBuffer) {
        // do we need to resize the buffer?
        if ((this.chartBuffer == null) || (this.chartBufferWidth != available.getWidth())
                || (this.chartBufferHeight != available.getHeight())) {
            this.chartBufferWidth = (int) available.getWidth();
            this.chartBufferHeight = (int) available.getHeight();
            this.chartBuffer = new BufferedImage(this.chartBufferWidth, this.chartBufferHeight,
                    BufferedImage.TYPE_INT_RGB);
            //this.chartBuffer = createImage(this.chartBufferWidth, this.chartBufferHeight);  -by Max
            // GraphicsConfiguration gc = g2.getDeviceConfiguration();
            // this.chartBuffer = gc.createCompatibleImage(
            // this.chartBufferWidth, this.chartBufferHeight,
            // Transparency.TRANSLUCENT);
            this.refreshBuffer = true;
        }

        // do we need to redraw the buffer?
        if (this.refreshBuffer) {
            Rectangle2D bufferArea = new Rectangle2D.Double(0, 0, this.chartBufferWidth,
                    this.chartBufferHeight);
            Graphics2D bufferG2 = (Graphics2D) this.chartBuffer.getGraphics();
            if (scale) {
                AffineTransform saved = bufferG2.getTransform();
                AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY);
                bufferG2.transform(st);
                this.chart.draw(bufferG2, chartArea, this.anchor, this.info);
                bufferG2.setTransform(saved);
            } else {
                this.chart.draw(bufferG2, bufferArea, this.anchor, this.info);
            }

            this.refreshBuffer = false;
        }

        // zap the buffer onto the panel...
        g2.drawImage(this.chartBuffer, insets.left, insets.top, this);

    }

    // or redrawing the chart every time...
    else {
        AffineTransform saved = g2.getTransform();
        g2.translate(insets.left, insets.top);
        if (scale) {
            AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY);
            g2.transform(st);
        }
        this.chart.draw(g2, chartArea, this.anchor, this.info);
        g2.setTransform(saved);
    }

    // Redraw the zoom rectangle (if present)
    drawZoomRectangle(g2);

    g2.dispose();
    this.anchor = null;
    this.verticalTraceLine = null;
    this.horizontalTraceLine = null;
}

From source file:gui.GW2EventerGui.java

/**
 * Creates new form GW2EventerGui/* ww  w  . j  a  va 2s .c o m*/
 */
public GW2EventerGui() {

    this.guiIcon = new ImageIcon(ClassLoader.getSystemResource("media/icon.png")).getImage();

    if (System.getProperty("os.name").startsWith("Windows")) {
        this.OS = "Windows";
        this.isWindows = true;
    } else {
        this.OS = "Other";
        this.isWindows = false;
    }

    if (this.isWindows == true) {
        this.checkIniDir();
    }

    initComponents();

    this.speakQueue = new LinkedList();

    this.speakRunnable = new Runnable() {

        @Override
        public void run() {

            String path = System.getProperty("user.home") + "\\.gw2eventer";
            File f;
            String sentence;

            while (!speakQueue.isEmpty()) {

                f = new File(path + "\\tts.vbs");

                if (!f.exists() && !f.isDirectory()) {

                    sentence = (String) speakQueue.poll();

                    try {

                        Writer writer = new OutputStreamWriter(
                                new FileOutputStream(
                                        System.getProperty("user.home") + "\\.gw2eventer\\tts.vbs"),
                                "ISO-8859-15");
                        BufferedWriter fout = new BufferedWriter(writer);

                        fout.write("Dim Speak");
                        fout.newLine();
                        fout.write("Set Speak=CreateObject(\"sapi.spvoice\")");
                        fout.newLine();
                        fout.write("Speak.Speak \"" + sentence + "\"");

                        fout.close();

                        Runtime rt = Runtime.getRuntime();

                        try {
                            if (sentence.length() > 0) {
                                Process p = rt.exec(System.getProperty("user.home") + "\\.gw2eventer\\tts.bat");
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    };

    this.matchIds = new HashMap();
    this.matchId = "2-6";
    this.matchIdColor = "green";

    this.jLabelNewVersion.setVisible(false);
    this.updateInformed = false;

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(screenSize.width / 2 - this.getSize().width / 2,
            (screenSize.height / 2 - this.getSize().height / 2) - 20);

    double width = screenSize.getWidth();
    double height = screenSize.getHeight();

    if ((width == 1280) && (height == 720 || height == 768 || height == 800)) {
        this.setExtendedState(this.MAXIMIZED_BOTH);
        //this.setLocation(0, 0);
    }

    JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) this.jSpinnerRefreshTime.getEditor();
    DefaultFormatter formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false);

    /*
     jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayX.getEditor();
     formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter();
     formatter.setAllowsInvalid(false);
            
     jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayY.getEditor();
     formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter();
     formatter.setAllowsInvalid(false);
     */
    this.workingButton = this.jButtonRefresh;
    this.refreshSelector = this.jCheckBoxAutoRefresh;

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {

            apiManager.saveSettingstoFile();
            System.exit(0);
        }
    });

    this.pushGui = new PushGui(this, true, "", "");
    this.pushGui.setIconImage(guiIcon);

    this.donateGui = new DonateGui(this, true);
    this.donateGui.setIconImage(guiIcon);

    this.infoGui = new InfoGui(this, true);
    this.infoGui.setIconImage(guiIcon);

    this.feedbackGui = new FeedbackGui(this, true);
    this.feedbackGui.setIconImage(guiIcon);

    this.overlayGui = new OverlayGui(this);
    this.initOverlayGui();

    this.settingsOverlayGui = new SettingsOverlayGui(this);
    this.initSettingsOverlayGui();

    this.wvwOverlayGui = new WvWOverlayGui(this);
    this.initWvwOverlayGui();

    this.language = "en";
    this.worldID = "2206"; //Millersund [DE]

    this.setTranslations();

    this.eventLabels = new ArrayList();
    this.eventLabelsTimer = new ArrayList();

    this.homeWorlds = new HashMap();

    this.preventSystemSleep = true;

    for (int i = 1; i <= EVENT_COUNT; i++) {

        try {

            Field f = getClass().getDeclaredField("labelEvent" + i);
            JLabel l = (JLabel) f.get(this);
            l.setPreferredSize(new Dimension(70, 28));
            //l.setToolTipText("");

            //int width2 = l.getX();
            //int height2 = l.getY();
            //System.out.println("$coords .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";");
            this.eventLabels.add(l);

            final int ii = i;

            l.addMouseListener(new java.awt.event.MouseAdapter() {
                @Override
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    showSoundSelector(ii);
                }
            });

            f = getClass().getDeclaredField("labelTimer" + i);
            l = (JLabel) f.get(this);
            l.setEnabled(true);
            l.setVisible(false);
            l.setForeground(Color.green);

            //int width2 = l.getX();
            //int height2 = l.getY();
            //System.out.println("$coords2 .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";");
            this.eventLabelsTimer.add(l);

        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException
                | IllegalAccessException ex) {
            Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    int[] disabledEvents = { 6, 8, 11, 12, 17, 18, 19, 20, 21, 22 };

    for (int i = 0; i < disabledEvents.length; i++) {

        Field f;
        JLabel l;

        try {
            f = getClass().getDeclaredField("labelEvent" + disabledEvents[i]);
            l = (JLabel) f.get(this);
            l.setEnabled(false);
            l.setVisible(false);

            f = getClass().getDeclaredField("labelTimer" + disabledEvents[i]);
            l = (JLabel) f.get(this);
            l.setEnabled(false);
            l.setVisible(false);
        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException
                | IllegalAccessException ex) {
            Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    this.lastPush = new Date();

    if (this.apiManager == null) {

        this.apiManager = new ApiManager(this, this.jSpinnerRefreshTime, this.jCheckBoxAutoRefresh.isSelected(),
                this.eventLabels, this.language, this.worldID, this.homeWorlds, this.jComboBoxHomeWorld,
                this.jLabelServer, this.jLabelWorking, this.jCheckBoxPlaySounds.isSelected(),
                this.workingButton, this.refreshSelector, this.eventLabelsTimer, this.jComboBoxLanguage,
                this.overlayGui, this.jCheckBoxWvWOverlay);
    }

    //this.wvwMatchReader = new WvWMatchReader(this.matchIds, this.jCheckBoxWvW);
    //this.wvwMatchReader.start();
    this.preventSleepMode();
    this.runUpdateService();
    this.runPushService();
    this.runTips();
    //this.runTest();
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Paints the component by drawing the chart to fill the entire component,
 * but allowing for the insets (which will be non-zero if a border has been
 * set for this component).  To increase performance (at the expense of
 * memory), an off-screen buffer image can be used.
 *
 * @param g  the graphics device for drawing on.
 *///from   w ww . j  a  v a  2s.c om
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (this.chart == null) {
        return;
    }
    Graphics2D g2 = (Graphics2D) g.create();

    // first determine the size of the chart rendering area...
    Dimension size = getSize();
    Insets insets = getInsets();
    Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top,
            size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom);

    // work out if scaling is required...
    boolean scale = false;
    double drawWidth = available.getWidth();
    double drawHeight = available.getHeight();
    this.scaleX = 1.0;
    this.scaleY = 1.0;

    if (drawWidth < this.minimumDrawWidth) {
        this.scaleX = drawWidth / this.minimumDrawWidth;
        drawWidth = this.minimumDrawWidth;
        scale = true;
    } else if (drawWidth > this.maximumDrawWidth) {
        this.scaleX = drawWidth / this.maximumDrawWidth;
        drawWidth = this.maximumDrawWidth;
        scale = true;
    }

    if (drawHeight < this.minimumDrawHeight) {
        this.scaleY = drawHeight / this.minimumDrawHeight;
        drawHeight = this.minimumDrawHeight;
        scale = true;
    } else if (drawHeight > this.maximumDrawHeight) {
        this.scaleY = drawHeight / this.maximumDrawHeight;
        drawHeight = this.maximumDrawHeight;
        scale = true;
    }

    Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight);

    // are we using the chart buffer?
    if (this.useBuffer) {

        // if buffer is being refreshed, it needs clearing unless it is
        // new - use the following flag to track this...
        boolean clearBuffer = true;

        // do we need to resize the buffer?
        if ((this.chartBuffer == null) || (this.chartBufferWidth != available.getWidth())
                || (this.chartBufferHeight != available.getHeight())) {
            this.chartBufferWidth = (int) available.getWidth();
            this.chartBufferHeight = (int) available.getHeight();
            this.chartBuffer = createImage(this.chartBufferWidth, this.chartBufferHeight);
            //                GraphicsConfiguration gc = g2.getDeviceConfiguration();
            //                this.chartBuffer = gc.createCompatibleImage(
            //                        this.chartBufferWidth, this.chartBufferHeight,
            //                        Transparency.TRANSLUCENT);
            this.refreshBuffer = true;
            clearBuffer = false; // buffer is new, no clearing required
        }

        // do we need to redraw the buffer?
        if (this.refreshBuffer) {

            this.refreshBuffer = false; // clear the flag

            Rectangle2D bufferArea = new Rectangle2D.Double(0, 0, this.chartBufferWidth,
                    this.chartBufferHeight);

            Graphics2D bufferG2 = (Graphics2D) this.chartBuffer.getGraphics();
            if (clearBuffer) {
                bufferG2.clearRect(0, 0, this.chartBufferWidth, this.chartBufferHeight);
            }
            if (scale) {
                AffineTransform saved = bufferG2.getTransform();
                AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY);
                bufferG2.transform(st);
                this.chart.draw(bufferG2, chartArea, this.anchor, this.info);
                bufferG2.setTransform(saved);
            } else {
                this.chart.draw(bufferG2, bufferArea, this.anchor, this.info);
            }

        }

        // zap the buffer onto the panel...
        g2.drawImage(this.chartBuffer, insets.left, insets.top, this);

    }

    // or redrawing the chart every time...
    else {

        AffineTransform saved = g2.getTransform();
        g2.translate(insets.left, insets.top);
        if (scale) {
            AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY);
            g2.transform(st);
        }
        this.chart.draw(g2, chartArea, this.anchor, this.info);
        g2.setTransform(saved);

    }

    // Redraw the zoom rectangle (if present)
    drawZoomRectangle(g2);

    g2.dispose();

    this.anchor = null;
    this.verticalTraceLine = null;
    this.horizontalTraceLine = null;

}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Paints the component by drawing the chart to fill the entire component, but allowing for the
 * insets (which will be non-zero if a border has been set for this component). To increase
 * performance (at the expense of memory), an off-screen buffer image can be used.
 * //from ww  w  .j a  v a 2s  .  co  m
 * @param g
 *            the graphics device for drawing on.
 */

@Override
public void paintComponent(Graphics g) {
    if (this.chart == null) {
        return;
    }
    Graphics2D g2 = (Graphics2D) g.create();

    // first determine the size of the chart rendering area...
    Dimension size = getSize();
    Insets insets = getInsets();
    Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top,
            size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom);

    // work out if scaling is required...
    boolean scale = false;
    double drawWidth = available.getWidth();
    double drawHeight = available.getHeight();
    this.scaleX = 1.0;
    this.scaleY = 1.0;

    if (drawWidth < this.minimumDrawWidth) {
        this.scaleX = drawWidth / this.minimumDrawWidth;
        drawWidth = this.minimumDrawWidth;
        scale = true;
    } else if (drawWidth > this.maximumDrawWidth) {
        this.scaleX = drawWidth / this.maximumDrawWidth;
        drawWidth = this.maximumDrawWidth;
        scale = true;
    }

    if (drawHeight < this.minimumDrawHeight) {
        this.scaleY = drawHeight / this.minimumDrawHeight;
        drawHeight = this.minimumDrawHeight;
        scale = true;
    } else if (drawHeight > this.maximumDrawHeight) {
        this.scaleY = drawHeight / this.maximumDrawHeight;
        drawHeight = this.maximumDrawHeight;
        scale = true;
    }

    Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight);
    // redrawing the chart every time...

    AffineTransform saved = g2.getTransform();
    g2.translate(insets.left, insets.top);
    if (scale) {
        AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY);
        g2.transform(st);
    }
    this.chart.draw(g2, chartArea, this.anchor, this.info);
    g2.setTransform(saved);

    Iterator<Overlay> iterator = this.overlays.iterator();
    while (iterator.hasNext()) {
        Overlay overlay = iterator.next();
        overlay.paintOverlay(g2, this);
    }

    // redraw the zoom rectangle (if present) - if useBuffer is false,
    // we use XOR so we can XOR the rectangle away again without redrawing
    // the chart
    drawSelectionRectangle(g2);

    g2.dispose();

    this.anchor = null;
    this.verticalTraceLine = null;
    this.horizontalTraceLine = null;

}

From source file:com.hammurapi.jcapture.CaptureFrame.java

protected void record() {
    try {/*from   w w  w.  j av a  2  s  .com*/
        Thread.sleep(200); // For Ubuntu.
    } catch (InterruptedException ie) {
        // Ignore
    }

    int borderWidth = 1;
    JFrame[] borderFrames = new JFrame[4];

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    Rectangle rr = captureConfig.getRecordingRectangle();
    Color borderColor = Color.RED;
    if (rr.x >= borderWidth) {
        // West border
        borderFrames[0] = new JFrame();
        borderFrames[0].setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        borderFrames[0].setSize(borderWidth, rr.height + borderWidth * 2);
        borderFrames[0].setLocation(rr.x - borderWidth, rr.y - borderWidth);
        borderFrames[0].setUndecorated(true);
        borderFrames[0].setAlwaysOnTop(true);
        borderFrames[0].setFocusableWindowState(false);
        borderFrames[0].getContentPane().setBackground(borderColor);
    }
    if (rr.x + rr.width < dim.width - borderWidth) {
        // East border
        borderFrames[1] = new JFrame();
        borderFrames[1].setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        borderFrames[1].setSize(borderWidth, rr.height + borderWidth * 2);
        borderFrames[1].setLocation(rr.x + rr.width, rr.y - borderWidth);
        borderFrames[1].setUndecorated(true);
        borderFrames[1].setAlwaysOnTop(true);
        borderFrames[1].setFocusableWindowState(false);
        borderFrames[1].getContentPane().setBackground(borderColor);
    }
    if (rr.y >= borderWidth) {
        // North border
        borderFrames[2] = new JFrame();
        borderFrames[2].setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        borderFrames[2].setSize(rr.width, borderWidth);
        borderFrames[2].setLocation(rr.x, rr.y - borderWidth);
        borderFrames[2].setUndecorated(true);
        borderFrames[2].setAlwaysOnTop(true);
        borderFrames[2].setFocusableWindowState(false);
        borderFrames[2].getContentPane().setBackground(borderColor);
    }
    if (rr.y + rr.height < dim.height - borderWidth) {
        // South border
        borderFrames[3] = new JFrame();
        borderFrames[3].setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        borderFrames[3].setSize(rr.width, borderWidth);
        borderFrames[3].setLocation(rr.x, rr.y + rr.height);
        borderFrames[3].setUndecorated(true);
        borderFrames[3].setAlwaysOnTop(true);
        borderFrames[3].setFocusableWindowState(false);
        borderFrames[3].getContentPane().setBackground(borderColor);
    }

    RecordingControlsFrame inst = new RecordingControlsFrame(this, borderFrames);
    int x = getLocation().x + getWidth() - inst.getWidth();
    if (x + inst.getWidth() > dim.getWidth()) {
        x = dim.width - inst.getWidth();
    } else if (x < 0) {
        x = 0;
    }

    int y = rr.getLocation().y + getHeight() + 1;
    if (y + inst.getHeight() > dim.height) {
        y = rr.getLocation().y - inst.getHeight();
        if (y < 0) {
            y = dim.height - inst.getHeight();
        }
    }
    inst.setLocation(x, y);
    inst.setVisible(true);
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @param report// w  ww .j a  v  a2s. c o  m
 * 
 * Loads and runs the query that acts as data source for report. Then runs report.
 */
public static void runReport(final SpReport report, final String title, final RecordSetIFace rs) {
    //XXX This is now also used to run Workbench reports. Really should extract the general stuff out
    //to a higher level...
    boolean isQueryBuilderRep = report.getReportObject() instanceof SpQuery;
    if (isQueryBuilderRep) {
        UsageTracker.incrUsageCount("QB.RunReport." + report.getQuery().getContextName());
    } else {
        UsageTracker.incrUsageCount("WB.RunReport");
    }
    TableTree tblTree = null;
    Hashtable<String, TableTree> ttHash = null;
    QueryParameterPanel qpp = null;
    if (isQueryBuilderRep) {
        UsageTracker.incrUsageCount("QB.RunReport." + report.getQuery().getContextName());
        QueryTask qt = (QueryTask) ContextMgr.getTaskByClass(QueryTask.class);
        if (qt != null) {
            Pair<TableTree, Hashtable<String, TableTree>> trees = qt.getTableTrees();
            tblTree = trees.getFirst();
            ttHash = trees.getSecond();
        } else {
            log.error("Could not find the Query task when running report " + report.getName());
            //blow up
            throw new RuntimeException("Could not find the Query task when running report " + report.getName());
        }
        qpp = new QueryParameterPanel();
        qpp.setQuery(report.getQuery(), tblTree, ttHash);
    }
    boolean go = true;
    try {
        JasperCompilerRunnable jcr = new JasperCompilerRunnable(null, report.getName(), null);
        jcr.findFiles();
        if (jcr.isCompileRequired()) {
            jcr.get();
        }
        //if isCompileRequired() is still true, then an error probably occurred compiling the report.
        JasperReport jr = !jcr.isCompileRequired() ? (JasperReport) JRLoader.loadObject(jcr.getCompiledFile())
                : null;
        ReportParametersPanel rpp = jr != null ? new ReportParametersPanel(jr, true) : null;
        JRDataSource src = null;
        if (rs == null && ((qpp != null && qpp.getHasPrompts()) || (rpp != null && rpp.getParamCount() > 0))) {
            Component pane = null;
            if (qpp != null && qpp.getHasPrompts() && rpp != null && rpp.getParamCount() > 0) {
                pane = new JTabbedPane();
                ((JTabbedPane) pane).addTab(UIRegistry.getResourceString("QB_REP_RUN_CRITERIA_TAB_TITLE"),
                        new JScrollPane(qpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));

                ((JTabbedPane) pane).addTab(UIRegistry.getResourceString("QB_REP_RUN_PARAM_TAB_TITLE"),
                        new JScrollPane(rpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
            } else if (qpp != null && qpp.getHasPrompts()) {
                pane = new JScrollPane(qpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            } else {
                pane = new JScrollPane(rpp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            }
            CustomDialog cd = new CustomDialog((Frame) UIRegistry.getTopWindow(),
                    UIRegistry.getResourceString("QB_GET_REPORT_CONTENTS_TITLE"), true,
                    CustomDialog.OKCANCELHELP, pane);
            cd.setHelpContext("RepRunSettings");
            cd.createUI();
            Dimension ps = cd.getPreferredSize();
            ps.setSize(ps.getWidth() * 1.3, ps.getHeight());
            cd.setSize(ps);
            UIHelper.centerAndShow(cd);
            go = !cd.isCancelled();
            cd.dispose();
        }
        if (go) {
            if (isQueryBuilderRep) {
                TableQRI rootQRI = null;
                int cId = report.getQuery().getContextTableId();
                for (TableTree tt : ttHash.values()) {
                    if (cId == tt.getTableInfo().getTableId()) {
                        rootQRI = tt.getTableQRI();
                        break;
                    }
                }
                Vector<QueryFieldPanel> qfps = new Vector<QueryFieldPanel>(qpp.getFields());
                for (int f = 0; f < qpp.getFields(); f++) {
                    qfps.add(qpp.getField(f));
                }

                HQLSpecs sql = null;

                // XXX need to allow modification of SelectDistinct(etc) ???
                //boolean includeRecordIds = true;
                boolean includeRecordIds = !report.getQuery().isSelectDistinct();

                try {
                    //XXX Is it safe to assume that query is not an export query? 
                    sql = QueryBldrPane.buildHQL(rootQRI, !includeRecordIds, qfps, tblTree, rs,
                            report.getQuery().getSearchSynonymy() == null ? false
                                    : report.getQuery().getSearchSynonymy(),
                            false, null);
                } catch (Exception ex) {
                    String msg = StringUtils.isBlank(ex.getLocalizedMessage())
                            ? getResourceString("QB_RUN_ERROR")
                            : ex.getLocalizedMessage();
                    UIRegistry.getStatusBar().setErrorMessage(msg, ex);
                    UIRegistry.writeTimedSimpleGlassPaneMsg(msg, Color.RED);
                    return;
                }
                int smushedCol = (report.getQuery().getSmushed() != null && report.getQuery().getSmushed())
                        ? getSmushedCol(qfps) + 1
                        : -1;
                src = new QBDataSource(sql.getHql(), sql.getArgs(), sql.getSortElements(),
                        getColumnInfo(qfps, true, rootQRI.getTableInfo(), false), includeRecordIds,
                        report.getRepeats(), smushedCol, /*getRecordIdCol(qfps)*/0);
                ((QBDataSource) src).startDataAcquisition();
            } else {
                DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
                try {
                    boolean loadedWB = false;
                    if (rs != null && rs.getOnlyItem() != null) {
                        Workbench wb = session.get(Workbench.class, rs.getOnlyItem().getRecordId());
                        if (wb != null) {
                            wb.forceLoad();
                            src = new WorkbenchJRDataSource(wb, true, report.getRepeats());
                            loadedWB = true;
                        }
                    }
                    if (!loadedWB) {
                        UIRegistry.displayErrorDlgLocalized("QueryBldrPane.WB_LOAD_ERROR_FOR_REPORT",
                                rs != null ? rs.getName() : "[" + UIRegistry.getResourceString("NONE") + "]");
                        return;
                    }
                } finally {
                    session.close();
                }
            }

            final CommandAction cmd = new CommandAction(ReportsBaseTask.REPORTS, ReportsBaseTask.PRINT_REPORT,
                    src);
            cmd.setProperty("title", title);
            cmd.setProperty("file", report.getName());
            if (rs == null) {
                cmd.setProperty("skip-parameter-prompt", "true");
            }
            //if isCompileRequired is true then an error probably occurred while compiling,
            //and, if so, it will be caught again and reported in the report results pane.
            if (!jcr.isCompileRequired()) {
                cmd.setProperty("compiled-file", jcr.getCompiledFile());
            }
            if (rpp != null && rpp.getParamCount() > 0) {
                StringBuilder params = new StringBuilder();
                for (int p = 0; p < rpp.getParamCount(); p++) {
                    Pair<String, String> param = rpp.getParam(p);
                    if (StringUtils.isNotBlank(param.getSecond())) {
                        params.append(param.getFirst());
                        params.append("=");
                        params.append(param.getSecond());
                        params.append(";");
                    }
                    cmd.setProperty("params", params.toString());
                }
            }
            CommandDispatcher.dispatch(cmd);
        }
    } catch (JRException ex) {
        UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex);
        log.error(ex);
        ex.printStackTrace();
    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param primaryStage//from  www  .  ja va 2 s .c  om
 * @throws Exception
 */
@Override
public void start(Stage primaryStage) throws Exception {
    File rep = new File("");
    currentDir = rep.getAbsolutePath();
    repertAppli = rep.getAbsolutePath();
    repertConfig = new File(repertAppli + File.separator + "configPV");
    if (!repertConfig.exists()) {
        repertConfig.mkdirs();
        locale = new Locale("fr", "FR");
        setUserAgentStylesheet("file:css/clair.css");
        repertoireProjet = repertAppli;
    } else {
        lisFichierConfig();
    }
    rb = ResourceBundle.getBundle("editeurpanovisu.i18n.PanoVisu", locale);
    stPrincipal = primaryStage;
    stPrincipal.setResizable(false);
    stPrincipal.setTitle("PanoVisu v" + numVersion);
    //AquaFx.style();
    //        setUserAgentStylesheet(STYLESHEET_MODENA);
    primaryStage.setMaximized(true);
    Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    int hauteur = (int) tailleEcran.getHeight() - 20;
    int largeur = (int) tailleEcran.getWidth() - 20;
    largeurMax = tailleEcran.getWidth() - 450.0d;
    creeEnvironnement(primaryStage, largeur, hauteur);

    File repertTempFile = new File(repertAppli + File.separator + "temp");
    repertTemp = repertTempFile.getAbsolutePath();

    if (!repertTempFile.exists()) {
        repertTempFile.mkdirs();
    } else {
        deleteDirectory(repertTemp);
    }
    String extTemp = genereChaineAleatoire(20);
    repertTemp = repertTemp + File.separator + "temp" + extTemp;
    repertTempFile = new File(repertTemp);
    repertTempFile.mkdirs();
    installeEvenements();
    projetsNouveau();
    primaryStage.setOnCloseRequest((WindowEvent event) -> {
        Action reponse = null;
        Localization.setLocale(locale);
        if (!dejaSauve) {
            reponse = Dialogs.create().owner(null).title("Quitter l'diteur")
                    .masthead("ATTENTION ! Vous n'avez pas sauvegard votre projet")
                    .message("Voulez vous le sauver ?")
                    .actions(Dialog.Actions.YES, Dialog.Actions.NO, Dialog.Actions.CANCEL).showWarning();
        }
        if (reponse == Dialog.Actions.YES) {
            try {
                projetSauve();

            } catch (IOException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if ((reponse == Dialog.Actions.YES) || (reponse == Dialog.Actions.NO) || (reponse == null)) {
            try {
                sauveHistoFichiers();
            } catch (IOException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }

            deleteDirectory(repertTemp);
            File ftemp = new File(repertTemp);
            ftemp.delete();
        } else {
            event.consume();
        }
    });
}

From source file:v800_trainer.JCicloTronic.java

/** Creates new form JCicloTronic */
public JCicloTronic() {

    ScreenSize = new Dimension();
    SelectionChanged = false;//www .  ja v a  2 s.c o m
    ScreenSize.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 50,
            java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50);
    Size = new Dimension();

    Properties = new java.util.Properties();
    SystemProperties = java.lang.System.getProperties();
    chooser = new javax.swing.JFileChooser();
    RawData = new byte[98316];
    //        System.setProperty("jna.library.path" , "C:/WINDOWS/system32");

    try {
        FileInputStream in = new FileInputStream(SystemProperties.getProperty("user.dir")
                + SystemProperties.getProperty("file.separator") + "JCicloexp.cfg");
        Properties.load(in);
        in.close();
    } catch (Exception e) {
        FontSize = 20;
        setFontSizeGlobal("Tahoma", FontSize);

        JOptionPane.showMessageDialog(null,
                "Keine Config-Datei in:  " + SystemProperties.getProperty("user.dir"), "Achtung!",
                JOptionPane.ERROR_MESSAGE);
        Properties.put("working.dir", SystemProperties.getProperty("user.dir"));
        Eigenschaften = new Eigenschaften(new javax.swing.JFrame(), true, this);
        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        double width = screenSize.getWidth();
        double height = screenSize.getHeight();
        this.setSize(new Dimension((int) width, (int) height));
        this.setPreferredSize(new Dimension((int) width, (int) height));
        this.setMinimumSize(new Dimension((int) width, (int) height));
        repaint();
    }
    try {

        UIManager.setLookAndFeel(Properties.getProperty("LookFeel"));
        SwingUtilities.updateComponentTreeUI(this);
        this.pack();
    } catch (Exception exc) {
    }

    if (debug) {
        try {
            System.setErr(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
            //        System.err =  new FileOutputStream(Properties.getProperty("working.dir") + SystemProperties.getProperty("file.separator") + "error.txt");
            System.setOut(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
        } catch (Exception err) {
        }
    }

    initComponents();

    setTitle("V800 Trainer    Datadir: " + Properties.getProperty("data.dir"));

    icon = new ImageIcon("hw.jpg");
    setIconImage(icon.getImage());

    if (Integer.parseInt(Properties.getProperty("View Geschw", "1")) == 1) {
        Graphik_check_Geschwindigkeit.setSelected(true);
    } else {
        Graphik_check_Geschwindigkeit.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hhe", "1")) == 1) {
        Graphik_check_Hhe.setSelected(true);
    } else {
        Graphik_check_Hhe.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hf", "1")) == 1) {
        Graphik_check_HF.setSelected(true);
    } else {
        Graphik_check_HF.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Temp", "1")) == 1) {
        Graphik_check_Temp.setSelected(true);
    } else {
        Graphik_check_Temp.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigp", "1")) == 1) {
        Graphik_check_Steigung_p.setSelected(true);
    } else {
        Graphik_check_Steigung_p.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigm", "1")) == 1) {
        Graphik_check_Steigung_m.setSelected(true);
    } else {
        Graphik_check_Steigung_m.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View av_Geschw", "1")) == 1) {
        Graphik_check_av_Geschw.setSelected(true);
    } else {
        Graphik_check_av_Geschw.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Cadence", "1")) == 1) {
        Graphik_check_Cadence.setSelected(true);
    } else {
        Graphik_check_Cadence.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Schrittlnge", "1")) == 1) {
        Graphik_check_Schrittlnge.setSelected(true);
    } else {
        Graphik_check_Schrittlnge.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("ZeitStreckeAbstnde", "1")) == 1) {
        Graphik_check_Abstand.setSelected(true);
    } else {
        Graphik_check_Abstand.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("SummenHisto", "1")) == 1) {
        Summenhistogramm_Check.setSelected(true);
    } else {
        Summenhistogramm_Check.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("xy_Strecke", "1")) == 1) {
        Graphik_Radio_Strecke.setSelected(true);
        Graphik_Radio_Zeit.setSelected(false);
    } else {
        Graphik_Radio_Strecke.setSelected(false);
        Graphik_Radio_Zeit.setSelected(true);
    }

    //Buttons fr XY-Darstellung   (ber Strecke oder ber Zeit)
    X_Axis = new ButtonGroup();
    X_Axis.add(Graphik_Radio_Strecke);
    X_Axis.add(Graphik_Radio_Zeit);

    //Buttons fr Jahresbersicht
    bersicht = new ButtonGroup();
    bersicht.add(jRadioButton_jahresverlauf);
    bersicht.add(jRadioButton_monatsbersicht);

    Datenliste_Zeitabschnitt.addItem("nicht aktiv");
    Datenliste_Zeitabschnitt.addItem("vergangene Woche");
    Datenliste_Zeitabschnitt.addItem("vergangener Monat");
    Datenliste_Zeitabschnitt.addItem("vergangenes Jahr");
    Datenliste_Zeitabschnitt.addItem("Alles");

    if (Datentabelle.getRowCount() != 0) {
        Datentabelle.addRowSelectionInterval(0, 0);
        Datenliste_scroll_Panel.getViewport().setViewPosition(new java.awt.Point(0, 0));
    }
    //        if (Properties.getProperty("CommPort").equals("nocom")) {
    //            jMenuReceive.setEnabled(false);
    //        } else {
    //            jMenuReceive.setEnabled(true);
    //        }

    jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount());

    setFileChooserFont(chooser.getComponents());
    locmap = true;
    Map_Type.removeAllItems();
    Map_Type.addItem("OpenStreetMap");
    Map_Type.addItem("Virtual Earth Map");
    Map_Type.addItem("Virtual Earth Satelite");
    Map_Type.addItem("Virtual Earth Hybrid");
    locmap = false;
    //    ChangeModel();
}

From source file:statos2_0.StatOS2_0.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");

    GridPane root = new GridPane();
    Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    root.setAlignment(Pos.CENTER);//from   ww w  .  j a v a  2s . c  o  m
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("");

    root.add(scenetitle, 0, 0, 2, 1);
    scenetitle.setId("welcome-text");
    Label userName = new Label(":");
    //userName.setId("label");
    root.add(userName, 0, 1);

    TextField userTextField = new TextField();
    root.add(userTextField, 1, 1);

    Label pw = new Label(":");
    root.add(pw, 0, 2);

    PasswordField pwBox = new PasswordField();
    root.add(pwBox, 1, 2);
    ComboBox store = new ComboBox();
    store.setItems(GetByTag());
    root.add(store, 1, 3);

    Button btn = new Button("");
    //btn.setPrefSize(100, 20);
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);

    root.add(hbBtn, 1, 4);

    Button btn2 = new Button("");
    //btn2.setPrefSize(100, 20);
    HBox hbBtn2 = new HBox(10);
    hbBtn2.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn2.getChildren().add(btn2);
    root.add(hbBtn2, 1, 5);

    final Text actiontarget = new Text();
    root.add(actiontarget, 1, 6);

    btn2.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            System.exit(0);
        }
    });

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            if (userTextField.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (pwBox.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (store.getSelectionModel().getSelectedIndex() < 0) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else {
                try {
                    String[] resu = checkpas(userTextField.getText(), pwBox.getText());
                    if (resu[0].equals("-1")) {
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("   !");
                        alert.showAndWait();
                    } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) {
                        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("     !"
                                + "\n       -  ");
                        Optional<ButtonType> result = alert.showAndWait();
                        if (result.get() == ButtonType.OK) {
                            // ... user chose OK
                            idstore = store.getSelectionModel().getSelectedIndex() + 1;
                            updsel(idstore, Integer.parseInt(resu[0]));
                            MainA ma = new MainA();
                            ma.m = (idstore);
                            ma.MT = "m" + idstore;
                            ma.selid = Integer.parseInt(resu[0]);
                            ma.nameseller = resu[1];
                            ma.storename = store.getSelectionModel().getSelectedItem().toString();
                            ma.start(primaryStage);
                        } else {
                            // ... user chose CANCEL or closed the dialog
                        }

                    } else {
                        // 

                        idstore = store.getSelectionModel().getSelectedIndex() + 1;
                        updsel(idstore, Integer.parseInt(resu[0]));
                        MainA ma = new MainA();
                        ma.m = (idstore);
                        ma.MT = "m" + idstore;
                        ma.selid = Integer.parseInt(resu[0]);
                        ma.nameseller = resu[1];
                        ma.storename = store.getSelectionModel().getSelectedItem().toString();

                        ma.start(primaryStage);

                    }

                } catch (NoSuchAlgorithmException ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            /**
             * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){
             * actiontarget.setId("acttrue");
             * actiontarget.setText(" !");
             * MainA ma = new MainA();
             * ma.m=1;
             * try {
             * ma.m=1;
             * ma.MT="m1";
             * ma.start(primaryStage);
             * } catch (Exception ex) {
             * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
             * }
             * }else{
             * actiontarget.setId("actfalse");
             * actiontarget.setText(" !");
             * } **/

        }
    });
    //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    //sSize.getHeight();
    Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight());

    primaryStage.setScene(scene);
    scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm());
    primaryStage.show();
}