public ConnectionForm() {
    setContentPane(contentPane);
    setModal(true);
    getRootPane().setDefaultButton(buttonOK);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setVisible(true);

    JMenu menu = new JMenu("Menu");
    menu.setVisible(true);

    JMenuItem statementItem = new JMenuItem("SQL Insert");
    statementItem.setVisible(true);
    statementItem.addActionListener(new SQLImportActionListener());
    statementItem.setEnabled(false);

    JMenuItem importItem = new JMenuItem("Files Import");
    importItem.setEnabled(false);
    importItem.setVisible(true);

    menu.add(statementItem);
    menu.add(importItem);
    menuBar.add(menu);
    setJMenuBar(menuBar);

    buttonOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
            int result = fileChooser.showOpenDialog(getParent());
          }
        });

    dbField.addMouseListener(new DBFileMouseListener(getParent()));
    filesField.addMouseListener(new SQLFilesMouseListener(getParent()));

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    // call onCancel() on ESCAPE
    contentPane.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  }
  /**
   * Gets a Swing component to display this property.
   *
   * @return a non-editable JTextField
   */
  public JComponent getEditorComponent() {
    final JTextField label;
    if (m_file == null) label = new JTextField();
    else label = new JTextField(m_file.getAbsolutePath());
    label.setEditable(false);
    label.addMouseListener(
        new MouseListener() {
          public void mouseClicked(final MouseEvent e) {
            final File selection = getFileUsingDialog(m_acceptableSuffixes);
            if (selection != null) {
              m_file = selection;
              label.setText(m_file.getAbsolutePath());
              // Ask Swing to repaint this label when it's convenient
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      label.repaint();
                    }
                  });
            }
          }

          public void mouseEntered(final MouseEvent e) {}

          public void mouseExited(final MouseEvent e) {}

          public void mousePressed(final MouseEvent e) {}

          public void mouseReleased(final MouseEvent e) {}
        });
    return label;
  }
Example #3
0
  /** Adds listeners to the UI components. */
  private void initListeners() {
    user.getDocument().addDocumentListener(this);
    pass.getDocument().addDocumentListener(this);
    login.addActionListener(this);
    user.addActionListener(this);
    pass.addActionListener(this);
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            quit();
          }
        });
    configButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            config();
          }
        });
    encryptionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            encrypt();
          }
        };
    encryptedButton.addActionListener(encryptionListener);
    addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            requestFocusOnField();
          }
        });
    user.addMouseListener(
        new MouseAdapter() {

          /**
           * Fires a property to move the window to the front.
           *
           * @see MouseListener#mouseClicked(MouseEvent)
           */
          public void mouseClicked(MouseEvent e) {
            firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true));
            user.requestFocus();
            // if (user.getText() != null)
            //	user.selectAll();
          }
        });
    pass.addMouseListener(
        new MouseAdapter() {

          /**
           * Fires a property to move the window to the front.
           *
           * @see MouseListener#mouseClicked(MouseEvent)
           */
          public void mouseClicked(MouseEvent e) {
            firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true));
            // requestFocusOnField();
          }
        });
  }
Example #4
0
  public static void Years(final JTextField textfield) {
    textfield.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent me) {

            gender_list.clear();
            gender_list = S1_mylist.ret_genders();
            Object[][] obj = new Object[gender_list.size()][1];
            int i = 0;
            for (S1_mylist.genders to : gender_list) {
              obj[i][0] = " " + to.gender;
              i++;
            }
            JLabel[] labels = {};
            int[] tbl_widths_customers = {textfield.getWidth()};
            String[] col_names = {""};
            TableRenderer tr = new TableRenderer();
            TableRenderer.setPopup(textfield, obj, labels, tbl_widths_customers, col_names);
            tr.setCallback(
                new TableRenderer.Callback() {
                  @Override
                  public void ok(TableRenderer.OutputData data) {
                    S1_mylist.genders to = (S1_mylist.genders) gender_list.get(data.selected_row);
                    textfield.setText("" + to.gender);
                  }
                });
          }
        });
  }
Example #5
0
 public Popup() {
   setLayout(new FlowLayout());
   add(t);
   ActionListener al =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           t.setText(((JMenuItem) e.getSource()).getText());
         }
       };
   JMenuItem m = new JMenuItem("Hither");
   m.addActionListener(al);
   popup.add(m);
   m = new JMenuItem("Yon");
   m.addActionListener(al);
   popup.add(m);
   m = new JMenuItem("Afar");
   m.addActionListener(al);
   popup.add(m);
   popup.addSeparator();
   m = new JMenuItem("Stay Here");
   m.addActionListener(al);
   popup.add(m);
   PopupListener pl = new PopupListener();
   addMouseListener(pl);
   t.addMouseListener(pl);
 }
  public EnterpriseCell() {

    this.enterpriseDAO = Lookup.getDefault().lookup(IEnterpriseBN.class);
    this.personDAO = Lookup.getDefault().lookup(IPersonBN.class);
    txtIdE = new JTextField();
    txtLogo = new JTextField();
    txtLogo.addMouseListener(this);
    txtNameE = new JTextField();
    txtSlogan = new JTextField();

    modelEnter = new DefaultComboBoxModel();
    modelEnter.addElement(" ");
    modelPerson = new DefaultComboBoxModel();
    modelPerson.addElement(" ");
    txtIdE.setText(" ");
    txtNameE.setText(" ");

    // Create model for combobox

    List<Enterprise> list = new ArrayList<Enterprise>();
    list = enterpriseDAO.getAllEnterprise();
    for (Enterprise bean : list) {
      modelEnter.addElement(bean);
    }

    List<Person> list1 = new ArrayList<Person>();
    list1 = personDAO.getAllPerson();
    for (Person bean : list1) {
      modelPerson.addElement(bean);
    }

    cboEnterprise = new JComboBox(modelEnter);
    cboPerson = new JComboBox(modelPerson);
  }
Example #7
0
  // Constructor
  public DeleteArchiveFrame(AmazonGlacierClient client, String vaultName, int region) {
    super("Delete Archive");

    int width = 200;
    int height = 170;

    Color wc = Color.WHITE;

    deleteClient = client;
    deleteVault = vaultName;

    JLabel label1 =
        new JLabel("ArchiveID to Delete from " + Endpoint.getTitleByIndex(region) + ":");
    jtfDeleteField = new JTextField(100);
    jbtDelete = new JButton("Delete");
    jbtBack = new JButton("Back");

    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout());
    p1.add(label1);
    p1.setBackground(wc);

    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(jtfDeleteField);
    jtfDeleteField.addMouseListener(new ContextMenuMouseListener());
    jtfDeleteField.setFocusable(true);
    p2.setBackground(wc);

    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout());
    p3.add(jbtDelete);
    jbtDelete.addActionListener(this);
    jbtDelete.setBackground(wc);
    p3.add(jbtBack);
    jbtBack.addActionListener(this);
    jbtBack.setBackground(wc);
    p3.setBackground(wc);

    JPanel p4 = new JPanel();
    p4.setLayout(new BorderLayout());
    p4.setBackground(wc);
    p4.add(p1, BorderLayout.NORTH);
    p4.add(p2, BorderLayout.CENTER);
    p4.add(p3, BorderLayout.SOUTH);

    setContentPane(p4);

    // Prepare for display
    pack();
    if (width < getWidth()) // prevent setting width too small
    width = getWidth();
    if (height < getHeight()) // prevent setting height too small
    height = getHeight();
    centerOnScreen(width, height);
    jtfDeleteField.setText("");
    jtfDeleteField.requestFocus();
  }
