private void _displayRespStrInFrame() { final JFrame frame = new JFrame("Google Static Map - Error"); GUIUtils.setAppIcon(frame, "69.png"); // frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JTextArea response = new JTextArea(_respStr, 25, 80); response.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) {} public void mousePressed(MouseEvent e) { /*frame.dispose();*/ } public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} }); frame.setContentPane(new JScrollPane(response)); frame.pack(); GUIUtils.centerOnScreen(frame); frame.setVisible(true); }
private void txAskingIdFocusLost( java.awt.event.FocusEvent evt) { // GEN-FIRST:event_txAskingIdFocusLost txAskingId.setText(GUIUtils.strNumber(txAskingId.getText(), null, null)); if (!txAskingId.getText().isEmpty()) { Asking asking = askingDAO.get(Integer.valueOf(txAskingId.getText())); if (asking != null) { txDate.setText(GUIUtils.formatDate(asking.getDate())); txName.setText( asking.getSecondName() + " " + asking.getFirstName() + " " + asking.getMiddleName()); } } } // GEN-LAST:event_txAskingIdFocusLost
private void validateForm() { List<String> errors = new ArrayList<String>(); GUIUtils.strDate(txDate.getText(), labDate.getText(), errors); if (!txReplyDate.getText().isEmpty()) { GUIUtils.strDate(txReplyDate.getText(), labReplyDate.getText(), errors); } if (!txAskingId.getText().isEmpty()) { Asking asking = askingDAO.get(Integer.valueOf(txAskingId.getText())); if (asking == null) { JOptionPane.showMessageDialog(null, "Обращение с указанным номером не найдено"); } } GUIUtils.showErrors(errors); }
private void initComponents() { setLayout(new BorderLayout(4, 4)); add(createReviewPanel(), BorderLayout.CENTER); add(createCtrlPanel(), BorderLayout.SOUTH); GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); }
private void doInit() { GUIUtils.setAppIcon(this, "burn.png"); GUIUtils.centerOnScreen(this); setVisible(true); int W = 28, H = W; boolean blur = false; float alpha = .7f; try { btnGetMap.setIcon(ImageUtils.loadScaledBufferedIcon("ok1.png", W, H, blur, alpha)); btnQuit.setIcon(ImageUtils.loadScaledBufferedIcon("charging.png", W, H, blur, alpha)); } catch (Exception e) { System.out.println(e); } _setupTask(); }
private void btnSaveActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSaveActionPerformed validateForm(); try { claim.setAsking(askingDAO.get(Integer.valueOf(txAskingId.getText()))); } catch (NumberFormatException e) { claim.setAsking(null); } claim.setDate(GUIUtils.str2Date(txDate.getText())); claim.setDescription(txDescription.getText()); claim.setName(txName.getText()); claim.setOffice((String) slOffice.getSelectedItem()); claim.setReason((String) slReason.getSelectedItem()); claim.setReplyDate(GUIUtils.str2Date(txReplyDate.getText())); claim.setStatus((String) slStatus.getSelectedItem()); if (claim.getId() == null) { claimDAO.add(claim); } else { claimDAO.update(claim); } } // GEN-LAST:event_btnSaveActionPerformed
public RegistratorClaimPanel(RegistratorForm registratorForm, Claim claim) { this.registratorForm = registratorForm; if (claim != null) { this.claim = claim; } else { this.claim = new Claim(); } initComponents(); if (claim != null) { if (claim.getAsking() != null) txAskingId.setText(GUIUtils.int2Str(claim.getAsking().getId())); txDate.setText(GUIUtils.formatDate(claim.getDate())); txName.setText(claim.getName()); slOffice.setSelectedItem(claim.getOffice()); txDescription.setText(claim.getDescription()); slReason.setSelectedItem(claim.getReason()); txReplyDate.setText(GUIUtils.formatDate(claim.getReplyDate())); slStatus.setSelectedItem(claim.getStatus()); } }
/** * Tells the look and feel to reset some of the values for this component so that it doesn't use * JTextArea's default values. * * <p>DO NOT CALL THIS METHOD YOURSELF! */ public void updateUI() { super.updateUI(); // setLineWrap(true); setWrapStyleWord(true); setHighlighter(null); setEditable(false); LookAndFeel.installBorder(this, "Label.border"); LookAndFeel.installColorsAndFont(this, "Label.background", "Label.foreground", "Label.font"); if (resizeHandler != null) { resizeHandler.componentResized(null); } // update restricted size SizePolicy policy = (SizePolicy) getClientProperty(SizePolicy.class); if (policy != null) { GUIUtils.restrictSize(this, policy); } }
private JPanel createCtrlPanel() { JPanel ctrlPanel = new JPanel(); ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS)); deleteButton = new JButton(DamusBundle.getString(DamusBundle.DELETE)); trainButton = new JButton(new TrainAction(panelViewer, reviewTable)); finishButton = new JButton(new FinishReviewAction(panelViewer)); GUIUtils.sizeUniformly(deleteButton, trainButton, finishButton); ctrlPanel.add(deleteButton); ctrlPanel.add(Box.createHorizontalGlue()); ctrlPanel.add(trainButton); ctrlPanel.add(Box.createHorizontalGlue()); ctrlPanel.add(finishButton); ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return ctrlPanel; }
private void initializeWindow() { setModal(true); // setResizable(false); setDefaultCloseOperation(DISPOSE_ON_CLOSE); GUIUtils.addHideAction(this); }
public void actionPerformed(ActionEvent event) { GUIUtils.getDisposeAction().actionPerformed(event); }
@Override protected void paintScreen(Graphics2D g) { g.setColor(Color.RED); GUIUtils.drawCenteredString((Graphics2D) g, "An error has occurred", getScreenWidth(), 20); GUIUtils.drawCenteredString((Graphics2D) g, message, getScreenWidth(), 50); }
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) {} }); }