Пример #1
0
  public JPanel demo(Graph g, final String label) {
    // create a new radial tree view
    final PhysioMapRadialGraphView gview =
        new PhysioMapRadialGraphView(settings, g, label, semsimmodel);
    Visualization vis = gview.getVisualization();

    // create a search panel for the tree map
    SearchQueryBinding sq =
        new SearchQueryBinding(
            (Table) vis.getGroup(treeNodes),
            label,
            (SearchTupleSet) vis.getGroup(Visualization.SEARCH_ITEMS));
    JSearchPanel search = sq.createSearchPanel();
    search.setShowResultCount(true);
    search.setBorder(BorderFactory.createEmptyBorder(5, 5, 4, 0));
    search.setFont(FontLib.getFont("Verdana", Font.PLAIN, 11));

    final JTextArea title = new JTextArea();
    title.setPreferredSize(new Dimension(450, 500));
    title.setMaximumSize(new Dimension(450, 500));
    title.setMinimumSize(new Dimension(450, 500));

    title.setAlignmentY(CENTER_ALIGNMENT);
    title.setLineWrap(true);
    title.setWrapStyleWord(true);
    title.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
    title.setFont(FontLib.getFont("Verdana", Font.PLAIN, 11));

    gview.addControlListener(
        new ControlAdapter() {
          public void itemEntered(VisualItem item, MouseEvent e) {}

          public void itemExited(VisualItem item, MouseEvent e) {
            title.setText(null);
          }
        });

    Box searchbox = new Box(BoxLayout.X_AXIS);
    searchbox.add(Box.createHorizontalStrut(10));
    searchbox.add(search);
    searchbox.add(Box.createHorizontalStrut(3));

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(searchbox, BorderLayout.NORTH);
    panel.add(gview, BorderLayout.CENTER);
    panel.add(Box.createGlue(), BorderLayout.SOUTH);

    Color BACKGROUND = Color.WHITE;
    Color FOREGROUND = Color.DARK_GRAY;
    UILib.setColor(panel, BACKGROUND, FOREGROUND);

    return panel;
  }
Пример #2
0
 private GUIRunner() {
   imageLabel = new JLabel();
   textArea = new JTextArea();
   textArea.setEditable(false);
   textArea.setMaximumSize(new Dimension(400, 200));
   Container panel = new JPanel();
   panel.setLayout(new FlowLayout());
   panel.add(imageLabel);
   panel.add(textArea);
   setTitle("ZXing");
   setSize(400, 400);
   setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   setContentPane(panel);
   setLocationRelativeTo(null);
 }
  /** initComponents */
  public void initComponents() {
    mainPanel = new JPanel();
    emailPanel = new JPanel();
    passwordPanel = new JPanel();
    buttonPanel = new JPanel();

    // Box layout so that all components are stacked vertically
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    emailPanel.setLayout(new BoxLayout(emailPanel, BoxLayout.X_AXIS));
    passwordPanel.setLayout(new BoxLayout(passwordPanel, BoxLayout.X_AXIS));
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));

    emailLabel = new JLabel("E-mail Address: ");
    emailTextArea = new JTextArea();
    emailTextArea.setMaximumSize(new Dimension(300, emailTextArea.getMinimumSize().height));

    emailPanel.add(emailLabel);
    emailPanel.add(emailTextArea);

    passwordLabel = new JLabel("Password:"******"Back");
    loginButton = new JButton("Login");

    buttonPanel.add(backButton);
    buttonPanel.add(loginButton);

    mainPanel.add(Box.createVerticalStrut(20));
    mainPanel.add(emailPanel);
    mainPanel.add(passwordPanel);
    mainPanel.add(buttonPanel);

    // Set the panel the the contentpane of the frame
    getContentPane().add(mainPanel);

    // Close form when you click the X
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    pack();
  }