Example #8
0
  public ScaleSelectionPanel() {
    this.setLayout(new BorderLayout());

    initScaleFileSelector();

    JButton fileButton = new JButton("...");
    fileButton.addActionListener(
        (ActionEvent e) -> {
          List<File> rValue = FileChooserManager.getDefault().showOpenDialog(FILE_CHOOSER_ID, null);

          if (!rValue.isEmpty()) {
            File f = rValue.get(0);

            if (!f.exists()) {
              return;
            }

            scale = Scale.loadScale(f);

            updateDisplay();
            fireChangeEvent();
          }
        });

    fileNameField.setEditable(false);

    this.add(fileNameField, BorderLayout.CENTER);
    this.add(fileButton, BorderLayout.EAST);

    popup.add(
        new AbstractAction("Reset (12TET)") {

          @Override
          public void actionPerformed(ActionEvent e) {
            setScale(Scale.get12TET());
            fireChangeEvent();
          }
        });

    fileNameField.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mousePressed(MouseEvent evt) {
            if (UiUtilities.isRightMouseButton(evt)) {

              Component c = evt.getComponent();

              popup.show(c, evt.getX(), evt.getY());
            }
          }
        });
  }
Example #9
0
  public SudokuGUI(String x) {
    setTitle(x);
    textfield1.setEditable(false);
    button5.setEnabled(false);
    button10.setEnabled(false);
    button13.setEnabled(false);
    button12.setEnabled(false);
    button15.setEnabled(false);
    button18.setEnabled(false);
    setLayout(new GridLayout(6, 4, 4, 4));
    setLocation(350, 300);

    button1.addMouseListener(this);
    button2.addMouseListener(this);
    button3.addMouseListener(this);
    button4.addMouseListener(this);
    button6.addMouseListener(this);
    button7.addMouseListener(this);
    button8.addMouseListener(this);
    button9.addMouseListener(this);
    button11.addMouseListener(this);
    button14.addMouseListener(this);
    button16.addMouseListener(this);
    button17.addMouseListener(this);
    button19.addMouseListener(this);
    button20.addMouseListener(this);
    textfield2.addMouseListener(this);

    add(button1);
    add(button2);
    add(button3);
    add(button4);
    add(button5);
    add(button6);
    add(button7);
    add(button8);
    add(button9);
    add(button10);
    add(button11);
    add(button12);
    add(button13);
    add(button14);
    add(button15);
    add(button16);
    add(button17);
    add(button18);
    add(button19);
    add(button20);
    add(textfield1);
    add(textfield2);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(700, 400);
  }
  private void textFieldFactory() {
    nameTextField = new JTextField();
    nameTextField.setFont(Constants.defaultFont);

    associationFilePathTextField = new JTextField();
    associationFilePathTextField.setEditable(false);
    associationFilePathTextField.setFont(Constants.defaultFont);
    associationFilePathTextField.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            associationFilePathTextFieldMouseClicked(e);
          }
        });
  }
 /**
  * This method initializes p
  *
  * @return javax.swing.JTextField
  */
 private JTextField getP() {
   if (p == null) {
     p = new JTextField();
     p.setBounds(new Rectangle(270, 128, 181, 20));
     p.setText("Introduzca p");
     p.addMouseListener(
         new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent e) {
             if (escribir) p.setText("");
           }
         });
   }
   return p;
 }
 /**
  * This method initializes b
  *
  * @return javax.swing.JTextField
  */
 private JTextField getB() {
   if (b == null) {
     b = new JTextField();
     b.setBounds(new Rectangle(270, 85, 182, 20));
     b.setText("Introduzca b");
     b.addMouseListener(
         new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent e) {
             if (escribir) b.setText("");
           }
         });
   }
   return b;
 }
 /**
  * This method initializes a
  *
  * @return javax.swing.JTextField
  */
 private JTextField getA() {
   if (a == null) {
     a = new JTextField();
     a.setBounds(new Rectangle(270, 43, 181, 20));
     a.setText("Introduzca a");
     a.addMouseListener(
         new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent e) {
             if (escribir) a.setText("");
           }
         });
   }
   return a;
 }
Example #14
0
 private JTextField buildFileChooser() {
   chooser = new Mp3Chooser(this);
   fileTxt = new JTextField();
   fileTxt.setEnabled(false);
   fileTxt.setPreferredSize(new Dimension(300, 20));
   fileTxt.addMouseListener(
       new MouseClickListener() {
         @Override
         public void mouseClicked(MouseEvent e) {
           chooser.show();
         }
       });
   return fileTxt;
 }
Example #15
0
  @Override
  public void addListener(ActionListener ctr) {
    btnBrowse.setActionCommand(FILE_BROWSE);
    btnBrowse.addActionListener(ctr);
    tfTextPath.setActionCommand(PREVIEW);
    tfTextPath.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            showFileChooser();
          }
        });

    btnPreview.setActionCommand(PREVIEW);
    btnPreview.addActionListener(ctr);
    loadFileDialog.addListener(ctr);
  }
Example #16
0
  // constructor of TextFrame
  public TextFrame() {
    // this.message = message;
    message = "Click to Edit Text";
    messageFont = new Font("Arial", Font.PLAIN, 30);
    foreground = Color.black;
    background = Color.white;

    // custom dialog (it's a private class inside TextFrame)
    cd = new CustomDialog(this);

    messageField = new JTextField();
    messageField.setPreferredSize(new Dimension(300, 200));
    messageField.setEditable(false);
    messageField.setHorizontalAlignment(SwingConstants.CENTER);
    messageField.setAlignmentX(Component.CENTER_ALIGNMENT);
    updateMessage();

    customize = new JButton("Customize");
    customize.setMaximumSize(customize.getPreferredSize());
    customize.setAlignmentX(Component.CENTER_ALIGNMENT);

    apply = new JButton("Apply");
    apply.setMaximumSize(customize.getPreferredSize());
    apply.setAlignmentX(Component.CENTER_ALIGNMENT);

    /*add the listeners*/
    customize.addActionListener(this);
    apply.addActionListener(this);
    messageField.addMouseListener(new PopUpClass());

    // customize
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(customize);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(messageField);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(apply);
    p.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));

    // make panel this JFrame's content pane

    this.setContentPane(p);
  }
