@Override
    public void keyPressed(KeyEvent e) {
        int keyCode = e.getKeyCode();

         if(keyCode == KeyEvent.VK_ENTER){
            final JDialog dialog = new JDialog();
            dialog.setTitle("Search results");
            dialog.setModal(true);
            int height = 40;
            
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();                     
            ArrayList list = DataLayer.search(zoekBalk.getText());
            panel.setLayout(new GridLayout(list.size(), 1));
            
            if(list.size() == 0){
                JOptionPane.showMessageDialog(null, zoekBalk.getText() + " kon niet gevonden worden/ bestaat niet!", "Niet gevonden", JOptionPane.INFORMATION_MESSAGE);
                //panel.add(new JLabel(zoekBalk.getText() + " kon niet gevonden worden/ bestaat niet!"));
            }else{
                for(int i = 0; i < list.size(); i++){
                    panel.add(new JLabel(list.get(i).toString()));
                    height = height + 20;
                }
                dialog.setPreferredSize(new Dimension(200, height));
                dialog.add(panel);
                dialog.pack();
                dialog.setLocationRelativeTo(null);
                dialog.setVisible(true);
                dialog.validate();
            }
        }
    }
 /* (non-Javadoc)
  * @see org.jajuk.ui.actions.JajukAction#perform(java.awt.event.ActionEvent)
  */
 @Override
 public void perform(ActionEvent evt) {
   final JEditorPane text = new JEditorPane("text/html", getTraces());
   text.setEditable(false);
   text.setMargin(new Insets(10, 10, 10, 10));
   text.setOpaque(true);
   text.setBackground(Color.WHITE);
   text.setForeground(Color.DARK_GRAY);
   text.setFont(FontManager.getInstance().getFont(JajukFont.BOLD));
   final JDialog dialog =
       new JDialog(JajukMainWindow.getInstance(), Messages.getString("DebugLogAction.0"), false);
   JButton jbCopy =
       new JButton(
           Messages.getString("DebugLogAction.2"),
           IconLoader.getIcon(JajukIcons.COPY_TO_CLIPBOARD));
   jbCopy.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           StringSelection data = new StringSelection(text.getText());
           Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
           clipboard.setContents(data, data);
         }
       });
   JButton jbRefresh =
       new JButton(Messages.getString("DebugLogAction.1"), IconLoader.getIcon(JajukIcons.REFRESH));
   jbRefresh.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           // Refresh traces
           text.setText(getTraces());
         }
       });
   JButton jbClose =
       new JButton(Messages.getString("Close"), IconLoader.getIcon(JajukIcons.CLOSE));
   jbClose.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           dialog.dispose();
         }
       });
   dialog.setLayout(new MigLayout("insets 10", "[grow]"));
   JScrollPane panel = new JScrollPane(text);
   UtilGUI.setEscapeKeyboardAction(dialog, panel);
   dialog.add(panel, "grow,wrap");
   dialog.add(jbCopy, "split 3,right,sg button");
   dialog.add(jbRefresh, "split 3,right,sg button");
   dialog.add(jbClose, "right,sg button");
   dialog.setPreferredSize(new Dimension(800, 600));
   dialog.pack();
   dialog.setLocationRelativeTo(JajukMainWindow.getInstance());
   dialog.setVisible(true);
 }
 @Override
 public void actionPerformed(CommandEvent event) {
   super.actionPerformed(event);
   final OpendapAccessPanel opendapAccessPanel =
       new OpendapAccessPanel(getAppContext(), event.getCommand().getHelpId());
   final JDialog jDialog = new JDialog(getAppContext().getApplicationWindow(), "OPeNDAP Access");
   jDialog.setContentPane(opendapAccessPanel);
   jDialog.pack();
   final Dimension size = jDialog.getSize();
   jDialog.setPreferredSize(size);
   jDialog.setVisible(true);
 }
 public static JDialog buildStudyWizardDialog(
     AddisWindow mainWindow, String title, AddStudyWizardPresentation pm) {
   JDialog dialog = new JDialog(mainWindow, title, true);
   AddStudyWizard wizard = new AddStudyWizard(pm, mainWindow, dialog);
   dialog.getContentPane().add(wizard);
   dialog.setMinimumSize(new Dimension(700, 550));
   dialog.setPreferredSize(AddisWindow.fitDimensionToScreen(790, 750));
   dialog.pack();
   WizardFrameCloser.bind(wizard, dialog);
   Main.bindPrintScreen(wizard);
   return dialog;
 }
 private JDialog getNotifyWindow() {
   if (NotifyWindow == null) {
     NotifyWindow = new JDialog();
     NotifyWindow.getContentPane().setLayout(null);
     NotifyWindow.setPreferredSize(new java.awt.Dimension(271, 138));
     NotifyWindow.getContentPane().add(getJLabel8());
     NotifyWindow.getContentPane().add(getJLabel9());
     NotifyWindow.getContentPane().add(getCloseButton());
     NotifyWindow.getContentPane().add(getJLabel10());
     NotifyWindow.setLocationRelativeTo(null);
     NotifyWindow.setSize(271, 138);
   }
   return NotifyWindow;
 }
 /**
  * Shows a {@link ScatterPlotPane}.
  *
  * @param parent parent component. Can be null
  * @param xAxisName name of the X-Axis
  * @param yAxisName name of the Y-Axis
  * @param chartData data to plot
  */
 public static void showDialog(
     Component parent, String xAxisName, String yAxisName, List<ScatterPlotData> chartData) {
   ScatterPlotPane scatterPlotPane = new ScatterPlotPane(parent, xAxisName, yAxisName, chartData);
   JDialog scatterPlotDialog = new JDialog();
   scatterPlotDialog.setContentPane(scatterPlotPane);
   scatterPlotDialog.setModalityType(ModalityType.APPLICATION_MODAL);
   scatterPlotDialog.setTitle("Scatter Plot");
   scatterPlotDialog.setIconImages(Images.getApplicationImages());
   scatterPlotDialog.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
   scatterPlotDialog.setMinimumSize(new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT));
   scatterPlotDialog.pack();
   scatterPlotDialog.setLocationRelativeTo(parent);
   scatterPlotDialog.setVisible(true);
   scatterPlotDialog.dispose();
 }
 public JDialog getAddDialog(AddisWindow mainWindow, Domain domain, ValueModel selectionModel) {
   JDialog dialog =
       new JDialog(mainWindow, "Create DerSimonian-Laird random effects meta-analysis", true);
   Wizard wizard =
       new PairwiseMetaAnalysisWizard(
           mainWindow,
           new PairWiseMetaAnalysisWizardPresentation(
               domain, mainWindow.getPresentationModelFactory()));
   dialog.getContentPane().add(wizard);
   dialog.setMinimumSize(new Dimension(700, 550));
   dialog.setPreferredSize(AddisWindow.fitDimensionToScreen(790, 650));
   dialog.pack();
   WizardFrameCloser.bind(wizard, dialog);
   Main.bindPrintScreen(wizard);
   return dialog;
 }
 private void pHtextButton4MouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_pHtextButton4MouseClicked
   PHprinter p = new PHprinter();
   p.setList(currentTabRef.getSelected());
   JDialog d = new JDialog(this, true);
   d.add(p);
   d.setPreferredSize(
       new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setMinimumSize(
       new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setMaximumSize(
       new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setSize(new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setLocationRelativeTo(this);
   d.setResizable(false);
   d.setVisible(true);
 } // GEN-LAST:event_pHtextButton4MouseClicked
  @SuppressWarnings("serial")
  public void showCredits() {
    dialog = new JDialog(parent, true);
    dialog.setUndecorated(true);

    final ScrollingLinesPanel panel = new ScrollingLinesPanel(image, lines);
    panel.setBorder(BorderFactory.createLineBorder(UIManager.getColor("Separator.foreground")));

    dialog.add(panel);
    dialog.pack();
    dialog.validate();
    dialog.setPreferredSize(panel.getPreferredSize());
    centerDialogLocation(dialog);

    Action scrollText =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            panel.incrementYPos();
            dialog.repaint();
          }
        };

    timer = new Timer(100, scrollText);

    dialog.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            hideCredits();
          }
        });

    Action cancelAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hideCredits();
          }
        };

    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), null, cancelAction);

    timer.start();
    dialog.setVisible(true);
  }
 private void formWindowClosing(
     java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowClosing
   PHclose p = new PHclose();
   p.setMainForm(this);
   JDialog d = new JDialog(this, true);
   d.add(p);
   d.setPreferredSize(
       new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setMinimumSize(
       new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setMaximumSize(
       new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setSize(new Dimension(p.getPreferredSize().width + 8, p.getPreferredSize().height + 32));
   d.setLocationRelativeTo(this);
   d.setResizable(false);
   d.setVisible(true);
   if (close == true) {
     dispose();
   }
 } // GEN-LAST:event_formWindowClosing
  public static void splash() {
    try {
      final BufferedImage img =
          ImageIO.read(Splash.class.getResourceAsStream("/path/to/your/splash/image/splash.png"));
      JDialog dialog =
          new JDialog() {

            @Override
            public void paint(Graphics g) {
              g.drawImage(img, 0, 0, null);
            }
          };
      // use the same size as your image
      dialog.setPreferredSize(new Dimension(450, 300));
      dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
      dialog.setUndecorated(true);
      dialog.pack();
      dialog.setLocationRelativeTo(null);
      dialog.setVisible(true);
      dialog.repaint();
      try {
        // Now, we are going to init the look and feel:

        Class uim = Class.forName("javax.swing.UIManager");
        uim.getDeclaredMethod("setLookAndFeel", String.class)
            .invoke(
                null, (String) uim.getDeclaredMethod("getSystemLookAndFeelClassName").invoke(null));

        // And now, we are going to invoke our loader method:
        Class clazz = Class.forName("yourpackage.YourClass");
        dialog.dispose();
        // suppose your method is called init and is static
        clazz.getDeclaredMethod("init").invoke(null);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      dialog.dispose();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
  public void showInitStoneDialog(Stone type) {
    JDialog diag = new JDialog(this);

    JPanel pan0 = new JPanel(new FlowLayout());

    JLabel lab0 = new JLabel(TXT_STT_0);
    JLabel labi = new JLabel(type.getIcon());
    JLabel lab1 = new JLabel(TXT_STT_1);

    pan0.add(lab0);
    pan0.add(labi);
    pan0.add(lab1);

    JPanel pan = new JPanel(new BorderLayout());

    final JDialog dig = diag;
    JButton button = new JButton(GAME_START_BUTTON);
    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dig.dispose();
            // Controler.startGame();
          }
        });

    pan.add(pan0, BorderLayout.CENTER);
    pan.add(button, BorderLayout.SOUTH);

    diag.add(pan);

    diag.setModal(true);
    diag.setLocationRelativeTo(null);
    diag.setPreferredSize(new Dimension(300, 200));
    diag.setSize(new Dimension(300, 200));
    diag.setVisible(true);
  }
    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals("Acties")) {
            controller.add(new Actiescreen());
        }

        if (e.getActionCommand().equals("Editmenu")) {
            JDialog dialog = new JDialog();
            dialog.setBounds(0, 0, 300, 500);

            dialog.add(new EditScreen(1));
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
        }

        if (e.getActionCommand().equals("Kalenderoverzicht")) {
            controller.add(new Kalenderscreen());
        }

        if (e.getActionCommand().equals("Gedachte toevoegen")) {
            JDialog dialog = new JDialog();
            dialog.setTitle("Gedachte Toevoegen");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            dialog.add(new EditScreen(2));
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Edit gedachte")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Edit gedachte");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField text = new JTextField();
            JButton button = new JButton("Toepassen");
            panel.add(text, BorderLayout.NORTH);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    String change = text.getText();
                    int gedachte = controller.getCurrentThought();
                    DataLayer.changeThought(gedachte, change);
                    dialog.setVisible(false);
                    controller.updateThouhts();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Gedachte omzetten naar actie")) {
            ArrayList<Projectscreen> test = controller.getProjects();
            if (test.get(0).getList().getSelectedIndex() == -1) {
                JOptionPane.showMessageDialog(null, "Selecteer eerst een gedachte", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
                final JDialog dialog = new JDialog();
                dialog.setPreferredSize(new Dimension(500, 200));
                dialog.setTitle("Gedachte omzetten naar actie");
                dialog.setModal(true);

                JPanel master = new JPanel();
                dialog.add(master);
                master.setLayout(new GridLayout(0, 1));

                // Project kiezen
                JPanel projects = new JPanel();
                projects.setLayout(new BorderLayout());
                JLabel projectnaam = new JLabel("Project");
                final JComboBox box = new JComboBox();
                final ArrayList<Projectscreen> arraylist = controller.getProjects();
                Projectscreen thoughts = arraylist.get(0);
                for (Projectscreen s : arraylist) {
                    if (!s.getNaam().equals("Gedachten")){
                    String naam = s.getNaam();
                    box.addItem(naam);
                    box.validate();
                    }
                }
                projects.add(projectnaam, BorderLayout.WEST);
                projects.add(box, BorderLayout.CENTER);
                master.add(projects);

                //gedachte
                JPanel gedachten = new JPanel();
                gedachten.setLayout(new BorderLayout());
                JLabel n = new JLabel("Gedachte: ");
                final JTextField n1 = new JTextField();
                final int id = controller.getCurrentThought();
                final JList list = thoughts.getList();
                final String s = (String) list.getSelectedValue();
                String[] s1 = s.split(" ");
                String s2 = s1[0];
                n1.setText(s.replaceFirst(s2, ""));
                n1.setText(n1.getText().trim());
                gedachten.add(n, BorderLayout.WEST);
                gedachten.add(n1, BorderLayout.CENTER);
                master.add(gedachten);

                // beschrijving
                JPanel beschrijving = new JPanel();
                beschrijving.setLayout(new BorderLayout());
                JLabel b = new JLabel("Beschrijving");
                final JTextArea b1 = new JTextArea(0, 3);
                b1.setLineWrap(true);
                b1.setRows(3);
                b1.setWrapStyleWord(true);
                b1.setColumns(0);
                JScrollPane scroll = new JScrollPane();
                scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                scroll.getViewport().setView(b1);
                beschrijving.add(b, BorderLayout.WEST);
                beschrijving.add(scroll, BorderLayout.CENTER);
                master.add(beschrijving);
                
                // context
                
                JPanel context = new JPanel();
                context.setLayout(new BorderLayout());
                JLabel co = new JLabel("Context");
                final JComboBox co1 = new JComboBox();
                co1.setEditable(true);
                final ArrayList<String> co2 = DataLayer.getContexts();
                if (!co2.isEmpty()){
                    for (String t : co2){
                        co1.addItem(t);
                    }
                }
                
                context.add(co, BorderLayout.WEST);
                context.add(co1, BorderLayout.CENTER);
                master.add(context);

                // status
                JPanel status = new JPanel();
                status.setLayout(new BorderLayout());
                JLabel st = new JLabel("Status");
                final JComboBox box1 = new JComboBox();
                ArrayList<String> arrayStatus = DataLayer.getStatuses();
                for (String t : arrayStatus) {
                    box1.addItem(t.toString());
                    box1.validate();
                }
                status.add(st, BorderLayout.WEST);
                status.add(box1, BorderLayout.CENTER);
                master.add(status);

                // datum
                JPanel datum = new JPanel();
                datum.setLayout(new BorderLayout());
                JLabel d = new JLabel("Datum");
                final JFormattedTextField d1 = new JFormattedTextField(new SimpleDateFormat("yyyy-mm-dd"));
                d1.setText("yyyy-mm-dd");
                datum.add(d, BorderLayout.WEST);
                datum.add(d1, BorderLayout.CENTER);
                master.add(datum);

                // button
                JButton toepassen = new JButton("Toepassen");
                master.add(toepassen);
                toepassen.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        String description = n1.getText();
                        String notes = b1.getText();
                        
                        String co3 = (String) co1.getSelectedItem();
                        boolean bestaat = false;
                        for (String t : co2){
                            if (t.equals(co3)){
                                bestaat = true;
                            }
                        }
                        
                        if (!bestaat){
                            DataLayer.addContext(co3);
                        }
                        
                        String context = co3;
                        String status = box1.getSelectedItem().toString();
                        int projectid = arraylist.get(box.getSelectedIndex()).getID() + 1;
                        String datum = d1.getText();
                        int idGedachte = Integer.parseInt("" + s.charAt(0)) - 1;

                        if (datum.equals("yyyy-mm-dd") | datum.equals("")) {
                            JOptionPane.showMessageDialog(null, "Vul een datum in", "Error", JOptionPane.ERROR_MESSAGE);
                        } else {
                            DataLayer.addAction(description, notes, context, status, projectid, datum);
                            DataLayer.deleteThought(idGedachte);
                            controller.updateThouhts();
                            controller.updateProjects();
                            dialog.setVisible(false);
                            ArrayList<Projectscreen> project = controller.getProjects();
                            Projectscreen t = project.get(0);
                            int i = t.getList().getModel().getSize();
                            int x = t.getList().getSelectedIndex();
                        }
                    }
                });

                dialog.pack();
                dialog.setLocationRelativeTo(null);
                dialog.setVisible(true);
                dialog.validate();
            }
        }

        if (e.getActionCommand().equals("Wis gedachte")) {
            DataLayer.deleteThought(controller.getCurrentThought());
            controller.updateThouhts();
        }

        if (e.getActionCommand().equals("Voeg project toe")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Project toevoegen");
            dialog.setModal(true);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField naam = new JTextField();

            JPanel projectnaam = new JPanel();
            projectnaam.setLayout(new BorderLayout());
            projectnaam.add(new JLabel("Projectnaam"), BorderLayout.WEST);
            projectnaam.add(naam, BorderLayout.CENTER);

            JButton button = new JButton("Aanmaken");
            panel.add(projectnaam, BorderLayout.NORTH);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    String e = DataLayer.addProject(naam.getText());
                    controller.updateProjects(e);
                    dialog.setVisible(false);
                    validate();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Bewerk project")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Bewerk project");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField naam = new JTextField();
            final JComboBox box = new JComboBox();
            box.setEditable(false);
            final ArrayList<Projectscreen> projects = controller.getProjects();
            projects.remove(0);
            for (Projectscreen t : projects) {
                box.addItem(t.getNaam());
                box.validate();
            }

            JPanel projectid = new JPanel();
            projectid.setLayout(new BorderLayout());
            projectid.add(new JLabel("Kies project"), BorderLayout.WEST);
            projectid.add(box, BorderLayout.CENTER);

            JPanel projectnaam = new JPanel();
            projectnaam.setLayout(new BorderLayout());
            projectnaam.add(new JLabel("Nieuwe projectnaam"), BorderLayout.WEST);
            projectnaam.add(naam, BorderLayout.CENTER);

            JButton button = new JButton("Bewerk");
            panel.add(projectid, BorderLayout.NORTH);
            panel.add(projectnaam, BorderLayout.CENTER);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    int d = box.getSelectedIndex();
                    projects.get(d).changeName(naam.getText());
                    DataLayer.changeProject(projects.get(d).getID(), naam.getText());
                    dialog.setVisible(false);
                    validate();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Verwijder project")) {
            final JDialog dialog = new JDialog();
            dialog.setTitle("Wis project");
            dialog.setModal(true);
            dialog.setBounds(0, 0, 300, 500);

            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            final JTextField naam = new JTextField();

            final JComboBox box = new JComboBox();
            box.setEditable(false);
            final ArrayList<Projectscreen> projects = controller.getProjects();
            projects.remove(0);
            for (Projectscreen t : projects) {
                box.addItem(t.getNaam());
                box.validate();
            }

            JPanel projectnaam = new JPanel();
            projectnaam.setLayout(new BorderLayout());
            projectnaam.add(new JLabel("Project"), BorderLayout.WEST);
            projectnaam.add(box, BorderLayout.CENTER);

            JButton button = new JButton("Wissen");
            panel.add(projectnaam, BorderLayout.NORTH);
            panel.add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    //pj.deleteProject(naam.getText(), id.getNumber().intValue()); 
                    int d = box.getSelectedIndex();
                    projects.get(d).changeName(naam.getText());
                    DataLayer.deleteProject(projects.get(d).getID());
                    controller.updateIDprojects(d);
                    dialog.setVisible(false);
                    validate();
                }
            });

            dialog.add(panel);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            dialog.validate();
        }

        if (e.getActionCommand().equals("Uitloggen")) {
            controller.logOff();
        }

        if (e.getActionCommand().equals("Afsluiten")) {
            controller.quit();
        }
    }