Пример #4
0
    @SuppressWarnings("unchecked") // we must be compatible with 1.6
    public VersionManagementPanel(final VisualCanvas canvas) {

      super(canvas);

      setLayout(new GridLayout());

      // TODO @Christian Poliwoda what does manual testing mean?
      // numbers tested manually
      Dimension prefScrollPaneDim = new Dimension(100, 30);
      Dimension visibleRectDim = canvas.getVisibleRect().getSize();

      final VersionController controller =
          canvas.getProjectController().getProject().getProjectFile();

      final int numVersions = controller.getNumberOfVersions() - 1;

      versionData = new Object[numVersions];

      ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

      try {
        versions = controller.getVersions();
      } catch (IOException ex) {
        Logger.getLogger(VersionManagementPanel.class.getName()).log(Level.SEVERE, null, ex);
      }

      int maxTextwidth = 0;
      String longestText = null;

      // the history with timestamp and a short commit message
      for (int i = 1; i < versions.size(); i++) {
        String text =
            // + Message.generateHTMLSpace(3)
            new Date(versions.get(i).getCommitTime() * 1000L)
                + ": "
                + versions.get(i).getShortMessage();

        // truncate texts that are too long
        int maxTextLength = 100;
        String dots = "...";

        int textLength = text.length() - dots.length();

        if (textLength > maxTextLength) {
          text = text.substring(0, maxTextLength) + dots;
        }

        versionData[versions.size() - i - 1] = new Version(text, i);

        if (text.length() > maxTextwidth) {
          maxTextwidth = text.length();
          longestText = text;
        }
      }

      resultModel = new DefaultListModel();

      // first init to show all if search not started yet
      for (int i = 0; i < versionData.length; i++) {
        resultModel.addElement(versionData[i]);
      }

      versionList = new JList(resultModel);

      // set the width of version managment window
      // dependent on largest git short message length
      double maxFontWidth =
          versionList
              .getFontMetrics(versionList.getFont())
              .getStringBounds(longestText, versionList.getGraphics())
              .getWidth();

      if (maxFontWidth <= visibleRectDim.width) {

        prefScrollPaneDim.width = (int) maxFontWidth;
      } else {

        if (visibleRectDim.width < 400) {
          prefScrollPaneDim.width = visibleRectDim.width;
        } else {
          prefScrollPaneDim.width = 400;
        }
      }

      versionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      versionList.setOpaque(false);

      versionList.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      versionList.setBorder(new EmptyBorder(3, 3, 3, 3));

      Box upperTopBox = Box.createVerticalBox();

      // press the commits to top with VerticalGlue
      // contains search area at top and
      // search results at the botton
      Box upperOuterBox = Box.createVerticalBox();

      JButton searchButton = new JButton("search");
      searchButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
              searchAndAddToResultList();
            }
          });

      searchField = new JTextArea();

      // search area box
      Box upperBox1 = Box.createHorizontalBox();

      upperBox1.add(searchField);
      upperBox1.add(searchButton);

      Dimension fieldDim = new Dimension(Short.MAX_VALUE, searchField.getPreferredSize().height);
      searchField.setMaximumSize(fieldDim);

      searchField.addKeyListener(
          new KeyAdapter() {
            String tmp = "";

            @Override
            public void keyReleased(KeyEvent ke) {

              searchAndAddToResultList();
            }
          });

      //            upperOuterBox.add(upperBox1);
      upperTopBox.add(upperBox1);
      upperTopBox.add(upperOuterBox);

      // result area box
      Box upperBox2 = Box.createHorizontalBox();

      upperBox2.add(Box.createHorizontalGlue());
      upperBox2.add(versionList);
      upperBox2.add(Box.createHorizontalGlue());

      upperOuterBox.add(upperBox2);
      upperOuterBox.add(Box.createVerticalGlue());

      // added for optical reasons to force correct scrollbar position
      Box upperInnerBorderPane = Box.createHorizontalBox();
      upperInnerBorderPane.add(upperOuterBox);
      upperInnerBorderPane.setBorder(new EmptyBorder(5, 15, 5, 15));
      upperInnerBorderPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);

      VScrollPane upperScrollPane = new VScrollPane(upperInnerBorderPane);
      upperScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setMinimumSize(prefScrollPaneDim);

      JSplitPane splitPane = new VSplitPane(JSplitPane.VERTICAL_SPLIT);
      splitPane.setEnabled(true); // true = transparent
      splitPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      splitPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      splitPane.setDividerLocation(0.5);

      upperTopBox.add(upperScrollPane);
      splitPane.add(upperTopBox); // add in the upper part

      htmlCommit.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      htmlCommit.setContentType("text/html");
      htmlCommit.setOpaque(false);
      htmlCommit.setEditable(false);
      htmlCommit.setBorder(new EmptyBorder(0, 15, 0, 15));

      Box lowerBox = Box.createVerticalBox();
      lowerBox.setAlignmentX(Component.LEFT_ALIGNMENT);
      lowerBox.add(htmlCommit);
      lowerBox.add(Box.createVerticalGlue());

      VScrollPane lowerScrollPane = new VScrollPane(lowerBox);

      lowerScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      lowerScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      lowerScrollPane.setMinimumSize(new Dimension(0, 0));

      // add in the lower part
      splitPane.setBottomComponent(lowerScrollPane);

      add(splitPane);

      versionList.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {

              // show commit message in lower part if clicked on a row
              // in upper part
              if (e.getClickCount() == 1) {

                final VersionController controller =
                    canvas.getProjectController().getProject().getProjectFile();

                final int numVersions = controller.getNumberOfVersions() - 1;

                ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

                try {
                  versions = controller.getVersions();
                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }

                int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                htmlCommit.setText(
                    "<html>"
                        + "<pre> <font color=white><br>"
                        + "<b>SHA-1:</b> "
                        + versions.get(versionIndex).getName()
                        + "<br><br>"
                        + "<b>Message:</b><br><br>"
                        + versions.get(versionIndex).getFullMessage()
                        + "</pre></p>"
                        + "</html>");
                htmlCommit.setCaretPosition(0);
              }

              if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {

                if (((Version) versionList.getSelectedValue()).getVersion() < 2) {
                  VDialog.showMessageDialog(
                      canvas,
                      "Cannot Load Version",
                      "The first version in a project contains no"
                          + " sessions and cannot be loaded!");
                  return;
                }

                //                        if (VDialog.showConfirmDialog(canvas,
                //                                "Checkout Version:",
                //                                "<html><div align=Center>"
                //                                + "<p>Do you want to checkout the selected"
                //                                + " version?<p>"
                //                                + "<p><b>Unsaved changes will be lost!</b></p>"
                //                                + "</div></html>",
                //                                VDialog.DialogType.YES_NO) != VDialog.YES) {
                //                            return;
                //                        }

                int answer =
                    VDialog.showConfirmDialog(
                        canvas,
                        "Checkout Version:",
                        "<html><div align=Center>"
                            + "<p>Checking out selected version.<p><br>"
                            + "<p>Do you want to save the current session?</p><br>"
                            + "<p><b>Unsaved changes will be lost!</b></p>"
                            + "</div></html>",
                        new String[] {"Save", "Discard", "Cancel"});

                if (answer == 0) {
                  try {
                    canvas.getProjectController().saveProject(false);
                  } catch (IOException ex) {
                    Logger.getLogger(VersionManagement.class.getName()).log(Level.SEVERE, null, ex);

                    VDialog.showMessageDialog(
                        canvas,
                        "Cannot save Project:",
                        "<html><div align=Center>" + "Project cannot be saved!" + "</div></html>");
                  }
                } else if (answer == 1) {
                  // nothing to do
                } else if (answer == 2) {
                  return;
                }

                try {

                  int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                  canvas.setActive(false);

                  String currentSessionName = canvas.getProjectController().getCurrentSession();

                  canvas.getProjectController().close(currentSessionName);

                  controller.checkoutVersion(versionIndex);

                  if (dialog != null) {
                    dialog.close();
                    dialog = null;
                  }

                  if (canvas
                      .getProjectController()
                      .getProject()
                      .getSessionFileByEntryName(currentSessionName)
                      .exists()) {
                    canvas.getProjectController().open(currentSessionName, false, true);
                  } else {
                    //                                VDialog.showMessageDialog(canvas,
                    //                                        "Cannot load \""
                    //                                        + currentSessionName
                    //                                        +"\":", "<html><div align=Center>"
                    //                                        + "<p>The Session "
                    //                                        + Message.EMPHASIZE_BEGIN
                    //                                        + currentSessionName
                    //                                         +  Message.EMPHASIZE_END
                    //                                        + " does not exist in the current"
                    //                                        + " version."
                    //                                        + "<p>The <b>Main</b>-Session will"
                    //                                        + "be loaded instead</div></html>");
                    canvas.getProjectController().open("Main", false, true);
                  }

                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }
              }
            }
          });

      //            setMinimumSize(visibleRectDim);
      setMaximumSize(visibleRectDim);

      int width = getPreferredSize().width;
      setPreferredSize(new Dimension(width, (int) (visibleRectDim.height * 0.5)));
    } // end constructure