Example #17
0
  private JPanel buildSnipeSettings() {
    JPanel tp = new JPanel();
    JLabel jl = new JLabel("How close to snipe (in seconds):");

    tp.setBorder(BorderFactory.createTitledBorder("Snipe Timing"));
    tp.setLayout(new BorderLayout());

    snipeTime = new JTextField();
    snipeTime.addMouseListener(JPasteListener.getInstance());
    snipeTime.setToolTipText("Number of seconds prior to auction end to fire a snipe.");

    snipeTime.setEditable(true);
    snipeTime
        .getAccessibleContext()
        .setAccessibleName("Default number of seconds prior to auction end to fire a snipe.");
    tp.add(jl, BorderLayout.NORTH);
    tp.add(snipeTime, BorderLayout.SOUTH);

    return (tp);
  }
Example #18
0
    public void showUpdateIsAvailable(final AppUpdate appUpdate) {
        if (isVisible() && startPanel != null) {
            Color bg = new Color(0.2f, 1.0f, 0.0f, 0.1f);
            HelpPanel hp = startPanel.getHelpPanel();
            hp.removeAll();
            hp.setOpaque(true);
            hp.setBackground(bg);
            Font font = new Font(null, Font.BOLD, 14);
            JLabel label;
            label = new JLabel(_("JCloisterZone " + appUpdate.getVersion() + " is available for download."));
            label.setFont(font);
            hp.add(label, "wrap");
            label = new JLabel(appUpdate.getDescription());
            hp.add(label, "wrap");

            final JTextField link = new JTextField(appUpdate.getDownloadUrl());
            link.setEditable(false);
            link.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
            link.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseEntered(MouseEvent e) {
                    link.setSelectionStart(0);
                    link.setSelectionEnd(link.getText().length());
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    link.setSelectionStart(0);
                    link.setSelectionEnd(0);
                }
            });

            hp.add(link, "wrap, growx");
            hp.repaint();
        } else {
            //probably it shouln't happen
            System.out.println("JCloisterZone " + appUpdate.getVersion() + " is avaiable for download.");
            System.out.println(appUpdate.getDescription());
            System.out.println(appUpdate.getDownloadUrl());
        }
    }
Example #19
0
  JPanel createSearchBar() {
    // Setup the searchbox/button at the top:
    JPanel searchQueryPanel = new JPanel();
    JLabel searchQueryLabel = new JLabel("Search: ");
    searchQuery = new JTextField();
    searchQueryButton = new JButton("Search", frame.gui.util.getImage("newsearch"));

    // Add the action listeners
    searchQuery.setActionCommand("search");
    searchQuery.addActionListener(this);
    searchQuery.addMouseListener(this);
    searchQueryButton.setActionCommand("search");
    searchQueryButton.addActionListener(this);
    searchQueryButton.addMouseListener(this);

    // Add the components to the query pane
    searchQueryPanel.setLayout(new BorderLayout());
    searchQueryPanel.add(searchQueryLabel, BorderLayout.WEST);
    searchQueryPanel.add(searchQuery, BorderLayout.CENTER);
    searchQueryPanel.add(searchQueryButton, BorderLayout.EAST);
    return searchQueryPanel;
  }
  public CheckableFileField() {
    setLayout(new BorderLayout());

    JPanel south = new JPanel(new BorderLayout());
    south.add(filenameField = new JTextField(), CENTER);
    south.add(defaultButton = new JButton(), EAST);

    add(checkBox = new JCheckBox(), NORTH);
    add(south);

    filenameField.setEditable(false);
    filenameField.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    filenameField.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1 && filenameField.isEnabled()) {
              chooseFile();
            }
          }
        });
    checkBox.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            updateFileSelectionState();
          }
        });
    defaultButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            file(null);
          }
        });

    updateFileSelectionState();
    file(null);
  }