Exemple #14
0
  /**
   * Construct the GUI for a logger.
   *
   * @param titleMessage for the title bar of the dialog box
   * @param width initial width of the resizeable dialog box
   * @param height initial height of the resizeable dialog box
   * @param exitApplicationOnClose if true, when the dialog box is closed (X-d out), will exit the
   *     application with success status
   * @param visible if true, will be made visible after construction
   */
  protected void createGUI(
      String titleMessage, int width, int height, boolean exitApplicationOnClose, boolean visible) {
    Border panelBorder = BorderFactory.createEtchedBorder();

    outputTextArea = new JTextArea();
    {
      // if one does not do this, the default behavior is scroll to end when append() on event
      // disptaching thread, but not from other threads
      Caret caret = outputTextArea.getCaret();
      if (caret != null && caret instanceof DefaultCaret) {
        ((DefaultCaret) caret)
            .setUpdatePolicy(
                DefaultCaret
                    .ALWAYS_UPDATE); // i.e. jump to end after append() regardless of whether in
                                     // same thread or not
      }
    }
    outputScrollPane = new JScrollPane(outputTextArea);
    outputScrollPane.setBorder(panelBorder);

    outputDialog = new JDialog();
    // outputDialog.setSize(width,height);
    outputDialog.setPreferredSize(new Dimension(width, height));
    outputDialog.setTitle(titleMessage);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.setBorder(panelBorder);

    JButton clearButton = new JButton("Clear");
    clearButton.setToolTipText("Clear log");
    buttonPanel.add(clearButton);
    clearButton.addActionListener(new ClearActionListener());

    Container mainPanel = outputDialog.getContentPane();
    {
      GridBagLayout mainPanelLayout = new GridBagLayout();
      mainPanel.setLayout(mainPanelLayout);
      {
        GridBagConstraints outputScrollPaneConstraints = new GridBagConstraints();
        outputScrollPaneConstraints.gridx = 0;
        outputScrollPaneConstraints.gridy = 0;
        outputScrollPaneConstraints.weightx = 1;
        outputScrollPaneConstraints.weighty = 1;
        outputScrollPaneConstraints.fill = GridBagConstraints.BOTH;
        mainPanelLayout.setConstraints(outputScrollPane, outputScrollPaneConstraints);
        mainPanel.add(outputScrollPane);
      }
      {
        GridBagConstraints buttonPanelConstraints = new GridBagConstraints();
        buttonPanelConstraints.gridx = 0;
        buttonPanelConstraints.gridy = 1;
        buttonPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        mainPanelLayout.setConstraints(buttonPanel, buttonPanelConstraints);
        mainPanel.add(buttonPanel);
      }
    }

    outputDialog.pack();
    outputDialog.setVisible(visible);

    if (exitApplicationOnClose) {
      // Note that unlike for JFrame, EXIT_ON_CLOSE is NOT a valid value to pass to
      // setDefaultCloseOperation(), so have to do this with WindowListener
      outputDialog.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              // System.err.println("DialogMessageLogger.WindowAdapter.windowClosing()");
              // dispose();
              System.exit(0);
            }
          });
    }
  }