Пример #5
0
  private JPanel buildMainContentPane() {
    JPanel backPanel = new JPanel();
    backPanel.setSize(600, 400);
    backPanel.setLayout(new BoxLayout(backPanel, BoxLayout.Y_AXIS));
    backPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
    // mainPanel.setBorder(BorderFactory.createEmptyBorder(0,0,20,0));
    final JTextArea textArea = new JTextArea("Type your troll text here");
    textArea.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent arg0) {}

          @Override
          public void keyReleased(KeyEvent arg0) {
            if (autoupdate) destinationGUI.setTextCenter(textArea.getText());
          }

          @Override
          public void keyPressed(KeyEvent arg0) {}
        });
    textArea.setPreferredSize(new Dimension(260, 200));
    textArea.setMaximumSize(new Dimension(260, 200));
    textArea.setMinimumSize(new Dimension(260, 200));
    mainPanel.add(textArea);

    JPanel settingsPanel = new JPanel();
    settingsPanel.setSize(150, 220);
    settingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));

    // CheckBox - Mise à jour auto du texte
    JCheckBox autoUpdateCB = new JCheckBox("Mise à jour auto du texte");
    autoUpdateCB.setSelected(autoupdate);
    autoUpdateCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdate = !autoupdate;
          }
        });
    autoUpdateCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateCB);

    // CheckBox - Mise à jour auto de la couleur du texte
    JCheckBox autoUpdateTextColorCB = new JCheckBox("Mise à jour auto de la couleur du texte");
    autoUpdateTextColorCB.setSelected(autoupdateTextColor);
    autoUpdateTextColorCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateTextColor = !autoupdateTextColor;
          }
        });
    autoUpdateTextColorCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateTextColorCB);

    // CheckBox - Mise à jour auto de la couleur d'arri�re plan
    JCheckBox autoUpdateBackgroundColorCB =
        new JCheckBox("Mise à jour auto de la couleur d'arrière-plan");
    autoUpdateBackgroundColorCB.setSelected(autoupdateBackgroundColor);
    autoUpdateBackgroundColorCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateBackgroundColor = !autoupdateBackgroundColor;
          }
        });
    autoUpdateBackgroundColorCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateBackgroundColorCB);

    // Checkbox - MAJ auto de la taille du texte
    JCheckBox autoUpdateTextSizeCB = new JCheckBox("Mise à jour auto de la taille du texte");
    autoUpdateTextSizeCB.setSelected(autoupdateTextSize);
    autoUpdateTextSizeCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateTextSize = !autoupdateTextSize;
          }
        });
    autoUpdateTextSizeCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateTextSizeCB);

    // Chekbox - fullscreen on second Screen
    JCheckBox fullscreenCB = new JCheckBox("Activer le plein écran sur le deuxième écran");
    fullscreenCB.setSelected(fullscreen);
    fullscreenCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            fullscreen = !fullscreen;
          }
        });
    fullscreenCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(fullscreenCB);

    JPanel backgroundColorPanel = new JPanel();
    backgroundColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final JPanel backgroundColorPreviewPanel = new JPanel();
    backgroundColorPreviewPanel.setMaximumSize(new Dimension(50, 25));
    backgroundColorPreviewPanel.setPreferredSize(new Dimension(50, 25));
    backgroundColorPreviewPanel.setBackground(backgroundColor);

    JButton backgroundColorButton = new JButton("Choisir la couleur d'arrière-plan");
    backgroundColorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            Color newColor =
                JColorChooser.showDialog(colorChooser, "Couleur d'arrière-plan", backgroundColor);
            if (newColor != null) {
              backgroundColor = newColor;
              backgroundColorPreviewPanel.setBackground(backgroundColor);
              if (autoupdateBackgroundColor) destinationGUI.setBackgroundColor(backgroundColor);
            }
          }
        });
    backgroundColorPanel.add(backgroundColorPreviewPanel);
    backgroundColorPanel.add(backgroundColorButton);
    backgroundColorPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(backgroundColorPanel);

    JPanel textColorPanel = new JPanel();
    textColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final JPanel textColorPreviewPanel = new JPanel();
    textColorPreviewPanel.setMaximumSize(new Dimension(50, 25));
    textColorPreviewPanel.setPreferredSize(new Dimension(50, 25));
    textColorPreviewPanel.setBackground(textColor);

    JButton textColorButton = new JButton("Choisir la couleur du texte");
    textColorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            Color newColor = JColorChooser.showDialog(colorChooser, "Couleur du texte", textColor);
            if (newColor != null) {
              textColor = newColor;
              textColorPreviewPanel.setBackground(textColor);
              if (autoupdateTextColor) destinationGUI.setTextColor(textColor);
            }
          }
        });

    textColorPanel.add(textColorPreviewPanel);
    textColorPanel.add(textColorButton);
    textColorPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(textColorPanel);

    colorChooser = new JColorChooser();

    SpinnerModel textSizeSpinnerModel = new SpinnerNumberModel(textSize, 1, 300, 1);
    final JSpinner textSizeSpinner = new JSpinner(textSizeSpinnerModel);
    textSizeSpinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            if ((int) textSizeSpinner.getValue() != textSize) {
              textSize = (int) textSizeSpinner.getValue();
              if (autoupdateTextSize) destinationGUI.setTextSize(textSize);
            }
          }
        });
    JPanel textSizePanel = new JPanel();
    textSizePanel.setMaximumSize(new Dimension(300, 60));
    textSizePanel.setPreferredSize(new Dimension(300, 30));
    textSizePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    textSizePanel.setAlignmentX(LEFT_ALIGNMENT);
    JLabel textSizeLabel = new JLabel("Taille du texte");
    textSizeSpinner.setMaximumSize(new Dimension(45, 20));
    textSizePanel.add(textSizeLabel);
    textSizePanel.add(textSizeSpinner);
    JLabel screenLabel = new JLabel("Second écran");
    Integer[] screens = {0, 1};
    JComboBox<Integer> screenComboBox = new JComboBox<Integer>(screens);
    screenComboBox.setSelectedIndex(Main.secondScreen);
    screenComboBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            JComboBox<Integer> cb = (JComboBox<Integer>) e.getSource();
            if (cb.getSelectedItem().equals(0)) {
              Main.mainScreen = 1;
              Main.secondScreen = 0;
            } else {
              Main.mainScreen = 0;
              Main.secondScreen = 1;
            }
          }
        });
    screenComboBox.setMaximumSize(new Dimension(45, 20));
    textSizePanel.add(screenLabel);
    textSizePanel.add(screenComboBox);

    settingsPanel.add(textSizePanel);
    mainPanel.add(settingsPanel);
    backPanel.add(mainPanel);

    // RAINBOW PANEL
    JPanel rainbowPanel = new JPanel();
    rainbowPanel.setMinimumSize(new Dimension(50, 40));
    rainbowPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
    final JButton rainbowButton = new JButton("Activer le Rainbow Mode");
    rainbowButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // rainbow mode is already activated :
            // stopping it...
            if (destinationGUI.isRainbowEnabled()) {
              destinationGUI.stopTimer();
              destinationGUI.setTextColor(textColor);
              destinationGUI.setBackgroundColor(backgroundColor);
              rainbowButton.setText("Activer le Rainbow Mode");
            }
            // Rainbow Mode is stopped :
            // starting it...
            else {
              destinationGUI.startTimer();
              rainbowButton.setText("Désactiver le Rainbow Mode");
            }
          }
        });

    JLabel epilepticLabel = new JLabel("Mode épileptique");
    final JCheckBox epilepticCheckBox = new JCheckBox();
    epilepticCheckBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            destinationGUI.setEpileptic(epilepticCheckBox.isSelected());
          }
        });
    JLabel speedLabel = new JLabel("Vitesse");
    final JSlider speedSlider =
        new JSlider(SwingConstants.HORIZONTAL, SPEED_MIN, SPEED_MAX, SPEED_INIT);
    speedSlider.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            if (!speedSlider.getValueIsAdjusting()) {
              destinationGUI.setSpeed(speedSlider.getValue());
            }
          }
        });
    destinationGUI.setSpeed(SPEED_INIT);
    speedSlider.setPreferredSize(new Dimension(100, 30));

    rainbowPanel.add(rainbowButton);
    rainbowPanel.add(speedLabel);
    rainbowPanel.add(speedSlider);
    rainbowPanel.add(epilepticLabel);
    rainbowPanel.add(epilepticCheckBox);
    backPanel.add(rainbowPanel);

    // BOTTOM PANEL
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 10));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
    JButton updateButton = new JButton("Mettre à jour les modifications");
    updateButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            destinationGUI.setTextCenter(textArea.getText().replaceAll("\n", "<br>"));
            destinationGUI.setTextColor(textColor);
            destinationGUI.setBackgroundColor(backgroundColor);
            destinationGUI.setTextSize(textSize);
          }
        });
    bottomPanel.add(updateButton);

    final JButton secondScreen = new JButton("Envoyer sur le second écran");
    secondScreen.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gd = ge.getScreenDevices();
            // Ramener sur le premier ecran
            if (isOnSecondScreen) {
              secondScreen.setText("Envoyer sur le second écran");
              showDestGUIOnScreen(Main.mainScreen);
              isOnSecondScreen = false;
              if (wasFullscreen) {
                quitFullscreen();
                destinationGUI = new GUI();
                destinationGUI.setTextCenter(textArea.getText());
                destinationGUI.setTextColor(textColor);
                destinationGUI.setBackgroundColor(backgroundColor);
                destinationGUI.setTextSize(textSize);
              }
            }
            // Envoyer sur le deuxieme ecran
            else {
              if (Main.protection && gd.length <= 1) {
                System.out.println("Erreur : Pas de second écran trouve");
                return;
              }
              showDestGUIOnScreen(Main.secondScreen);
              secondScreen.setText("Ramener sur le premier écran");
              isOnSecondScreen = true;
              wasFullscreen = fullscreen;
            }
          }
        });

    bottomPanel.add(secondScreen);
    bottomPanel.setAlignmentX(CENTER_ALIGNMENT);

    destinationGUI.setTextSize(textSize);
    destinationGUI.setTextColor(textColor);
    destinationGUI.setBackgroundColor(backgroundColor);
    destinationGUI.setTextCenter(textArea.getText());

    backPanel.add(bottomPanel);
    return backPanel;
  }