Example #21
0
  public MyTextField(int type) {
    this.type = type;

    field = new JTextField();

    if (type == 0 || type == -1) {
      width = 112;
      field.setBounds(28, 0, (int) (width * 0.55), height);
    } else {
      width = 200;
      field.setBounds(30, 0, (int) (width * 0.7), height);
    }
    this.setPreferredSize(new Dimension(width, height));
    this.setOpaque(false);
    this.setLayout(null);
    p = this;

    field.setFont(new Font("黑体", Font.PLAIN, 18));
    field.setForeground(new Color(44, 62, 80));
    field.setOpaque(false);
    field.setBorder(new EmptyBorder(0, 0, 0, 0));
    this.add(field);

    field.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            state = 2;
            p.repaint();
          }

          @Override
          public void mouseExited(MouseEvent e) {
            state = 1;
            p.repaint();
          }
        });
  }
  /**
   * ************************************************************ The above feature improvement was
   * made by Gang Shu on February 7, 2014
   * ************************************************************
   */
  private void initUI() {
    this.setSize(new Dimension(dialogWidth, dialogHeight));

    srcFilesDirField = createTextField();
    srcFilesDirField.setEditable(false);
    srcFilesDirField.addMouseListener(new BrowseSourceFilesBtnListener());

    workingDirField = createTextField();
    workingDirField.setEditable(true);
    workingDirField.addMouseListener(new BrowseWorkingDirButtonListener());

    buildSelectedFileCountLabel();

    srcFilesBrowseBtn = new JButton("Browse...");
    srcFilesBrowseBtn.addActionListener(new BrowseSourceFilesBtnListener());

    outputDirBrowseBtn = new JButton("Browse...");
    outputDirBrowseBtn.addActionListener(new BrowseWorkingDirButtonListener());

    finishButton = new JButton("Finish");
    vfbListener = new ValidateFinishButtonListener();
    finishButton.addActionListener(vfbListener);
    //        finishButton.addActionListener(new ValidateFinishButtonListener());

    cancelButton = new JButton("Cancel");
    InputMap im = cancelButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap am = cancelButton.getActionMap();
    im.put(KeyStroke.getKeyStroke("ESCAPE"), "Cancel");
    am.put("Cancel", new CancelAction());

    cancelButton.addActionListener(new CancelButtonListener());

    fileRadio = new JRadioButton("File Selections");
    fileRadio.setSelected(false);
    fileRadio.setToolTipText("select one or multiple EDF source files");
    fileRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (dirMode == true) {
              enableOutputDirPanel(false);
              resetActiveAreas();
              dirMode = false;
            }
          }
        });

    dirRadio = new JRadioButton("Directory");
    dirRadio.setSelected(true);
    dirRadio.setToolTipText("select a source directory of EDF files");
    dirRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (dirMode == false) enableOutputDirPanel(false);
            resetActiveAreas();
            dirMode = true;
          }
        });

    yesOverwriteRadio = new JRadioButton("Yes");
    yesOverwriteRadio.setToolTipText("overwrite source files");
    yesOverwriteRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputDirBrowseBtn.setEnabled(false);
            workingDirField.setEnabled(false);
            overwriteMode = true;
            MainWindow.setWriteMode(MainWindow.overwrite_mode);
            repaint();
          }
        });

    // noOverrideRadio = new JRadioButton("Save Changes to New Directory");
    noOverwriteRadio = new JRadioButton("No");
    noOverwriteRadio.setToolTipText("duplicate source files to new directory");
    noOverwriteRadio.setSelected(true);
    /** Bugfix to default write mode. (Mar. 5, 2014) */
    MainWindow.setWriteMode(MainWindow.duplicate_mode);
    /** Bugfix to default write mode. (Mar. 5, 2014) */
    noOverwriteRadio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputDirBrowseBtn.setEnabled(true);
            workingDirField.setEnabled(true);
            if (workingDirectory != null) workingDirField.setText(workingDirectory.toString());
            overwriteMode = false;
            MainWindow.setWriteMode(MainWindow.duplicate_mode);

            repaint();
          }
        });
    enableOutputDirPanel(false);
    finishButton.setEnabled(false);
    // disable finish button until source and output have been chosen. -- Fangping, 08/03/2010
  }
  /**
   * Creates a new <code>AddPersonDialog</code> with a given owner <code>JFrame</code> and <code>
   * FamilyTree</code>.
   */
  public AddPersonDialog(JFrame owner, FamilyTree tree) {
    super(owner, "Add New Person", true /* modal */);

    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayout(0, 2));
    Border infoBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    infoPanel.setBorder(infoBorder);

    infoPanel.add(new JLabel("id:"));
    final JTextField idField = new JTextField();
    infoPanel.add(idField);

    final ButtonGroup group = new ButtonGroup();

    final JRadioButton male = new JRadioButton("male", true);
    group.add(male);
    infoPanel.add(male);

    final JRadioButton female = new JRadioButton("female");
    group.add(female);
    infoPanel.add(female);

    infoPanel.add(new JLabel("First name:"));
    final JTextField firstNameField = new JTextField();
    infoPanel.add(firstNameField);

    infoPanel.add(new JLabel("Middle name:"));
    final JTextField middleNameField = new JTextField();
    infoPanel.add(middleNameField);

    infoPanel.add(new JLabel("Last name:"));
    final JTextField lastNameField = new JTextField();
    infoPanel.add(lastNameField);

    infoPanel.add(new JLabel("Date of Birth:"));
    final JTextField dobField = new JTextField();
    infoPanel.add(dobField);

    infoPanel.add(new JLabel("Date of Death:"));
    final JTextField dodField = new JTextField();
    infoPanel.add(dodField);

    infoPanel.add(new JLabel("Father:"));
    JPanel fatherPanel = new JPanel();
    fatherPanel.setLayout(new FlowLayout());
    final JTextField fatherText = new JTextField("Click to choose");
    fatherText.setEditable(false);
    fatherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked father");
          }
        });
    fatherPanel.add(fatherText);
    infoPanel.add(fatherPanel);

    infoPanel.add(new JLabel("Mother:"));
    JPanel motherPanel = new JPanel();
    motherPanel.setLayout(new FlowLayout());
    final JTextField motherText = new JTextField("Click to choose");
    motherText.setEditable(false);
    motherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked mother");
          }
        });
    motherPanel.add(motherText);
    infoPanel.add(motherPanel);

    pane.add(infoPanel, BorderLayout.NORTH);

    // "Add" and "Cancel" buttons
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());

    JButton addButton = new JButton("Add");
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Create a new person based on the information entered in
            // this dialog
            int id = 0;
            try {
              id = Integer.parseInt(idField.getText());

            } catch (NumberFormatException ex) {
              error("Invalid id: " + idField.getText());
              return;
            }

            String text = null;

            text = dobField.getText();
            Date dob = null;
            if (text != null && !text.equals("")) {
              dob = parseDate(dobField.getText());
              if (dob == null) {
                // Parse error
                return;
              }
            }

            text = dodField.getText();
            Date dod = null;
            if (text != null && !text.equals("")) {
              dod = parseDate(dodField.getText());
              if (dod == null) {
                // Parse error
                return;
              }
            }

            Person.Gender gender;
            if (group.getSelection().equals(male)) {
              gender = Person.MALE;

            } else {
              gender = Person.FEMALE;
            }

            // Okay, everything parsed alright
            newPerson = new Person(id, gender);
            newPerson.setFirstName(firstNameField.getText());
            newPerson.setMiddleName(middleNameField.getText());
            newPerson.setLastName(lastNameField.getText());
            newPerson.setDateOfBirth(dob);
            newPerson.setDateOfDeath(dod);

            if (mother != null) {
              newPerson.setMother(mother);
            }

            if (father != null) {
              newPerson.setFather(father);
            }

            // We're all happy
            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(addButton);

    buttonPanel.add(Box.createHorizontalGlue());

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Read my lips, no new Person!

            AddPersonDialog.this.newPerson = null;

            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(cancelButton);

    buttonPanel.add(Box.createHorizontalGlue());

    pane.add(buttonPanel, BorderLayout.SOUTH);
  }
Example #24
0
  @SuppressWarnings("deprecation")
  public void init() {
    int w = frame.getWidth() / 851;
    int h = frame.getHeight() / 576;
    AllImage.welcome.setImage(
        AllImage.welcome
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_version.setImage(
        AllImage.welcome_version
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_login.setImage(
        AllImage.welcome_login
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_input2.setImage(
        AllImage.welcome_input2
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_input1.setImage(
        AllImage.welcome_input1
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_aboutus.setImage(
        AllImage.welcome_aboutus
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_none.setImage(
        AllImage.welcome_none
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));

    welcome = new JLabel(AllImage.welcome);
    welcome.setSize(panel.getWidth(), panel.getHeight());
    welcome.setLocation(0, 0);

    welcome_none = new JLabel(AllImage.welcome_none);
    welcome_none.setSize(panel.getWidth(), panel.getHeight());
    welcome_none.setLocation(0, 0);
    welcome_none.setVisible(false);

    aboutusPane.setSize(508 * w, 346 * h);
    aboutusPane.setLocation(176 * w, 122 * h);
    aboutusPane.setVisible(false);
    searchField.setOpaque(false);
    searchField.setBorder(null);
    searchField.setFont(new Font("ºÚÌå", Font.PLAIN, 18));
    searchField.setForeground(Color.BLACK);
    searchField.setSize(w * 290, h * 54);
    searchField.setLocation(w * 240, h * 221);
    searchField.addMouseListener(
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_input1);
            panel.repaint();
          }

          public void mouseClicked(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_input2);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }
        });

    panel.setLayout(null);
    welComeLabel.setSize(frame.getWidth() / 4, frame.getHeight() / 10);
    welComeLabel.setLocation(
        frame.getWidth() / 8 * 3, frame.getHeight() / 5 * 2 - welComeLabel.getHeight());
    welComeLabel.setFont(new Font("ºÚÌå", 0, 30));

    search.setOpaque(false);
    search.setBorder(null);
    search.setSize(58 * w, 62 * h);
    search.setLocation(565 * w, 236 * h);

    aboutUs.setOpaque(false);
    aboutUs.setBorder(null);
    aboutUs.setSize(54 * w, 15 * h);
    aboutUs.setLocation(432 * w, 470 * h);

    version.setOpaque(false);
    version.setBorder(null);
    version.setSize(50 * w, 11 * h);
    version.setLocation(350 * w, 470 * h);

    aboutusClose.setOpaque(false);
    aboutusClose.setBorder(null);
    aboutusClose.setSize(18 * w, 18 * h);
    aboutusClose.setLocation(648 * w, 132 * h);

    login.setOpaque(false);
    login.setBorder(null);
    login.setSize(75 * w, 13 * h);
    login.setLocation(768 * w, 54 * h);

    panel.add(aboutusClose);
    panel.add(aboutusPane);
    panel.add(login);
    panel.add(search);
    panel.add(welComeLabel);
    panel.add(searchField);
    panel.add(aboutUs);
    panel.add(version);
    panel.add(welcome);
    panel.add(welcome_none);
    search.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_input2);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }
        });

    aboutusClose.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            aboutusPane.setVisible(false);
            welcome_none.setVisible(false);
            welcome.setVisible(true);
            panel.add(searchField);
            panel.add(search);
            panel.repaint();
          }
        });

    aboutUs.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_aboutus);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }

          public void mouseClicked(MouseEvent e) {
            panel.remove(searchField);
            panel.remove(search);
            welcome.setVisible(false);
            welcome_none.setVisible(true);
            aboutusPane.setVisible(true);
            panel.repaint();
          }
        });
    version.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_version);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }

          public void mouseClicked(MouseEvent e) {
            panel.remove(searchField);
            panel.remove(search);
            welcome.setVisible(false);
            welcome_none.setVisible(true);
            aboutusPane.setVisible(true);
            panel.repaint();
          }
        });
    login.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            removeA();
            panel.repaint();
            MainController.jumpToRightui(Rightui.Login);
          }

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_login);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }
        });
    panel.repaint();
  }