Exemple #15
0
  /**
   * @param main
   * @param type
   */
  public GraphIso2(Bats main, String type) {
    this.main = main;
    this.data = main.data;
    h1 = Setting.getInt("/bat/general/font/h1");
    p = Setting.getInt("/bat/general/font/p");
    ft = Setting.getString("/bat/general/font/type");
    fTitel = new Font(ft, Font.PLAIN, h1);
    fAxes = new Font(ft, Font.PLAIN, p);
    fText = new Font(ft, Font.PLAIN, p);
    x = Setting.getString("/bat/isotope/graph/" + type + "/x_value");
    y = Setting.getString("/bat/isotope/graph/" + type + "/y_value");
    dataType = Setting.getString("/bat/isotope/graph/" + type + "/data");
    try {
      x_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/x_value")
              .getAttribute("multi")
              .getIntValue();
      y_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/y_value")
              .getAttribute("multi")
              .getIntValue();
    } catch (DataConversionException e) {
      x_multi = 1;
      y_multi = 1;
    }

    JLabel textLabel = new JLabel("Isobar correction on radioisotope:", JLabel.LEFT);
    textLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);

    JLabel textLabel2 =
        new JLabel(Setting.getString("/bat/isotope/graph/" + type + "/unit"), JLabel.LEFT);
    textLabel2.setAlignmentX(Component.RIGHT_ALIGNMENT);

    nf.setOverwriteMode(false);
    nf.setMinimum(0.000);
    textField = new JFormattedTextField(nf);
    try {
      textField.setValue(data.corrList.get(0).isoFact);
    } catch (IndexOutOfBoundsException e) {
      log.debug("Could not set isobar factor.");
    }
    textField.setColumns(5); // get some space

    textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField.selectAll();
                } else
                  try { // The text is valid,
                    textField.commitEdit(); // so use it.
                    fieldChange();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    textField2 = new JFormattedTextField(nf);
    textField2.setValue(data.corrList.get(0).isoErr);
    textField2.setColumns(5); // get some space

    textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField2
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField2.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField2.selectAll();
                } else
                  try { // The text is valid,
                    textField2.commitEdit(); // so use it.
                    fieldChange2();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    JPanel labelAndText = new JPanel();
    labelAndText.add(textLabel);
    labelAndText.add(textField);
    labelAndText.add(new JLabel("±"));
    labelAndText.add(textField2);
    labelAndText.add(textLabel2);

    JPanel regPane = new JPanel();
    regPane.add(new JLabel("slope: "));
    NumberFormatter nf = new NumberFormatter(new DecimalFormat("0.00E00"));
    slopeField = new JFormattedTextField(nf);
    slopeField.setPreferredSize(new Dimension(80, 20));
    slopeField.setEditable(false);
    regPane.add(slopeField);
    slopeErrField = new JFormattedTextField(nf);
    slopeErrField.setPreferredSize(new Dimension(80, 20));
    slopeErrField.setEditable(false);
    regPane.add(slopeErrField);
    regPane.add(new JLabel("R^2: "));
    nf = new NumberFormatter(new DecimalFormat("0.00E0"));
    rField = new JFormattedTextField(nf);
    rField.setPreferredSize(new Dimension(60, 20));
    rField.setEditable(false);
    regPane.add(rField);
    this.makeReg();

    JPanel regTextPanel = new JPanel(new GridLayout(1, 2));
    regTextPanel.add(labelAndText);
    regTextPanel.add(regPane);

    JPanel controlPanel = new JPanel(new GridLayout(1, 1));
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.PAGE_AXIS));
    controlPanel.setBorder(BorderFactory.createEmptyBorder(30, 10, 5, 10));
    controlPanel.add(regTextPanel);

    JDialog frame = new JDialog();
    frame.setModal(true);
    frame.setTitle("Correction");
    frame.setPreferredSize(
        new Dimension(
            Setting.getInt("/bat/general/frame/correction/width"),
            Setting.getInt("/bat/general/frame/correction/height")));
    frame.add(controlPanel, BorderLayout.SOUTH);
    dataSet = Func.getXY(data.get(dataType), null, x, y, x_multi, y_multi);
    chart = createChart(dataSet);
    frame.add(new ChartPanel(chart));
    frame.addWindowListener(this);
    frame.pack();
    frame.setVisible(true);
  }
  int showOpenDialog(final boolean sa) {

    dialog = new JDialog(frame, JDialog.ModalityType.APPLICATION_MODAL);
    // dialog.setUndecorated(false);

    saveAs = sa;

    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            dialog.dispose();
          }
        });

    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    driver.curDiag.filterOptions[0] = fCParms.title;
    cBox = new MyComboBox(driver.curDiag.filterOptions);
    cBox.setMaximumRowCount(2);
    cBox.addMouseListener(this);
    cBox.setSelectedIndex(driver.allFiles ? 1 : 0);

    order = new Vector<Component>(9);
    order.add(text);
    order.add(butParent);
    order.add(butNF);
    order.add(panel); // just a place-holder - will be filled in by
    // buildList
    order.add(text2);
    order.add(butCopy);
    order.add(butOK);
    order.add(cBox);
    order.add(butDel);
    order.add(butCancel);

    text.setEditable(true);
    text.setEnabled(true);

    // text.getDocument().addDocumentListener(this);

    text2.setEditable(true);
    text2.setEnabled(true);
    text2.setRequestFocusEnabled(true);
    // text2.addKeyListener(this);
    // text2.getDocument().addDocumentListener(this);
    text2.setPreferredSize(new Dimension(100, driver.fontHeight + 2));

    text3.setEditable(false);
    text3.setEnabled(true);
    // text3.setRequestFocusEnabled(true);
    text3.setFont(driver.fontg.deriveFont(Font.ITALIC));
    // text3.setPreferredSize(new Dimension(100, driver.fontHeight + 2));

    String s = (saveAs) ? "Save or Save As" : "Open File";
    comp = new MyFileCompare();
    renderer = new ListRenderer(driver);

    if (fCParms == driver.curDiag.fCPArr[DrawFBP.DIAGRAM]) dialog.setTitle(s);
    else {
      if (fCParms == driver.curDiag.fCPArr[DrawFBP.GENCODE])
        fCParms.prompt =
            "Specify file name for generated code - for diagram: " + driver.curDiag.title + ".drw";

      dialog.setTitle(fCParms.prompt);
      if (fCParms == driver.curDiag.fCPArr[DrawFBP.CLASS]) listShowingJarFile = listHead;
    }

    enterAction = new EnterAction();
    copyAction = new CopyAction();
    cancelAction = new CancelAction();
    deleteAction = new DeleteAction();

    parentAction = new ParentAction();
    newFolderAction = new NewFolderAction();

    butParent.setAction(parentAction);
    butParent.setText("Parent Folder");
    butParent.setMnemonic(KeyEvent.VK_P);

    butNF.setAction(newFolderAction);
    butNF.setMnemonic(KeyEvent.VK_N);
    butNF.setText("New Folder");

    // butOK.setAction(okAction);
    butOK.setAction(enterAction);
    butCopy.setAction(copyAction);
    butCancel.setAction(cancelAction);
    butDel.setAction(deleteAction);

    butParent.setRequestFocusEnabled(true);
    butNF.setRequestFocusEnabled(true);
    butCopy.setRequestFocusEnabled(true);

    text.addMouseListener(this);
    text2.addMouseListener(this);

    panel.setPreferredSize(new Dimension(600, 600));

    text.setFocusTraversalKeysEnabled(false);
    butParent.setFocusTraversalKeysEnabled(false);
    butNF.setFocusTraversalKeysEnabled(false);
    text2.setFocusTraversalKeysEnabled(false);
    butOK.setFocusTraversalKeysEnabled(false);
    butDel.setFocusTraversalKeysEnabled(false);
    butCancel.setFocusTraversalKeysEnabled(false);
    butCopy.setFocusTraversalKeysEnabled(false);

    butParent.setEnabled(true);
    butNF.setEnabled(true);
    butOK.setEnabled(true);
    // butCopy.setEnabled(saveAs);
    butCopy.setEnabled(true);
    butCancel.setEnabled(true);
    butDel.setEnabled(true);

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escape, "CLOSE");

    panel.getActionMap().put("CLOSE", cancelAction);

    JLabel label = new JLabel("Current folder: ");
    label.setFont(driver.fontg);

    Box box0 = new Box(BoxLayout.Y_AXIS);
    Box box1 = new Box(BoxLayout.X_AXIS);

    box1.add(label);

    box1.add(Box.createRigidArea(new Dimension(12, 0)));
    box1.add(text);
    box1.add(Box.createRigidArea(new Dimension(6, 0)));

    box1.add(butParent);
    // butParent.addActionListener(this);
    box1.add(Box.createRigidArea(new Dimension(6, 0)));

    // butNF.addActionListener(this);
    box1.add(butNF);

    box0.add(Box.createRigidArea(new Dimension(0, 20)));
    box0.add(box1);

    box0.add(Box.createRigidArea(new Dimension(0, 20)));
    panel.add(box0, BorderLayout.NORTH);

    text.setFont(label.getFont());
    text.addActionListener(this);
    text2.addActionListener(this);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;

    JPanel pan2 = new JPanel();

    pan2.setLayout(gridbag);
    // c.fill = GridBagConstraints.BOTH;

    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.0;

    JLabel lab1 = new JLabel("File name: ");
    gridbag.setConstraints(lab1, c);
    pan2.add(lab1);

    c.gridx = 1;
    c.weightx = 0.0;
    JLabel lab5 = new JLabel("  ");
    gridbag.setConstraints(lab5, c);
    pan2.add(lab5);

    c.gridx = 2;

    c.weightx = saveAs ? 0.1 : 1.0;
    c.gridwidth = saveAs ? 1 : 3;
    // c.ipadx  = saveAs ? -20: 0;
    gridbag.setConstraints(text2, c);
    pan2.add(text2);

    if (saveAs) {
      c.gridx = 3;
      c.weightx = 0.0;
      c.gridwidth = 1;
      JLabel lab6 = new JLabel("   Suggestion: ");
      gridbag.setConstraints(lab6, c);
      pan2.add(lab6);

      c.gridx = 4;
      c.weightx = 0.9;
      // c.ipadx = 20;
      gridbag.setConstraints(text3, c);
      pan2.add(text3);
      text3.setBackground(Color.WHITE);
      Dimension dim = text3.getPreferredSize();
      text3.setPreferredSize(new Dimension(driver.fontWidth * 25, dim.height));
    }

    c.gridx = 5;
    c.weightx = 0.0;
    JLabel lab7 = new JLabel("  ");
    gridbag.setConstraints(lab7, c);
    pan2.add(lab7);

    c.gridx = 6;
    c.weightx = 0.0;

    if (saveAs) {
      c.gridwidth = 1;
      gridbag.setConstraints(butCopy, c);
      pan2.add(butCopy);

      c.gridx = 7;
      c.weightx = 0.0;

      c.gridwidth = 1;
    } else c.gridwidth = 2;
    gridbag.setConstraints(butOK, c);
    pan2.add(butOK);

    c.weightx = 0.0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;

    JLabel lab2 = new JLabel("Files of type:");
    gridbag.setConstraints(lab2, c);
    pan2.add(lab2);

    c.gridx = 1;
    c.weightx = 0.0;
    JLabel lab8 = new JLabel("  ");
    gridbag.setConstraints(lab8, c);
    pan2.add(lab8);

    c.gridx = 2;
    c.weightx = 1.0;
    c.gridwidth = 3;
    gridbag.setConstraints(cBox, c);
    pan2.add(cBox);
    cBox.addActionListener(this);

    c.gridx = 5;
    c.weightx = 0.0;
    c.gridwidth = 1;
    JLabel lab9 = new JLabel("  ");
    gridbag.setConstraints(lab9, c);
    pan2.add(lab9);

    c.gridx = 6;
    c.weightx = 0.0;
    gridbag.setConstraints(butDel, c);
    pan2.add(butDel);

    c.gridx = 7;
    c.weightx = 0.0;
    gridbag.setConstraints(butCancel, c);
    pan2.add(butCancel);

    butOK.setText("OK");
    butOK.setFont(driver.fontg.deriveFont(Font.BOLD));
    butCancel.setText("Cancel");
    butDel.setText("Delete");
    butCopy.setText(saveAs ? "Use suggested name" : "");

    JLabel lab3 = new JLabel();
    lab3.setPreferredSize(new Dimension(500, 30));
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 4;
    c.weightx = 1.0;
    gridbag.setConstraints(lab3, c);
    pan2.add(lab3);

    cBox.addActionListener(this);

    // cBox.setUI(new BasicComboBoxUI());
    cBox.setRenderer(new ComboBoxRenderer());

    Dimension dim = new Dimension(1000, 800);
    dialog.setPreferredSize(dim);

    dialog.setFocusTraversalKeysEnabled(false);
    text.addKeyListener(this);
    text2.addKeyListener(this);
    butParent.addKeyListener(this); // needed to service tab keys
    butNF.addKeyListener(this); // needed to service tab keys
    butOK.addKeyListener(this); // needed to service tab keys
    cBox.addKeyListener(this); // needed to service tab keys
    butDel.addKeyListener(this); // needed to service tab keys
    butCancel.addKeyListener(this); // needed to service tab keys
    butCopy.addKeyListener(this); // needed to service tab keys
    cBox.setFocusTraversalKeysEnabled(false);
    mtp = new MyTraversalPolicy();
    setFocusTraversalPolicy(mtp);
    setFocusCycleRoot(false);

    showList();
    if (saveAs) {

      if (suggestedName != null && !(suggestedName.equals(""))) {
        File h = new File(suggestedName);
        listHead = h.getParent();
        text.setText(listHead);
        text2.setText(h.getName());
        text3.setText(h.getName());

        /*
        SwingUtilities.invokeLater(new Runnable() {
        	public void run() {
        		text2.requestFocusInWindow();
        		selComp = text2;
        		text2.setBackground(vLightBlue);
        	}
        });

        */

        text2.addAncestorListener(new RequestFocusListener(false));
        selComp = text2;
        // text2.setBackground(vLightBlue);
        // text2.setEditable(true);
      }

      if (driver.curDiag.title != null && driver.curDiag.diagFile != null) {
        s += " (current file: " + driver.curDiag.diagFile.getAbsolutePath() + ")";
      }
    } else {
      text.setText(listHead);
      /*
      SwingUtilities.invokeLater(new Runnable() {
      	public void run() {
      		list.requestFocusInWindow();
      		selComp = list;
      		// list.setBackground(vLightBlue);
      	}
      });
      */
      // list.addAncestorListener( new RequestFocusListener() );
      selComp = list;
    }

    panel.add(pan2, BorderLayout.SOUTH);
    dialog.add(panel);

    dialog.pack();
    dialog.setLocation(200, 100);
    frame.pack();

    dialog.setVisible(true);

    // if (!saveAs)
    // textBackground = Color.WHITE;

    frame.repaint();

    return result;
  }