Пример #6
0
  public MemoryEpisodeDisplay(MemoryEpisode episode) {
    _numberOfDetails = 0;

    _panel = new JPanel();
    _panel.setBorder(BorderFactory.createEtchedBorder());
    _panel.setLayout(new BoxLayout(_panel, BoxLayout.Y_AXIS));
    _panel.setMaximumSize(new Dimension(750, 250));
    _panel.setMinimumSize(new Dimension(750, 250));

    Dimension d1 = new Dimension(100, 20);
    Dimension d2 = new Dimension(100, 100);
    Dimension d3 = new Dimension(115, 80);

    JPanel pnl = new JPanel();
    pnl.setLayout(new BoxLayout(pnl, BoxLayout.X_AXIS));
    pnl.setMaximumSize(new Dimension(750, 100));

    // ABSTRACT
    /*JPanel aux = new JPanel();
    aux.setLayout(new BoxLayout(aux,BoxLayout.Y_AXIS));
    aux.setMaximumSize(d2);
    aux.setMinimumSize(d2);
    aux.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
    JLabel lbl = new JLabel("Abstract");
    lbl.setMaximumSize(d1);
    lbl.setMinimumSize(d1);
    aux.add(lbl);*/

    // _abstract = new JTextArea(episode.getAbstract());
    /*_abstract = new JTextArea("");
    _abstract.setLineWrap(true);
    _abstract.setMaximumSize(d3);
    _abstract.setMinimumSize(d3);
    aux.add(_abstract);
    pnl.add(aux);*/

    // TIME
    JPanel aux = new JPanel();
    aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS));
    aux.setMaximumSize(d2);
    aux.setMinimumSize(d2);
    aux.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    JLabel lbl = new JLabel("Time");
    lbl.setMaximumSize(d1);
    lbl.setMinimumSize(d1);
    aux.add(lbl);
    _time = new JTextArea(episode.getTime().toString());
    _time.setLineWrap(true);
    _time.setMaximumSize(d3);
    _time.setMinimumSize(d3);
    aux.add(_time);
    pnl.add(aux);

    // PEOPLE
    aux = new JPanel();
    aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS));
    aux.setMaximumSize(d2);
    aux.setMinimumSize(d2);
    aux.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl = new JLabel("People");
    lbl.setMaximumSize(d1);
    lbl.setMinimumSize(d1);
    aux.add(lbl);
    _people = new JTextArea(episode.getPeople().toString());
    _people.setLineWrap(true);
    _people.setMaximumSize(d3);
    _people.setMinimumSize(d3);
    aux.add(_people);
    pnl.add(aux);

    // LOCATION
    aux = new JPanel();
    aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS));
    aux.setMaximumSize(d2);
    aux.setMinimumSize(d2);
    aux.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl = new JLabel("Location");
    lbl.setMaximumSize(d1);
    lbl.setMinimumSize(d1);
    aux.add(lbl);
    _location = new JTextArea(episode.getLocation().toString());
    _location.setLineWrap(true);
    _location.setMaximumSize(d3);
    _location.setMinimumSize(d3);
    aux.add(_location);
    pnl.add(aux);

    // OBJECTS
    aux = new JPanel();
    aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS));
    aux.setMaximumSize(d2);
    aux.setMinimumSize(d2);
    aux.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl = new JLabel("Objects");
    lbl.setMaximumSize(d1);
    lbl.setMinimumSize(d1);
    aux.add(lbl);
    _objects = new JTextArea(episode.getObjects().toString());
    _objects.setLineWrap(true);
    _objects.setMaximumSize(d3);
    _objects.setMinimumSize(d3);
    aux.add(_objects);
    pnl.add(aux);

    _panel.add(pnl);

    // DETAILS
    _details = new JPanel();
    _details.setBorder(BorderFactory.createTitledBorder("Details"));
    _details.setLayout(new BoxLayout(_details, BoxLayout.Y_AXIS));

    aux = new JPanel();
    aux.setLayout(new BoxLayout(aux, BoxLayout.X_AXIS));
    aux.setMinimumSize(new Dimension(750, 30));
    aux.setMaximumSize(new Dimension(750, 30));

    lbl = new JLabel("ID");
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(30, 30));
    lbl.setMaximumSize(new Dimension(30, 30));
    aux.add(lbl);

    /*lbl = new JLabel("Ca.");
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
    lbl.setMinimumSize(new Dimension(30,30));
    lbl.setMaximumSize(new Dimension(30,30));
    aux.add(lbl);

    lbl = new JLabel("Eff.");
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
    lbl.setMinimumSize(new Dimension(30,30));
    lbl.setMaximumSize(new Dimension(30,30));
    aux.add(lbl);*/

    lbl = new JLabel("Subject"); // Who?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(50, 30));
    lbl.setMaximumSize(new Dimension(50, 30));
    aux.add(lbl);

    lbl = new JLabel("Action"); // What?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Intention"); // Goal?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Target"); // Whom?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Status"); // Activation, Success, Failure?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Meaning"); // Which speechAct?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Path"); // Multimedia directory
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Object"); // object/third person
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Desirability"); // Desirable?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    lbl = new JLabel("Praiseworthiness"); // Praiseworthy?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(80, 30));
    lbl.setMaximumSize(new Dimension(80, 30));
    aux.add(lbl);

    /*lbl = new JLabel("Parameters"); // How?
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
    lbl.setMinimumSize(new Dimension(100,30));
    lbl.setMaximumSize(new Dimension(100,30));
    aux.add(lbl);*/

    lbl = new JLabel("Feeling");
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(100, 30));
    lbl.setMaximumSize(new Dimension(100, 30));
    aux.add(lbl);

    lbl = new JLabel("Location");
    lbl.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    lbl.setMinimumSize(new Dimension(100, 30));
    lbl.setMaximumSize(new Dimension(100, 30));
    aux.add(lbl);

    _details.add(aux);

    JPanel prop = new JPanel();
    prop.setLayout(new BoxLayout(prop, BoxLayout.Y_AXIS));
    prop.setMaximumSize(new Dimension(750, 150));
    prop.setMinimumSize(new Dimension(750, 150));

    JScrollPane propertiesScroll = new JScrollPane(prop);

    ListIterator<ActionDetail> li = episode.getDetails().listIterator();
    while (li.hasNext()) {
      prop.add(new MemoryDetailPanel((ActionDetail) li.next()));
      _numberOfDetails++;
    }

    _details.add(propertiesScroll);

    _panel.add(_details);
  }