Example #25
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmShutdowntimer = new JFrame();
    frmShutdowntimer.setTitle("Shutdowntimer");
    frmShutdowntimer.setFont(new Font("Dialog", Font.PLAIN, 12));
    frmShutdowntimer.setResizable(false);
    frmShutdowntimer.setBounds(100, 100, 650, 177);
    frmShutdowntimer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    start = new JButton("Start");
    start.setBounds(453, 94, 160, 33);
    start.setFont(new Font("Tahoma", Font.PLAIN, 20));
    start.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Thread timerThread = new Thread(GUI.this);
            if (running) {
              running = false;
              GUI.this.start.setText("Start");
              textField.setText("00");
              textField_1.setText("00");
              textField_2.setText("00");
              label.setText("");

            } else {
              running = true;
              GUI.this.start.setText("Stop");
              timerThread.start();
            }
          }
        });

    textField = new JTextField();
    textField.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            textField.setText("");
          }
        });
    textField.setHorizontalAlignment(SwingConstants.CENTER);
    textField.setText("00");
    textField.setBounds(27, 51, 176, 31);
    textField.setFont(new Font("Tahoma", Font.PLAIN, 20));
    textField.setColumns(10);

    textField_1 = new JTextField();
    textField_1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            textField_1.setText("");
          }
        });
    textField_1.setHorizontalAlignment(SwingConstants.CENTER);
    textField_1.setText("00");
    textField_1.setBounds(240, 51, 176, 31);
    textField_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
    textField_1.setColumns(10);

    textField_2 = new JTextField();
    textField_2.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            textField_2.setText("");
          }
        });
    textField_2.setText("00");
    textField_2.setHorizontalAlignment(SwingConstants.CENTER);
    textField_2.setBounds(453, 51, 160, 31);
    textField_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
    textField_2.setColumns(10);

    label = new JLabel("                 ");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setBounds(240, 98, 176, 25);
    label.setFont(new Font("Tahoma", Font.PLAIN, 20));

    lblNewLabel = new JLabel(":");
    lblNewLabel.setBounds(218, 54, 7, 25);
    lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));

    label_1 = new JLabel(":");
    label_1.setBounds(431, 54, 7, 25);
    label_1.setFont(new Font("Tahoma", Font.BOLD, 20));
    frmShutdowntimer.getContentPane().setLayout(null);

    lblStunden = new JLabel("Stunden");
    lblStunden.setBounds(27, 16, 176, 25);
    lblStunden.setFont(new Font("Tahoma", Font.PLAIN, 20));
    frmShutdowntimer.getContentPane().add(lblStunden);
    frmShutdowntimer.getContentPane().add(textField);
    frmShutdowntimer.getContentPane().add(lblNewLabel);
    frmShutdowntimer.getContentPane().add(textField_1);
    frmShutdowntimer.getContentPane().add(label_1);
    frmShutdowntimer.getContentPane().add(label);
    frmShutdowntimer.getContentPane().add(textField_2);
    frmShutdowntimer.getContentPane().add(start);

    lblMinuten = new JLabel("Minuten");
    lblMinuten.setFont(new Font("Tahoma", Font.PLAIN, 20));
    lblMinuten.setBounds(240, 18, 176, 20);
    frmShutdowntimer.getContentPane().add(lblMinuten);

    lblSekunden = new JLabel("Sekunden");
    lblSekunden.setFont(new Font("Tahoma", Font.PLAIN, 20));
    lblSekunden.setBounds(453, 20, 160, 20);
    frmShutdowntimer.getContentPane().add(lblSekunden);
  }
Example #26
0
  public void addItem(String item) {
    JTextField menuItem = new JTextField(item);

    // don't allow editing of text field
    menuItem.setEditable(false);

    // set full name as tooltip
    menuItem.setToolTipText(item);

    // add mouse listener to modify trigger string
    menuItem.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseReleased(MouseEvent arg0) {
            Object source = arg0.getSource();

            // make sure click was on a JTextField
            if (source instanceof JTextField) {
              JTextField item = (JTextField) source;
              autoComplete.replaceWithPopupItem(item.getText());

              // don't show popup anymore
              autoComplete.hidePopup();
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseExited(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent e) {
            // TODO Auto-generated method stub

          }
        });

    // add item to popup
    this.add(menuItem);

    // resize the popup when the current item has larger bounds than the previous max
    int currentStringWidth = (int) mxUtils.getSizeForString(item, this.fontSize).getWidth();
    if (currentStringWidth > this.maxWidth) {
      this.maxWidth = currentStringWidth;
      resetSize(this.maxWidth, this.minHeight);
    }
  }
  public InvoiceUI_LoadingListZZEdit(LoadingListZZVO vo, boolean edit) {
    voall = vo;
    setLayout(null);
    setTitle("装车单  No:" + vo.getID());
    setResizable(false);
    setBounds(screenWidth / 4, screenHeight / 4, screenWidth / 3, 6 * screenHeight / 8);
    setVisible(true);

    Edit = edit;

    final JPanel newin = new JPanel();
    newin.setLayout(null);
    add(newin);
    newin.setBounds(0, 0, this.getWidth(), 3 * this.getHeight() / 5);
    newin.setBorder(BorderFactory.createTitledBorder(""));

    JLabel id = new JLabel("单据ID");
    // 前两位zc 后面五位数字
    newin.add(id);
    id.setBounds(120, 20, 80, 20);
    final JTextField idf = new JTextField(vo.getID());
    newin.add(idf);
    idf.setBounds(220, 20, 100, 24);
    idf.setEditable(Edit);
    idf.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel date = new JLabel("装车日期");
    newin.add(date);
    date.setBounds(120, 60, 80, 20);
    final JTextField df = new JTextField(vo.getTime());
    df.setFont(new Font("Dialog", Font.CENTER_BASELINE, 12));
    newin.add(df);
    df.setBounds(220, 60, 100, 24);
    df.setEditable(Edit);
    df.setHorizontalAlignment(SwingConstants.CENTER);
    if (Edit) {
      df.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                df.setText(sdf.format(new Date()));
              }
            }
          });
    }

    JLabel transNum = new JLabel("汽运编号");
    // 20位
    newin.add(transNum);
    transNum.setBounds(120, 100, 80, 20);
    final JTextField tnf = new JTextField(vo.getTransportNumber());
    tnf.setFont(new Font("SansSerif", Font.CENTER_BASELINE, 12));
    newin.add(tnf);
    tnf.setBounds(220, 100, 150, 24);
    tnf.setEditable(Edit);
    tnf.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel arrivalPlace = new JLabel("到达地");
    newin.add(arrivalPlace);
    arrivalPlace.setBounds(120, 140, 80, 20);
    final JTextField apf = new JTextField(vo.getArrival());
    apf.setFont(new Font("SansSerif", Font.PLAIN, 12));
    newin.add(apf);
    apf.setBounds(220, 140, 100, 24);
    apf.setEditable(Edit);
    apf.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel carNum = new JLabel("车辆代号");
    newin.add(carNum);
    carNum.setBounds(120, 180, 80, 20);
    final JTextField cnf = new JTextField(vo.getCarNumber());
    cnf.setFont(new Font("SansSerif", Font.CENTER_BASELINE, 12));
    newin.add(cnf);
    cnf.setBounds(220, 180, 100, 24);
    cnf.setEditable(Edit);
    cnf.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel supervisor = new JLabel("监装员");
    newin.add(supervisor);
    supervisor.setBounds(120, 220, 80, 20);
    final JTextField s1f = new JTextField(vo.getSurpervior());
    s1f.setFont(new Font("SansSerif", Font.CENTER_BASELINE, 12));
    newin.add(s1f);
    s1f.setBounds(220, 220, 100, 24);
    s1f.setEditable(Edit);
    s1f.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel supercargo = new JLabel("押运员");
    newin.add(supercargo);
    supercargo.setBounds(120, 260, 80, 20);
    final JTextField s2f = new JTextField(vo.getSupercargo());
    s2f.setFont(new Font("SansSerif", Font.CENTER_BASELINE, 12));
    newin.add(s2f);
    s2f.setBounds(220, 260, 100, 24);
    s2f.setEditable(Edit);
    s2f.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel orderNum = new JLabel("订单条形号码");
    newin.add(orderNum);
    orderNum.setBounds(120, 300, 80, 20);
    ArrayList<String> arr = new ArrayList<String>(vo.getOrderNumber());
    String[] strs = new String[arr.size()];
    String str = null;
    for (int i = 0; i < arr.size(); i++) {
      strs[i] = arr.get(i) + "\n";
      str += strs[i];
    }
    final JTextArea area = new JTextArea(str);
    area.setLineWrap(true);
    area.setFont(new Font("SanSerif", Font.PLAIN, 12));
    JScrollPane pane =
        new JScrollPane(
            area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    newin.add(pane);
    pane.setViewportView(area);
    pane.setBounds(220, 300, 100, 64);

    JLabel cost = new JLabel("运费");
    newin.add(cost);
    cost.setBounds(120, 380, 80, 20);
    final JTextField cf = new JTextField(String.valueOf(vo.getCost()));
    cf.setFont(new Font("SansSerif", Font.CENTER_BASELINE, 12));
    newin.add(cf);
    cf.setBounds(220, 380, 100, 24);
    cf.setEditable(Edit);
    cf.setHorizontalAlignment(SwingConstants.CENTER);

    JPanel buttonpanel = new JPanel();
    buttonpanel.setLayout(null);
    JButton cancle = new JButton("编辑(E)");
    buttonpanel.add(cancle);
    cancle.setBounds(this.getWidth() / 2 + 90, 25, 100, 30);
    add(buttonpanel);
    buttonpanel.setBounds(0, 3 * this.getHeight() / 5, this.getWidth(), 70);

    cancle.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            InvoiceUI_LoadingListZZEdit.this.dispose();
            new InvoiceUI_LoadingListZZEdit(getVO(), true);
          }
        });

    if (Edit) {
      JButton save = new JButton("保存(S)");
      buttonpanel.add(save);
      save.setBounds(this.getWidth() / 3 - 120, 25, 100, 30);

      save.addActionListener(
          new ActionListener() {
            LoadingListZZBL loadinglistzzdata = new LoadingListZZBL();
            LoadingListZZVO newvo;

            public void actionPerformed(ActionEvent e) {
              //					if(idf.getText().equals(voall.getID())&&df.getText().equals(voall.getTime())&&
              //
              //	tnf.getText().equals(voall.getOrder())&&jcb.getSelectedItem().toString().equals(voall.getState())
              //							&&dpf.getText().equals(voall.getFrom())){
              //						JOptionPane.showMessageDialog(newin, "未发生改变");
              //						InvoiceUI_LoadingListZZEdit.this.dispose();
              //						new InvoiceUI_LoadingListZZEdit(voall,false);
              //					}else{
              try {
                if (!df.getText().matches("\\d{4}-\\d{1,2}-\\d{1,2}")
                    || tnf.getText().length() != 21
                    || cnf.getText().length() != 9) {
                  JOptionPane.showMessageDialog(newin, "修改信息格式错误");
                }
                InvoiceUI_LoadingListZZEdit.this.dispose();
                loadinglistzzdata.delete(getVO());
                loadinglistzzdata.record(newvo);
                new InvoiceUI_LoadingListZZEdit(newvo, false);

              } catch (HeadlessException e2) {
                e2.printStackTrace();
              } catch (IOException e2) {
                e2.printStackTrace();
                //						}
              }
            }
          });
    }

    if (Edit) {
      JButton back = new JButton("取消(C)");
      buttonpanel.add(back);
      back.setBounds(this.getWidth() / 2 - 50, 25, 100, 30);
      back.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              InvoiceUI_LoadingListZZEdit.this.dispose();
              new InvoiceUI_LoadingListZZEdit(getVO(), false);
            }
          });

    } else {
      JButton back = new JButton("删除(D)");
      buttonpanel.add(back);
      back.setBounds(this.getWidth() / 2 - 50, 25, 100, 30);
      back.addActionListener(
          new ActionListener() {
            LoadingListZZBL loadinglistzzdata = new LoadingListZZBL();

            public void actionPerformed(ActionEvent e) {
              try {
                loadinglistzzdata.delete(voall);
              } catch (IOException e1) {
                e1.printStackTrace();
              }
              InvoiceUI_LoadingListZZEdit.this.dispose();
              JOptionPane.showMessageDialog(null, voall.getID() + "已删除");
            }
          });
    }
  }
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.getContentPane().setBackground(Color.WHITE);
    frame.getContentPane().setForeground(Color.RED);
    frame.setBackground(Color.WHITE);
    frame.setBounds(100, 100, 613, 459);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setForeground(Color.BLACK);
    tabbedPane.setBackground(Color.WHITE);
    tabbedPane.setBounds(1, 2, 596, 408);
    frame.getContentPane().add(tabbedPane);

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(Color.WHITE);
    panel_1.setForeground(Color.GREEN);
    tabbedPane.addTab("Recieved Mail", null, panel_1, null);
    panel_1.setLayout(null);

    JTextPane textPane_1 = new JTextPane();
    textPane_1.setBackground(Color.WHITE);
    textPane_1.setForeground(Color.BLACK);
    textPane_1.setEditable(false);

    JScrollPane scrollPane1 = new JScrollPane(textPane_1);
    scrollPane1.setBounds(150, 100, 420, 250);
    panel_1.add(scrollPane1);

    // panel_1.add(textPane_1);

    DefaultListModel listModel = new DefaultListModel();
    File[] files1 = new File("src/inbox").listFiles();
    for (File file : files1) {
      if (file.isFile())
        listModel.addElement((file.getName()).substring(0, (file.getName()).length() - 4));
    }

    JList list = new JList(listModel);
    list.setForeground(Color.BLACK);
    list.setBackground(Color.WHITE);

    // list.setBounds(10, 11, 112, 280);
    // panel_1.add(list);

    JScrollPane scrollPane = new JScrollPane(list);
    // scrollPane.setViewportView(list);
    scrollPane.setBounds(20, 11, 112, 340);
    panel_1.add(scrollPane);

    JLabel lblMessage = new JLabel("Message");
    lblMessage.setForeground(Color.BLACK);
    lblMessage.setBounds(175, 77, 79, 14);
    panel_1.add(lblMessage);

    JPanel panel = new JPanel();
    panel.setBackground(Color.WHITE);
    tabbedPane.addTab("Send Email", null, panel, null);
    panel.setLayout(null);

    JComboBox contactCombo = new JComboBox();
    contactCombo.setForeground(Color.BLACK);
    contactCombo.setBackground(Color.WHITE);
    contactCombo.setBounds(172, 21, 409, 20);
    panel.add(contactCombo);

    JLabel label = new JLabel("Message:");
    label.setForeground(Color.BLACK);
    label.setBounds(13, 117, 91, 14);
    panel.add(label);

    JTextPane messagePane = new JTextPane();
    messagePane.setBackground(Color.WHITE);
    messagePane.setForeground(Color.BLACK);
    messagePane.setBounds(10, 124, 539, 194);
    // panel.add(messagePane);

    JButton button_1 = new JButton("Send");
    button_1.setForeground(Color.BLACK);
    button_1.setBackground(Color.WHITE);
    button_1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            String to = contactCombo.getSelectedItem().toString();
            String subject = txtSubject.getText();
            Random rn = new Random();
            String ShareID = Integer.toString((new Random()).nextInt((999999999 - 100) + 1) + 100);
            System.out.println(ShareID);
            String from = "src/proxies/proxies.txt";
            String message = messagePane.getText();
            try {
              // if(selectedFileIn == true)
              System.out.println("sendmail1");
              SendMail.Distributor(to, ShareID, from, message, "", subject);
              System.out.println("sendmail2");
              // selectedFileIn = false;
            } catch (IOException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
            messagePane.setText("");
            contactCombo.repaint();
            attField.setText("");
            attField.removeAll();
          }
        });

    JScrollPane sP =
        new JScrollPane(
            messagePane,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    sP.setBounds(13, 142, 568, 194);
    panel.add(sP);
    button_1.setBounds(482, 346, 99, 23);
    panel.add(button_1);

    JLabel lblTo = new JLabel("To");
    lblTo.setForeground(Color.BLACK);
    lblTo.setBackground(Color.BLACK);
    lblTo.setBounds(116, 24, 46, 14);
    panel.add(lblTo);

    attField = new JTextField();
    attField.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {}
        });
    attField.setBounds(172, 52, 409, 20);
    panel.add(attField);
    attField.setColumns(10);

    JButton btnSearchButton = new JButton("Search");
    btnSearchButton.setBackground(Color.WHITE);
    btnSearchButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.showOpenDialog(frame);
            // fileChooser.setCurrentDirectory(new File(System.getProperty("src/")));
            selectedFile = fileChooser.getSelectedFile();
            attField.setText(selectedFile.getName());
            selectedFileIn = true;
            // selectedFile = fileChooser.getSelectedFile();
          }
        });
    btnSearchButton.setBounds(73, 51, 89, 23);
    panel.add(btnSearchButton);

    txtSubject = new JTextField();
    txtSubject.setBounds(172, 83, 409, 20);
    panel.add(txtSubject);
    txtSubject.setColumns(10);

    JLabel lblSubject = new JLabel("Subject");
    lblSubject.setForeground(Color.BLACK);
    lblSubject.setBackground(Color.BLACK);
    lblSubject.setBounds(116, 85, 46, 14);
    panel.add(lblSubject);

    JPanel panel_2 = new JPanel();
    panel_2.setBackground(Color.WHITE);
    tabbedPane.addTab("Add Contact", null, panel_2, null);
    panel_2.setLayout(null);

    JLabel lblEmailAddress = new JLabel("Email Address");
    lblEmailAddress.setForeground(Color.BLACK);
    lblEmailAddress.setBounds(75, 159, 72, 14);
    panel_2.add(lblEmailAddress);

    JTextPane proxyPane = new JTextPane();
    proxyPane.setForeground(Color.BLACK);
    proxyPane.setBackground(Color.LIGHT_GRAY);
    proxyPane.setBounds(157, 159, 298, 102);
    panel_2.add(proxyPane);

    JLabel lblContactName = new JLabel("Contact Name");
    lblContactName.setForeground(Color.BLACK);
    lblContactName.setBounds(69, 124, 72, 14);
    panel_2.add(lblContactName);

    contactField = new JTextField();
    contactField.setBackground(Color.LIGHT_GRAY);
    contactField.setColumns(10);
    contactField.setBounds(157, 121, 298, 20);
    panel_2.add(contactField);

    JButton btnAddContact = new JButton("Add Contact");
    btnAddContact.setBackground(Color.WHITE);
    btnAddContact.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            BufferedWriter output = null;
            // Add new contact
            String conName = contactField.getText();
            String allprox = proxyPane.getText();
            File conFile = new File("src/contacts/" + conName + ".txt");
            try {
              output = new BufferedWriter(new FileWriter(conFile));
              output.write(allprox);
              output.close();
            } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
    btnAddContact.setBounds(157, 301, 118, 23);
    panel_2.add(btnAddContact);

    // List<String> contacts = new ArrayList<String>();
    // comboBox.addItem("hg");
    File[] files = new File("src/contacts").listFiles();
    for (File file : files) {
      if (file.isFile())
        contactCombo.addItem((file.getName()).substring(0, (file.getName()).length() - 4));
    }
    list.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            String strbldr = "";
            String loc = "src/inbox/" + list.getSelectedValue().toString() + ".txt";
            try {
              BufferedReader buffread = new BufferedReader(new FileReader(loc));
              String line = buffread.readLine();
              while (line != null) {
                strbldr += line;
                strbldr += "\n";
                line = buffread.readLine();
              }
              buffread.close();
            } catch (Exception e) {
            }
            ;
            textPane_1.setText(strbldr);
            textPane_1.setCaretPosition(0);
          }
        });
    class Inner extends Thread {

      public void run() {

        do {
          System.out.println("Hello from a thread!");
          try {
            ReceiveMail.run();
            scrollPane.repaint();
            this.sleep(10000);
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        } while (true);
      }

      public void main(String args[]) {
        (new Inner()).start();
      }
    }
    Inner reloads = new Inner();
    reloads.start();
  }