Пример #7
0
  /** Create the dialog. */
  private void init() {
    setBounds(100, 100, 550, 450);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
      JPanel panelTop = new JPanel();
      FlowLayout flowLayout = (FlowLayout) panelTop.getLayout();
      flowLayout.setAlignment(FlowLayout.LEADING);
      contentPanel.add(panelTop, BorderLayout.NORTH);
      {
        JLabel lblIcondistributer = new JLabel(IconFactory.DISTRIBUTOR48_ICON);
        panelTop.add(lblIcondistributer);
      }
      {
        JLabel lblProductForm = new JLabel("Distributor:");
        lblProductForm.setFont(new Font("Tahoma", Font.BOLD, 14));
        panelTop.add(lblProductForm);
      }

      lblProductname = new JLabel("ProductName");
      lblProductname.setFont(new Font("Tahoma", Font.PLAIN, 14));
      panelTop.add(lblProductname);
    }
    {
      {
        JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        tabbedPane.setFont(new Font("Tahoma", Font.PLAIN, 14));
        contentPanel.add(tabbedPane, BorderLayout.CENTER);
        {
          JPanel panelMain = new JPanel();
          tabbedPane.addTab("Main", null, panelMain, null);
          panelMain.setLayout(null);

          JLabel lblName = new JLabel("Name");
          lblName.setFont(new Font("Tahoma", Font.PLAIN, 16));
          lblName.setBounds(10, 27, 46, 14);
          panelMain.add(lblName);

          txtName = new JTextField();
          txtName.setFont(new Font("Tahoma", Font.PLAIN, 14));
          txtName.setBounds(119, 22, 191, 25);
          panelMain.add(txtName);
          txtName.setColumns(10);
        }
        {
          JPanel panelAlias = new JPanel();
          tabbedPane.addTab("Alias", null, panelAlias, null);
          panelAlias.setLayout(new BorderLayout(0, 0));

          JToolBar toolBar = new JToolBar();
          panelAlias.add(toolBar, BorderLayout.NORTH);

          JButton btnAdd = new JButton(IconFactory.ADD24_ICON);
          btnAdd.addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent arg0) {
                  DistributorAliasForm dialog =
                      new DistributorAliasForm(
                          DistributorForm.this.getOwner(),
                          "",
                          new DistributorAlias(),
                          DistributorForm.this);
                  dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                  dialog.setVisible(true);
                }
              });

          toolBar.add(btnAdd);

          JButton btnEdit = new JButton(IconFactory.EDIT24_ICON);
          btnEdit.addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent arg0) {

                  DistributorAlias alias = aliasList.getSelectedValue();
                  if (alias != null) {
                    DistributorAliasForm dialog =
                        new DistributorAliasForm(
                            DistributorForm.this.getOwner(), "", alias, DistributorForm.this);
                    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                    dialog.setVisible(true);
                  }
                }
              });

          toolBar.add(btnEdit);

          JButton btnRemove = new JButton(IconFactory.DELETE24_ICON);
          toolBar.add(btnRemove);

          aliasList = new JList<DistributorAlias>();
          aliasList.setBorder(new MatteBorder(1, 0, 0, 0, (Color) Color.LIGHT_GRAY));
          panelAlias.add(aliasList);
        }
        {
          JPanel panelCharacteristic = new JPanel();
          tabbedPane.addTab("Characteristic", null, panelCharacteristic, null);
          panelCharacteristic.setLayout(null);

          JLabel lblColumnCount = new JLabel("Column count");
          lblColumnCount.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblColumnCount.setBounds(10, 11, 120, 20);
          panelCharacteristic.add(lblColumnCount);

          JLabel lblIdColumn = new JLabel("ID Column");
          lblIdColumn.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblIdColumn.setBounds(10, 42, 120, 20);
          panelCharacteristic.add(lblIdColumn);

          JLabel lblPriceColumn = new JLabel("Price Column");
          lblPriceColumn.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblPriceColumn.setBounds(10, 73, 120, 20);
          panelCharacteristic.add(lblPriceColumn);

          txtColumnCount = new JTextField();
          txtColumnCount.setBounds(140, 13, 86, 20);
          panelCharacteristic.add(txtColumnCount);
          txtColumnCount.setColumns(10);

          txtColumnId = new JTextField();
          txtColumnId.setColumns(10);
          txtColumnId.setBounds(140, 44, 86, 20);
          panelCharacteristic.add(txtColumnId);

          txtColumnPrice = new JTextField();
          txtColumnPrice.setColumns(10);
          txtColumnPrice.setBounds(140, 75, 86, 20);
          panelCharacteristic.add(txtColumnPrice);

          JLabel lblArtistColumn = new JLabel("Artist Column");
          lblArtistColumn.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblArtistColumn.setBounds(10, 104, 120, 20);
          panelCharacteristic.add(lblArtistColumn);

          txtArtist = new JTextField();
          txtArtist.setColumns(10);
          txtArtist.setBounds(140, 106, 86, 20);
          panelCharacteristic.add(txtArtist);

          JLabel lblTrackColumn = new JLabel("Track Column");
          lblTrackColumn.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblTrackColumn.setBounds(10, 137, 120, 20);
          panelCharacteristic.add(lblTrackColumn);

          txtTrack = new JTextField();
          txtTrack.setColumns(10);
          txtTrack.setBounds(140, 139, 86, 20);
          panelCharacteristic.add(txtTrack);

          JLabel lblTrackType = new JLabel("Track type");
          lblTrackType.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblTrackType.setBounds(10, 168, 120, 20);
          panelCharacteristic.add(lblTrackType);

          txtType = new JTextField();
          txtType.setColumns(10);
          txtType.setBounds(140, 170, 86, 20);
          panelCharacteristic.add(txtType);

          txtColumnquantity = new JTextField();
          txtColumnquantity.setColumns(10);
          txtColumnquantity.setBounds(396, 13, 86, 20);
          panelCharacteristic.add(txtColumnquantity);

          JLabel lblColumnQuantity = new JLabel("Column quantity");
          lblColumnQuantity.setFont(new Font("Tahoma", Font.PLAIN, 14));
          lblColumnQuantity.setBounds(266, 11, 120, 20);
          panelCharacteristic.add(lblColumnQuantity);
        }
      }
    }
    {
      JTextArea txtrComment = new JTextArea();
      txtrComment.setFont(new Font("Monospaced", Font.PLAIN, 14));
      txtrComment.setMaximumSize(new Dimension(4, 16));
      // contentPanel.add(txtrComment, BorderLayout.SOUTH);
      txtrComment.setMargin(new Insets(10, 10, 2, 2));
      txtrComment.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
      txtrComment.setRows(3);

      JScrollPane scrollPaneComment = new JScrollPane();
      scrollPaneComment.setBorder(new EmptyBorder(5, 0, 0, 0));
      scrollPaneComment.setViewportView(txtrComment);

      contentPanel.add(scrollPaneComment, BorderLayout.SOUTH);
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("OK", IconFactory.OK_ICON);
        okButton.setActionCommand("OK");
        okButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent arg0) {
                if (txtName.getText() == "") {
                  JOptionPane.showMessageDialog(null, "You can't save empty name");
                } else {
                  pushDataToProduct();
                  listener.saveDistributor(distributor);
                  dispose();
                }
              }
            });
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
      {
        JButton cancelButton = new JButton("Cancel", IconFactory.CANCEL_ICON);
        cancelButton.setActionCommand("Cancel");
        cancelButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent arg0) {
                dispose();
              }
            });
        buttonPane.add(cancelButton);
      }
    }
  }
  public void setUpLeftPanel() {
    leftPanel.removeAll();

    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    leftPanel.setAlignmentX(LEFT_ALIGNMENT);
    leftPanel.setBorder(Constants.PADDING);

    leftTitle = new WhiteLabel("Create a New Part");
    leftTitle.setFont(new Font("Arial", Font.PLAIN, 20));
    leftTitle.setLabelSize(300, 40);
    leftTitle.setAlignmentX(0);
    leftPanel.add(leftTitle);

    JPanel namePanel = new JPanel();
    namePanel.setBorder(Constants.TOP_PADDING);
    namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.LINE_AXIS));
    namePanel.setOpaque(false);
    namePanel.setVisible(true);
    namePanel.setAlignmentX(0);
    leftPanel.add(namePanel);

    WhiteLabel nameLabel = new WhiteLabel("Name");
    nameLabel.setLabelSize(100, 25);
    namePanel.add(nameLabel);

    nameField = new JTextField("name");

    nameField.setMaximumSize(new Dimension(200, 25));
    nameField.setBorder(Constants.FIELD_PADDING);
    namePanel.add(nameField);

    JPanel numPanel = new JPanel();
    numPanel.setBorder(Constants.TOP_PADDING);
    numPanel.setLayout(new BoxLayout(numPanel, BoxLayout.LINE_AXIS));
    numPanel.setOpaque(false);
    numPanel.setVisible(true);
    numPanel.setAlignmentX(0);
    leftPanel.add(numPanel);

    WhiteLabel numLabel = new WhiteLabel("Part no.");
    numLabel.setLabelSize(100, 25);
    numPanel.add(numLabel);

    numField = new WhiteLabel("" + (rightPanel.getItemList().size() + 1));
    numField.setMaximumSize(new Dimension(200, 25));
    numField.setBorder(Constants.FIELD_PADDING);
    numPanel.add(numField);

    JPanel descPanel = new JPanel();
    descPanel.setBorder(Constants.TOP_PADDING);
    descPanel.setLayout(new BoxLayout(descPanel, BoxLayout.LINE_AXIS));
    descPanel.setOpaque(false);
    descPanel.setVisible(true);
    descPanel.setAlignmentX(0);
    leftPanel.add(descPanel);

    WhiteLabel descLabel = new WhiteLabel("Description");
    descLabel.setLabelSize(100, 25);
    descPanel.add(descLabel);

    descField = new JTextArea("Description...");
    descField.setMinimumSize(new Dimension(200, 70));
    descField.setMaximumSize(new Dimension(200, 70));
    descField.setPreferredSize(new Dimension(200, 70));
    descField.setBorder(Constants.FIELD_PADDING);
    descPanel.add(descField);

    JPanel chancePanel = new JPanel();
    chancePanel.setBorder(Constants.TOP_PADDING);
    chancePanel.setLayout(new BoxLayout(chancePanel, BoxLayout.LINE_AXIS));
    chancePanel.setOpaque(false);
    chancePanel.setVisible(true);
    chancePanel.setAlignmentX(0);
    leftPanel.add(chancePanel);

    WhiteLabel chanceLabel = new WhiteLabel("Defect Chance");
    chanceLabel.setLabelSize(100, 25);
    chancePanel.add(chanceLabel);

    badChanceScroller = new JSlider(JSlider.HORIZONTAL, CHANCE_MIN, CHANCE_MAX, CHANCE_INIT);
    badChanceScroller.setMajorTickSpacing(50);
    badChanceScroller.setMinorTickSpacing(5);
    badChanceScroller.setPaintTicks(true);
    badChanceScroller.setPaintLabels(true);
    badChanceScroller.setFont(new Font("Arial", Font.PLAIN, 14));
    badChanceScroller.setForeground(Color.WHITE);
    badChanceScroller.setOpaque(false);
    chancePanel.add(badChanceScroller);

    imagePanel = new JPanel();
    imagePanel.setBorder(Constants.TOP_PADDING);
    imagePanel.setLayout(new BoxLayout(imagePanel, BoxLayout.LINE_AXIS));
    imagePanel.setOpaque(false);
    imagePanel.setAlignmentX(0);
    leftPanel.add(imagePanel);

    imageLabel = new WhiteLabel("Select Image ");
    imageLabel.setLabelSize(100, 60);
    imagePanel.add(imageLabel);

    imageSelectPanel = new JPanel();
    imageSelectPanel.setBackground(new Color(0, 0, 0, 0));

    // Iterate through the ArrayList of available images in constants to
    // populate JScrollPane

    for (String imagePath : Constants.DEFAULT_IMAGEPATHS) {
      ClickablePanel imageSelectClickable = new ClickablePanel(new ImageClickHandler(imagePath));
      JLabel imageSelectLabel =
          new JLabel(new ImageIcon(Constants.PART_IMAGE_PATH + imagePath + ".png"));
      imageSelectLabel.setMinimumSize(new Dimension(50, 30));
      imageSelectLabel.setPreferredSize(new Dimension(50, 30));
      imageSelectLabel.setMaximumSize(new Dimension(50, 30));

      imageSelectClickable.add(imageSelectLabel);
      imageSelectClickable.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      imageSelectClickable.setMinimumSize(new Dimension(50, 30));
      imageSelectClickable.setPreferredSize(new Dimension(50, 30));
      imageSelectClickable.setMaximumSize(new Dimension(50, 30));

      imageSelectPanel.add(imageSelectClickable);
      imageClickablePanels.put(imagePath, imageSelectClickable);
      imageSelectPanel.setOpaque(false);
    }

    imageSelect = new JScrollPane(imageSelectPanel);
    imageSelect.setMinimumSize(new Dimension(250, 60));
    imageSelect.setPreferredSize(new Dimension(250, 60));
    imageSelect.setMaximumSize(new Dimension(250, 60));
    // imageSelect.setOpaque(false);
    imageSelect.setBorder(null);
    imageSelect.setOpaque(false);
    imageSelect.getViewport().setOpaque(false);
    imagePanel.add(imageSelect);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBorder(Constants.TOP_PADDING);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setOpaque(false);
    buttonPanel.setVisible(true);
    buttonPanel.setAlignmentX(0);
    leftPanel.add(buttonPanel);

    if (isEditing || isDeleting) {
      JButton cancelButton = new JButton("Cancel");
      cancelButton.setMinimumSize(new Dimension(100, 25));
      cancelButton.setMaximumSize(new Dimension(100, 25));
      cancelButton.setPreferredSize(new Dimension(100, 25));
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              restoreLeftPanel();
            }
          });
      buttonPanel.add(cancelButton);
    } else {
      WhiteLabel fakeLabel = new WhiteLabel("");
      fakeLabel.setLabelSize(100, 25);
      buttonPanel.add(fakeLabel);
    }

    submitButton = new JButton("Submit >");
    submitButton.setMinimumSize(new Dimension(200, 25));
    submitButton.setMaximumSize(new Dimension(200, 25));
    submitButton.setPreferredSize(new Dimension(200, 25));
    submitButton.setAlignmentX(0);
    buttonPanel.add(submitButton);

    removeAllActionListener(submitButton);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO try to remove this hack
            float chance = (float) badChanceScroller.getValue();

            PartType newPart =
                new PartType(
                    nameField.getText(),
                    Integer.parseInt(numField.getText()),
                    descField.getText(),
                    chance / 100);
            newPart.setImagePath(selectedImagePath);
            manager.createPart(newPart);
            restoreLeftPanel();
          }
        });
  }