Example #29
0
  void init() {

    /* ============
     *     Windows
     * ============ */

    this.setResizable(false);
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container con = this.getContentPane(); // inherit main frame
    con.add(panel); // add the panel to frame

    /* ============
     *     Menu
     * ============ */

    this.setIconImage(new ImageIcon("img/title_img.png").getImage());
    // Where the GUI is created:
    JMenuBar menuBar;
    JMenu menu;
    JMenuItem menuItem;

    // Create the menu bar.
    menuBar = new JMenuBar();

    // Build the first menu.
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_A);
    menuBar.add(menu);

    // a group of JMenuItems
    menuItem = new JMenuItem("About", new ImageIcon("img/about.png"));
    menu.add(menuItem);

    this.setJMenuBar(menuBar);

    /* ============
     *    Content
     * ============ */

    JLabel logo = new JLabel(new ImageIcon("img/title_img.png"));
    logo.setAlignmentX(CENTER_ALIGNMENT);
    final JTextField nickname = new JTextField();
    final Border defaultBorder = nickname.getBorder();

    nickname.setText("Enter a nickname");
    nickname.setPreferredSize(new Dimension(250, 30));
    nickname.setMaximumSize(nickname.getPreferredSize());
    nickname.setAlignmentX(CENTER_ALIGNMENT);

    // nickname.addFocusListener(this);
    nickname.addFocusListener(
        new FocusListener() {
          @Override
          public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub
            if (!nickname.getText().equals("Enter a nickname")) {
              nickname.setText(nickname.getText().replace(" ", ""));
            }

            if (nickname.getText().equals("") || nickname.getText().equals("Enter a nickname")) {
              nickname.setText("Enter a nickname");
              goodNickname = false;
            }
          }

          @Override
          public void focusGained(FocusEvent e) {
            // TODO Auto-generated method stub
            goodNickname = true;
          }
        });

    nickname.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub
            if (nickname.getText().equals("Enter a nickname")) {
              nickname.setText("");
              nickname.setBorder(defaultBorder);
            }
          }

          @Override
          public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }
        });

    final JButton connect = new JButton("Connect");
    connect.setPreferredSize(new Dimension(250, 30));
    connect.setMaximumSize(connect.getPreferredSize());
    connect.setAlignmentX(CENTER_ALIGNMENT);

    connect.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            if (goodNickname) {
              openChatGUI(nickname);
            } else {
              nickname.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.red));
            }
          }
        });

    nickname.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            if (goodNickname) {
              openChatGUI(nickname);
            } else {
              nickname.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.red));
            }
          }
        });

    panel.add(Box.createRigidArea(new Dimension(0, 15)));
    panel.add(logo);
    panel.add(Box.createRigidArea(new Dimension(0, 30)));
    panel.add(nickname);
    panel.add(Box.createRigidArea(new Dimension(0, 10)));
    panel.add(connect);

    setVisible(true); // display this frame
  }
  /** Create the panel. */
  public Receiveui(JFrame m, JPanel jp, LoginPO loginPO) {
    main = m;
    JPanel lastui = jp;
    Receiveui nowPanel = this;
    setLayout(null);
    ImageIcon image1 = new ImageIcon("image/transparent_circle.png");

    JButton button = new JButton("");
    button.setBounds(13, -9, 63, 63);
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.setIcon(image1);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            button.setIcon(new ImageIcon("image/mask_circle.png"));
          }
        });
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            main.remove(nowPanel);
            main.getContentPane().add(lastui);
            main.invalidate();
            main.repaint();
            main.setVisible(true);
          }
        });
    add(button);

    JLabel lblHello = new JLabel("Hello! " + loginPO.getName());
    lblHello.setForeground(Color.WHITE);
    lblHello.setBounds(655, 12, 100, 15);
    add(lblHello);

    JToolBar toolBar = new JToolBar();
    toolBar.setEnabled(false);
    toolBar.setBounds(8, 540, 750, 35);
    toolBar.setOpaque(false);
    toolBar.setBorder(null);
    add(toolBar);

    JLabel label_4 = new JLabel("״̬À¸");
    label_4.setForeground(Color.WHITE);
    toolBar.add(label_4);

    textField = new JTextField("ÊäÈë×°Ô˵¥±àºÅ");
    textField.setOpaque(false);
    textField.setBorder(null);
    textField.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 18));
    textField.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            label_4.setText("״̬À¸");
            if (!(Character.isDigit(e.getKeyChar()))) {
              e.consume();
            }
          }
        });
    textField.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            textField.setText("");
          }
        });
    textField.setBounds(205, 244, 347, 44);
    textField.setForeground(new Color(255, 255, 255, 200));
    textField.setCaretColor(new Color(248, 179, 28));
    add(textField);
    textField.setColumns(10);

    JButton button_1 = new JButton("");
    button_1.setContentAreaFilled(false);
    button_1.setBorderPainted(false);
    button_1.setBounds(349, 316, 52, 52);
    ImageIcon image2 = new ImageIcon("image/transparent_circle.png");
    @SuppressWarnings("static-access")
    Image temp1 =
        image2
            .getImage()
            .getScaledInstance(
                button_1.getWidth(), button_1.getHeight(), image2.getImage().SCALE_DEFAULT);
    image2 = new ImageIcon(temp1);
    button_1.setIcon(image2);
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (textField.getText().length() != 10) {
              label_4.setText("ÇëÊäÈëÕýÈ·×°Ô˵¥ºÅ");
            } else {
              ReceiveBLService rbs = new ReceiveBL();
              LoadorderVO lv = rbs.checkUnreceive_loadorderPO(textField.getText());
              if (lv == null) {
                label_4.setText("δ¼ì²âµ½¸Ã×°Ô˵¥");
              } else {
                Arriverorder a = new Arriverorder(main, nowPanel, lv, loginPO);
                main.remove(nowPanel);
                main.getContentPane().add(a);
                main.invalidate();
                main.repaint();
                main.setVisible(true);
              }
            }
          }
        });
    add(button_1);
  }