Пример #9
-1
  /**
   * Shows a dialog request to enter text in a multiline text field <br>
   * Though not all text might be visible, everything entered is delivered with the returned text
   * <br>
   * The main purpose for this feature is to allow pasting text from somewhere preserving line
   * breaks <br>
   *
   * @param msg the message to display.
   * @param title the title for the dialog (default: Sikuli input request)
   * @param lines the maximum number of lines visible in the text field (default 9)
   * @param width the maximum number of characters visible in one line (default 20)
   * @return The user's input including the line breaks.
   */
  public static String inputText(String msg, String title, int lines, int width) {
    width = Math.max(20, width);
    lines = Math.max(9, lines);
    if ("".equals(title)) {
      title = "Sikuli input request";
    }
    JTextArea ta = new JTextArea("");
    int w = width * ta.getFontMetrics(ta.getFont()).charWidth('m');
    int h = (int) (lines * ta.getFontMetrics(ta.getFont()).getHeight());
    ta.setPreferredSize(new Dimension(w, h));
    ta.setMaximumSize(new Dimension(w, 2 * h));

    JScrollPane sp = new JScrollPane(ta);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

    JTextArea tm = new JTextArea(msg);
    tm.setColumns(width);
    tm.setLineWrap(true);
    tm.setWrapStyleWord(true);
    tm.setEditable(false);
    tm.setBackground(new JLabel().getBackground());

    JPanel pnl = new JPanel();
    pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));
    pnl.add(sp);
    pnl.add(Box.createVerticalStrut(10));
    pnl.add(tm);
    pnl.add(Box.createVerticalStrut(10));

    if (0 == JOptionPane.showConfirmDialog(null, pnl, title, JOptionPane.OK_CANCEL_OPTION)) {
      return ta.getText();
    } else {
      return "";
    }
  }