Esempio n. 1
0
  private void initUI() {
    JPanel panel = new JPanel();

    JTextArea area = new JTextArea("Text zona");
    area.setPreferredSize(new Dimension(100, 100));

    JButton button = new JButton("Buton");
    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            System.exit(0);
          }
        });
    panel.add(button);

    JTree tree = new JTree();
    panel.add(tree);
    panel.add(area);

    add(panel);
    pack();

    setTitle("Fereastra layout flow");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
  }
 protected void createWidgets() {
   ReadOnlyTableModel<B> model = new ReadOnlyTableModel<>(getAssignments());
   model.addColumn(
       "Profesor",
       "request",
       new ToStringConverter<Request>() {
         @Override
         public String convert(Request aRequest) {
           return aRequest.getProfessor().getName();
         }
       });
   model.addColumn(
       "Materia",
       "request",
       new ToStringConverter<Request>() {
         @Override
         public String convert(Request aRequest) {
           return aRequest.getSubject().getName();
         }
       });
   assignmentsTable = new JTable(model);
   assignmentsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   assignmentsTable
       .getSelectionModel()
       .addListSelectionListener(
           AssignmentsDetailWindow.this::whenAssignmentsTableSelectionChanged);
   periodDetail = new JTextArea();
   periodDetail.setPreferredSize(new Dimension(480, 100));
   periodDetail.setEditable(false);
   createOtherWidgets();
 }
  private void init() {

    listMultipleSelection = getMultipleSelection();
    listModel = new DefaultListModel();

    // create GUI
    if (listMultipleSelection.getPossibleValues().isEmpty()) {
      panel = null;
      itemsContainerList = null;
      return;
    }

    final Border padding = BorderFactory.createEmptyBorder(5, 10, 5, 10);
    panel = new JPanel();
    BorderLayout layout = new BorderLayout();
    panel.setLayout(layout);
    final JTextArea jta = new JTextArea(getDescription());
    jta.setPreferredSize(new Dimension(200, 50));
    jta.setLineWrap(true);
    jta.setWrapStyleWord(true);
    jta.setBorder(padding);
    panel.add(jta, BorderLayout.PAGE_START);
    jta.setBackground(null);
    jta.setEditable(false);

    // put the items in a list
    itemsContainerList =
        new JList(listModel); // new JList(listMultipleSelection.getPossibleValues().toArray());
    for (T value : getMultipleSelection().getPossibleValues()) listModel.addElement(value);

    itemsContainerList.setFont(new Font("sansserif", Font.PLAIN, 11));
    itemsContainerList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    itemsContainerList.addListSelectionListener(this);

    // selected items
    final List<T> selectedVals = listMultipleSelection.getSelectedValues();
    final List<T> allValues = listMultipleSelection.getPossibleValues();

    final int[] selectedIdx = new int[selectedVals.size()];
    int index = 0;
    for (T selected : selectedVals) {
      for (int i = 0; i < allValues.size(); i++) {
        if (itemsContainerList.getModel().getElementAt(i).equals(selected)) {
          selectedIdx[index] = i;
          index++;
        }
      }
    }
    itemsContainerList.setSelectedIndices(selectedIdx);

    // use a JscrollPane to visualize the items

    final JScrollPane scrollpane = new JScrollPane(itemsContainerList);
    scrollpane.setAutoscrolls(true);
    scrollpane.setOpaque(false);
    scrollpane.setBorder(padding);
    panel.add(scrollpane, BorderLayout.CENTER);
  }
  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;
  }
Esempio n. 5
0
 /**
  * This method initializes jTextArea
  *
  * @return javax.swing.JTextArea
  */
 private JTextArea getJTextArea() {
   if (jTextArea == null) {
     jTextArea = new JTextArea();
     jTextArea.setEnabled(false);
     jTextArea.setText("");
     jTextArea.setEditable(false);
     jTextArea.setLineWrap(true);
     jTextArea.setWrapStyleWord(true);
     jTextArea.setPreferredSize(new Dimension(320, 170));
     jTextArea.addKeyListener(myAction);
   }
   return jTextArea;
 }
Esempio n. 6
0
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints constr;

    // list label
    constr = new GridBagConstraints();
    constr.gridy = 0;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(5, 5, 0, 5);
    panel.add(new JLabel(IdeBundle.message("label.macros")), constr);

    // macros list
    constr = new GridBagConstraints();
    constr.gridy = 1;
    constr.weightx = 1;
    constr.weighty = 1;
    constr.insets = new Insets(0, 5, 0, 5);
    constr.fill = GridBagConstraints.BOTH;
    constr.anchor = GridBagConstraints.WEST;
    panel.add(new JScrollPane(myMacrosList), constr);
    myMacrosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myMacrosList.setPreferredSize(null);

    // preview label
    constr = new GridBagConstraints();
    constr.gridx = 0;
    constr.gridy = 2;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(5, 5, 0, 5);
    panel.add(new JLabel(IdeBundle.message("label.macro.preview")), constr);

    // preview
    constr = new GridBagConstraints();
    constr.gridx = 0;
    constr.gridy = 3;
    constr.weightx = 1;
    constr.weighty = 1;
    constr.fill = GridBagConstraints.BOTH;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(0, 5, 5, 5);
    panel.add(new JScrollPane(myPreviewTextarea), constr);
    myPreviewTextarea.setEditable(false);
    myPreviewTextarea.setLineWrap(true);
    myPreviewTextarea.setPreferredSize(null);

    panel.setPreferredSize(new Dimension(400, 500));

    return panel;
  }
Esempio n. 7
0
  /** Initialize components */
  private void initializeComponent() {
    /* Initialize components */
    txtEmail = new JTextArea();
    txtEmail.setText("No message.");
    txtEmail.setPreferredSize(new Dimension(886, 737));
    txtEmail.setLineWrap(true);
    txtEmail.setEditable(false);
    txtEmail.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JScrollPane scrollEmail = new JScrollPane(txtEmail);

    /* Register event handlers */

    /* Add components */
    this.add(scrollEmail, BorderLayout.CENTER);
  }
 public WarehouseKeeperLogFrame() {
   this.setSize(600, 600);
   this.setDefaultCloseOperation(HIDE_ON_CLOSE);
   this.setLocation((WIDTH / 2) - this.getWidth() / 2, (HEIGTH / 2) - this.getHeight() / 2);
   this.setLayout(new FlowLayout());
   log.setAutoscrolls(true);
   log.setPreferredSize(new Dimension(1000, 500));
   log.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
   JScrollPane jScrollPane = new JScrollPane(log);
   jScrollPane.setPreferredSize(new Dimension(565, 300));
   jScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
   jScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   jScrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
   this.add(jScrollPane);
   log.setEditable(false);
 }
  { // Set the layout to the frame in order to show the panels, BorderLayout used.
    setLayout(new BorderLayout());

    // program will stop running when "X" is pressed.
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    // set the title for the program.
    this.setTitle("Financial Modeller - B00540772");

    // add the two frames to the frame show that they will show in the correct areas.
    this.add(drawing, BorderLayout.NORTH);
    this.add(control, BorderLayout.SOUTH);

    // add the instructions panel into the frame.
    this.add(instructions, BorderLayout.CENTER);

    // set the size of the two panels.
    drawing.setPreferredSize(new Dimension(900, 350));
    control.setPreferredSize(new Dimension(900, 250));
    instructions.setPreferredSize(new Dimension(900, 80));

    // set the background of the DrawingPanel to highlight the two different panels.
    drawing.setBackground(Color.WHITE);

    // call the line wrap method to improve the layout of the text area.
    instructions.setLineWrap(true);

    // insert the instructions for the user.
    instructions.append(
        "Please use the control panel to enter your financial"
            + " information. When the information has been entered press 'Start'"
            + " to run the simulation. The textual output will          show each"
            + " input and output as it happens, and will give you a balance update."
            + " The graphical output will give you a representation of the changing"
            + " weekly balance,       each second represents"
            + " one week. Please be aware that if the balance goes above £16000"
            + " or the duration goes above 52 weeks the graphical output will stop,"
            + " if         this happens you can continue to use the textual output."
            + " If you do not wish to use all of the threads please leave amount AND"
            + " frequency as '0' and that thread will not    start.");

    // set visible and pack to ensure it will run correctly.
    pack();
    setVisible(true);
  }
Esempio n. 10
0
  private void build() {
    setLayout(new VerticalFlowLayout(3));

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (Shot shot : shots.getShotList()) model.addElement(shot);
    cboShot = new JComboBox(model);
    add(cboShot);
    cboShot.addActionListener(this);

    add(pnlZone);
    add(lblLocation);

    JPanel pnlHolder = new JPanel(new BorderLayout());
    pnlBuilder = new BuilderPanel();
    pnlHolder.add(lblInfo, BorderLayout.WEST);
    pnlHolder.add(pnlBuilder, BorderLayout.CENTER);

    lblInfo.setBorder(BorderFactory.createEtchedBorder());
    add(pnlHolder);

    lblInfo.setPreferredSize(new Dimension(350, 200));

    pnlZone.addMouseListener(pnlBuilder);
  }
  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();
          }
        });
  }
  public SeparateFestivalFrame(final MediaPlayerMain frame) {

    setTitle("[Synthesize speech from text]");
    setSize(540, 250);
    getRootPane().setBorder(BorderFactory.createMatteBorder(0, 3, 0, 3, Color.WHITE));

    thisFrame = this;
    JPanel mainPanel = new JPanel(new BorderLayout());
    setContentPane(mainPanel);

    // Create new fonts with modified styles, while retaining the same font
    final Font defaultFONT = new JLabel().getFont();
    String defaultFont = defaultFONT.getName();

    final AudioConverter ac = frame.getAC();
    ac.setFestivalFrame(this);

    // Definition of Main Panels and Layouts

    JPanel corePanel = new JPanel(new BorderLayout(0, 5));
    corePanel.setBorder(new EmptyBorder(0, 5, 5, 5));
    JPanel botPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 0));
    botPanel.setBorder(new EmptyBorder(0, 0, 5, 0));

    // Primary label

    JLabel titleLabel2 = new JLabel("Create custom audio using text to speech");
    titleLabel2.setBorder(new EmptyBorder(5, 0, 0, 0));
    titleLabel2.setFont(new Font(defaultFont, Font.BOLD, 18));
    titleLabel2.setHorizontalAlignment(SwingConstants.LEFT);

    // Festival text box
    final JTextArea textBox2 = new JTextArea();
    remainingCharacters = new JLabel();
    remainingCharacters.setHorizontalAlignment(SwingConstants.LEFT);
    remainingCharacters.setFont(new Font(defaultFont, Font.PLAIN, 10));

    // Document used to restrict characters entered into textbox
    customDoc = new DefaultStyledDocument();
    customDoc.setDocumentFilter(new DocumentLimit(250));
    customDoc.addDocumentListener(
        new DocumentListener() {

          @Override
          public void insertUpdate(DocumentEvent e) {
            updateCount();
          }

          @Override
          public void removeUpdate(DocumentEvent e) {
            updateCount();
          }

          @Override
          public void changedUpdate(DocumentEvent e) {
            updateCount();
          }
        });
    textBox2.setDocument(customDoc);
    updateCount();
    textBox2.setLineWrap(true);
    textBox2.setPreferredSize(new Dimension(350, 100));

    // Festival Speed setting
    JPanel festivalPanel = new JPanel(new BorderLayout());
    festivalPanel.add(textBox2, BorderLayout.CENTER);

    // Panel dedicated to voice speed
    JPanel speedRow = new JPanel(new FlowLayout(FlowLayout.TRAILING, 2, 0));
    JLabel newLabel = new JLabel("Speed of audio output:");
    newLabel.setFont(new Font(defaultFont, Font.BOLD, 12));

    // Combo box allows user to select between voice speeds
    String[] combos = {"Fast", "Normal", "Slow"};
    JComboBox<String> speedBox = new JComboBox<String>(combos);
    speedBox.setSelectedItem(combos[1]);
    speedBox.addActionListener(
        new ActionListener() {

          @Override
          // Update scheme files with any change in selection on combobox
          public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> comboBox = (JComboBox<String>) e.getSource();
            String speed = (String) comboBox.getSelectedItem();
            frame.updateScheme(speed);
          }
        });

    speedRow.add(newLabel);
    speedRow.add(speedBox);

    festivalPanel.add(speedRow, BorderLayout.SOUTH);

    // Festival reads out provided text as a preview
    JButton previewBtn = new JButton("Preview Text to Speech");
    previewBtn.setFont(new Font(defaultFont, Font.PLAIN, 11));

    previewBtn.setPreferredSize(new Dimension(180, 25));
    previewBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String text = textBox2.getText();

            if (text.isEmpty()) {
              JOptionPane.showMessageDialog(
                  thisFrame, "Text box has been left blank", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
              currentProcess = ac.convertToAudio(text);
            }
          }
        });

    // Button used to kill speaking process
    JButton cancelPreview = new JButton("Stop");
    cancelPreview.setFont(new Font(defaultFont, Font.PLAIN, 11));
    cancelPreview.setPreferredSize(new Dimension(100, 25));
    cancelPreview.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (currentProcess != null) {
              CancelProcess(currentProcess);
              currentProcess = null;
            }
          }
        });

    // Preview Panel includes the preview button and the Character count
    JPanel previewPanel = new JPanel(new BorderLayout());
    JPanel twoButtons = new JPanel(new FlowLayout());
    previewPanel.add(remainingCharacters, BorderLayout.WEST);
    twoButtons.add(previewBtn);
    twoButtons.add(cancelPreview);
    previewPanel.add(twoButtons, BorderLayout.EAST);
    previewPanel.setBorder(new EmptyBorder(3, 0, 0, 0));

    // Centre Panel includes practically all content except the final
    // options
    corePanel.add(titleLabel2, BorderLayout.NORTH);
    corePanel.add(festivalPanel, BorderLayout.CENTER);
    corePanel.add(previewPanel, BorderLayout.SOUTH);

    mainPanel.add(corePanel, BorderLayout.CENTER);

    // Bottom Panel - Contains Confirm/Cancel buttons for frame

    JButton okBtn = new JButton("Save to MP3 file");
    okBtn.setFont(new Font(defaultFont, Font.BOLD, 12));
    okBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String festivalText = textBox2.getText();

            if (festivalText.isEmpty()) {
              JOptionPane.showMessageDialog(
                  thisFrame,
                  "Please enter text into the text area",
                  "No text to convert",
                  JOptionPane.ERROR_MESSAGE);
            } else {
              // convert festival text to wav file
              // get wav file path
              if (ac.convertToWav(festivalText)) {
                ac.wavToMp3();
                thisFrame.setVisible(false);
              }
            }
          }
        });
    okBtn.setPreferredSize(new Dimension(175, 25));

    JButton cnclBtn = new JButton("Cancel");
    cnclBtn.setFont(new Font(defaultFont, Font.BOLD, 12));
    cnclBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            thisFrame.setVisible(false);
          }
        });
    cnclBtn.setPreferredSize(new Dimension(175, 25));

    botPanel.add(okBtn);
    botPanel.add(cnclBtn);
    mainPanel.add(botPanel, BorderLayout.SOUTH);
  }
Esempio n. 13
0
  protected void init() {
    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    setLayout(gb);

    JLabel subjectDNLbl = makeJLabel("SUBJECTDN");
    CMSAdminUtil.resetGBC(gbc);
    gbc.anchor = gbc.NORTHWEST;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, 0, COMPONENT_SPACE);
    add(subjectDNLbl, gbc);

    JLabel issuerLbl = makeJLabel("ISSUE");
    CMSAdminUtil.resetGBC(gbc);
    gbc.anchor = gbc.NORTHWEST;
    gbc.gridwidth = gbc.REMAINDER;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, 0, COMPONENT_SPACE);
    add(issuerLbl, gbc);

    JTextArea subjectText = new JTextArea(null, null, 0, 0);
    JScrollPane subjectScrollPane =
        new JScrollPane(
            subjectText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    // subjectScrollPane.setPreferredSize(new Dimension(50, 30));
    CMSAdminUtil.resetGBC(gbc);
    gbc.anchor = gbc.NORTHWEST;
    gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, 0);
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.fill = gbc.BOTH;
    add(subjectScrollPane, gbc);

    JTextArea issueText = new JTextArea(null, null, 0, 0);
    JScrollPane issueScrollPane =
        new JScrollPane(
            issueText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    // issueScrollPane.setPreferredSize(new Dimension(50, 30));
    CMSAdminUtil.resetGBC(gbc);
    gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE);
    gbc.anchor = gbc.NORTHWEST;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.fill = gbc.BOTH;
    gbc.gridwidth = gbc.REMAINDER;
    add(issueScrollPane, gbc);

    JTextArea infoText = new JTextArea(null, null, 0, 0);
    gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE);
    infoText.setPreferredSize(new Dimension(50, 20));
    gbc.fill = gbc.BOTH;
    gbc.anchor = gbc.NORTHWEST;
    gbc.gridwidth = gbc.REMAINDER;
    gbc.weighty = 1.0;
    add(infoText, gbc);

    mAdd = makeJButton("ADD");
    CMSAdminUtil.resetGBC(gbc);
    gbc.anchor = gbc.NORTHEAST;
    gbc.fill = gbc.NONE;
    gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE);
    gbc.gridwidth = gbc.REMAINDER;
    add(mAdd, gbc);

    super.init();
  }
  public ObjectInspector(Db4oViewer viewer, Object object) {
    this.viewer = viewer;
    this.object = object;

    this.setPreferredSize(new Dimension(600, 800));
    BorderLayout thisLayout = new BorderLayout();
    getContentPane().setLayout(thisLayout);
    this.setLocation(400, 150);

    {
      jSplitPane1 = new JSplitPane();
      getContentPane().add(jSplitPane1, BorderLayout.NORTH);
      jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
      {
        jPanel1 = new JPanel();
        jSplitPane1.add(jPanel1, JSplitPane.BOTTOM);
        BorderLayout jPanel1Layout = new BorderLayout();
        jPanel1.setLayout(jPanel1Layout);
        jPanel1.setPreferredSize(new java.awt.Dimension(590, 191));
        {
          jPanel2 = new JPanel();
          FlowLayout jPanel2Layout = new FlowLayout();
          jPanel1.add(jPanel2, BorderLayout.SOUTH);
          jPanel2.setPreferredSize(new java.awt.Dimension(592, 33));
          jPanel2.setLayout(jPanel2Layout);
          {
            saveButton = new JButton();
            jPanel2.add(saveButton);
            saveButton.setText("Save");
            saveButton.setActionCommand("save");
            saveButton.addActionListener(this);
          }
          {
            deleteButton = new JButton();
            jPanel2.add(deleteButton);
            deleteButton.setText("Delete");
            deleteButton.setActionCommand("delete");
            deleteButton.addActionListener(this);
          }
          {
            refreshButton = new JButton();
            jPanel2.add(refreshButton);
            refreshButton.setText("Refresh");
            refreshButton.setActionCommand("refresh");
            refreshButton.addActionListener(this);
          }
        }
        {
          jPanel3 = new JPanel();
          jPanel1.add(jPanel3, BorderLayout.NORTH);
          FlowLayout jPanel3Layout = new FlowLayout();
          jPanel3.setLayout(jPanel3Layout);
          jPanel3.setPreferredSize(new java.awt.Dimension(592, 114));
          {
            fieldEdit = new JTextArea();
            jPanel3.add(fieldEdit);
            fieldEdit.setPreferredSize(new java.awt.Dimension(324, 92));
            fieldEdit.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
          }
          {
            editApply = new JButton();
            jPanel3.add(editApply);
            editApply.setText("Apply");
            editApply.setActionCommand("apply");
            editApply.addActionListener(this);
          }
        }
      }
      {
        jScrollPane1 = new JScrollPane();
        jSplitPane1.add(jScrollPane1, JSplitPane.TOP);
        {
          jTree1 = new AutoScrollingJTree(new DefaultMutableTreeNode());
          jScrollPane1.setViewportView(jTree1);
          jTree1.setDragEnabled(true);

          TreeDragSource ds = new TreeDragSource(jTree1, DnDConstants.ACTION_COPY_OR_MOVE);
          TreeDropTarget dt = new TreeDropTarget(jTree1);
        }
      }
    }

    if (object != null) {
      this.setTitle(object.toString());
    }

    System.out.println(object);

    buildTree();
    jTree1.addMouseListener(this);

    this.pack();
    this.setVisible(true);
  }
  public void inicializar() {

    JPanel painel = new JPanel();
    painel.setLayout(new BorderLayout());
    setTitle("Instrucoes");
    add(painel);

    tabela = new JTable();
    tabela.setModel(
        new DefaultTableModel(
            new Object[][] {
              {"Instrução", "Exemplo", "Significado"},
              {"Soma", "add $t0,$t1,$t2", "$t0 = $t1+$t2"},
              {"Subtração", "sub $s1, $s2,$s3", "$s1 = $s2 - $s3"},
              {"Soma imediato", "addi $s1,$s2, 100", "$s1 = $s2 + 100"},
              {"Multiplicação", "mul $v0,$a1,$v0", "$v0 = $a1 * $v0"},
              {"Divisão", "div $t0,$a1,$a0", "$t0 = $a1 / $s0"},
              {"Resto", "rest $t1,$a1,$a0", "$t1 = $a1 % $a0"},
              {"AND", "and $s1, $s2,$s3", "$s1 = $s2 & $s3"},
              {"AND imediato", "andi $s1,$s2,100", "$s1 = $s2 & 100"},
              {"OR", "or $s1,$s2,$s3", "$s1 = $s2 ou $s3"},
              {"OR imediato", "ori $s1,$s2,100", "$s1 = $s2 ou 100"},
              {
                "SHIFT para a Esquerda",
                "sll $s1,$s2,10",
                "$s1 = $s2 << 10 (Shifta os bits de $s2 10 posições para a esquerda)"
              },
              {
                "SHIFT para a Direita",
                "srl $s1,$s2,10",
                "$s1 = $s2 >> 10 (Shifta os bits de $s2 10 posições para a direita)"
              },
              {"Leitura do Array", "lw $s1,100($s2)", "$s1 = Memória ($s2 + 100)"},
              {"Escrita no Array", "sw $s1,100($s2)", "Memória ($s2 + 100) = $s1"},
              {"Verificar Igualdade", "beq $s1,$s2,label", "if ( $s1 == $s2 ) {vai para label}"},
              {"Verificar Desigualdade", "bne $s1,$s2,label", "if ( $s1 != $s2 ) {vai para label}"},
              {
                "Verificar se for menor",
                "slt $s1,$s2,$s3",
                "if ( $s2 < $s3 ) {$s1 = 1} else {$s1 = 0}"
              },
              {"Salto", "j label", "Vá para label"},
              {"Salto para um registrador", "jr $ra", "Vá para $ra"},
              {"Salto para um ‘link’", "jal Func", "$ra = PC + 4; Vá para Func"},
              {"Mover valor", "move $v0,$a0", "Move o $a0 para $v0"}
            },
            new String[] {"New column", "New column", "New column"}));

    tabela.setDefaultRenderer(
        Object.class,
        new DefaultTableCellRenderer() {
          public Component getTableCellRendererComponent(
              JTable table,
              Object value,
              boolean isSelected,
              boolean hasFocus,
              int row,
              int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (row == 0) {
              setBackground(Color.LIGHT_GRAY);

            } else {
              setBackground(null);
            }
            return this;
          }
        });

    painel.add(tabela);
    tabela.getColumnModel().getColumn(0).setPreferredWidth(0);
    tabela.getColumnModel().getColumn(1).setPreferredWidth(0);
    tabela.getColumnModel().getColumn(2).setPreferredWidth(250);
    tabela.setRowHeight(0, 30);

    area.setPreferredSize(new Dimension(500, 500));
    ScrollPane scroll = new ScrollPane();
    scroll.setPreferredSize(new Dimension(800, 280));
    scroll.add(area);

    setResizable(false);
    setSize(700, 395);
    setLocationRelativeTo(null);
    setVisible(true);
  }
Esempio n. 16
0
  public ModuleViewTeacher() {

    JFrame frame = new JFrame("Module 1");
    frame.add(topPanel, BorderLayout.NORTH);
    topPanel.setBackground(Color.white);
    frame.add(menuBar);
    frame.setJMenuBar(menuBar);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(1024, 768);

    // Panel 1
    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayout(3, 1));
    panel1.setBorder(
        BorderFactory.createTitledBorder(
            "MODUL 1")); // lager border rundt hele panel1 med overskrift
    panel1.setPreferredSize(
        new Dimension(
            frame.getWidth() / 2 - 10,
            frame.getHeight() / 2
                - 10)); // setter dimensjoner på det respektive panelet slik at det er halve
                        // skjermbredden

    JPanel panel1_1 = new JPanel();
    JPanel panel1_2 = new JPanel();
    JPanel panel1_3 = new JPanel();

    JPanel bottomPanel = new JPanel(new GridLayout(1, 2));
    JPanel bottomLeft = new JPanel(new FlowLayout(LEFT));
    JPanel bottomRight = new JPanel(new FlowLayout(LEFT));
    JButton btnLagre = new JButton("Lagre");
    JButton btnLagre1 = new JButton("Lagre");
    JCheckBox godkjent = new JCheckBox("Godkjent");
    JCheckBox ikkeGodkjent = new JCheckBox("Ikke godkjent");

    frame.add(bottomPanel, BorderLayout.SOUTH);
    bottomPanel.setBackground(Color.white);
    bottomPanel.add(bottomLeft);
    bottomPanel.add(bottomRight);
    bottomLeft.add(btnLagre);
    bottomRight.add(btnLagre1);
    bottomRight.add(godkjent);
    bottomRight.add(ikkeGodkjent);

    godkjent.setMnemonic(KeyEvent.VK_C);
    ikkeGodkjent.setMnemonic(KeyEvent.VK_C);

    panel1_1.setBorder(BorderFactory.createTitledBorder("Info"));
    panel1_2.setBorder(BorderFactory.createTitledBorder("Ressurser"));
    panel1_3.setBorder(BorderFactory.createTitledBorder("Godkjenning/læringsmål"));

    JTextArea textArea1 = new JTextArea();
    JTextArea textArea2 = new JTextArea();
    JTextArea textArea3 = new JTextArea();

    // bruker gridlayout på panelene inni hovedpanelet
    panel1_1.setLayout(new GridLayout(1, 1));
    panel1_2.setLayout(new GridLayout(1, 1));
    panel1_3.setLayout(new GridLayout(1, 1));
    textArea1.setEditable(true);
    textArea2.setEditable(true);
    textArea3.setEditable(true);

    textArea1.setLineWrap(true);
    textArea1.setWrapStyleWord(true);
    textArea2.setLineWrap(true);
    textArea2.setWrapStyleWord(true);
    textArea3.setLineWrap(true);
    textArea3.setWrapStyleWord(true);

    // legger til textfelt i underpanelene
    panel1_1.add(textArea1);
    panel1_2.add(textArea2);
    panel1_3.add(textArea3);

    // Legg panelene til i hovedpanel.
    panel1.add(panel1_1);
    panel1.add(panel1_2);
    panel1.add(panel1_3);

    // Panel 2 - Godkjenning

    JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayout(2, 1));
    panel2.setBorder(
        BorderFactory.createTitledBorder(
            "Godkjenning")); // lager border rundt hele panel1 med overskrift
    panel2.setPreferredSize(
        new Dimension(
            frame.getWidth() / 2 - 10,
            frame.getHeight() / 2 - 10)); // setter dimensjoner på det respektive panelet

    JPanel upperPanel = new JPanel();
    JPanel lowerPanel = new JPanel();
    ListModel model = new DefaultListModel();
    JList navneListe = new JList(model);
    JScrollPane scrollPane = new JScrollPane(navneListe);

    upperPanel.setLayout(new GridLayout(1, 1));
    upperPanel.setBorder(BorderFactory.createTitledBorder("Studenter"));

    String listData[] = {
      "Admir Begovic",
      "Tor Hakli",
      "Erlend Nord",
      "Lars Martin Risdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal",
      "Atilla Sjusdal"
    };

    // navneListe.setPreferredSize(new Dimension(frame.getWidth() - 40, frame.getHeight()- 40));
    navneListe = new JList(listData);
    scrollPane.setVisible(true);

    upperPanel.add(new JScrollPane(navneListe));

    lowerPanel.setLayout(new FlowLayout());
    lowerPanel.setBorder(BorderFactory.createTitledBorder("KOMMENTAR"));

    JTextArea kommentarTf = new JTextArea();
    kommentarTf.setPreferredSize(new Dimension(frame.getWidth() / 2 - 30, frame.getHeight() - 20));
    lowerPanel.add(kommentarTf); // legger til kommentarfeltet i lowerpanel

    kommentarTf.setLineWrap(true);
    kommentarTf.setWrapStyleWord(true);
    kommentarTf.setEditable(true);

    panel2.add(upperPanel); // legger til upperpanel i panel2
    panel2.add(lowerPanel); // legger til lowerpanel i panel2

    // Legg til paneler i hovedframen
    frame.add(panel1, BorderLayout.WEST);
    frame.add(panel2, BorderLayout.EAST);

    frame.setLocationRelativeTo(null);
    // frame.pack();

  }
Esempio n. 17
0
  private JPanel viewMarketingPanel(final JPanel mainPanel) {
    // removes everything from the main layout
    mainPanel.setLayout(new BorderLayout());
    JPanel mainmarketPanel = new JPanel();
    mainmarketPanel.setLayout(new BoxLayout(mainmarketPanel, BoxLayout.Y_AXIS));
    JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    headerPanel.setPreferredSize(new Dimension(600, 60));
    JLabel header = new JLabel("MARKETING NOTE");
    header.setFont(new Font("Verdana", Font.BOLD, 25));
    headerPanel.add(header);
    mainmarketPanel.add(headerPanel);

    for (int i = 0; i < numOfSelected.length; ++i) {
      int ID = numOfSelected[i];
      JPanel marketPanel = new JPanel();
      BorderLayout marketNoteLayout = new BorderLayout();
      marketNoteLayout.setVgap(10);
      marketPanel.setLayout(marketNoteLayout);

      JLabel noteDateLabel = new JLabel("Note Date: ");
      noteDateLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
      JLabel noteDate = new JLabel(getNoteDate(2, ID));
      noteDate.setFont(new Font("Tahoma", Font.PLAIN, 20));
      JLabel machineIDLabel = new JLabel("Machine ID: ");
      machineIDLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
      JLabel machineID = new JLabel(String.valueOf(ID + 1));
      machineID.setVerticalTextPosition(SwingConstants.BOTTOM);
      machineID.setFont(new Font("Tahoma", Font.PLAIN, 20));

      JPanel dateFlow = new JPanel(new FlowLayout());
      JPanel idFlow = new JPanel(new FlowLayout());
      JPanel dateIdGrid = new JPanel(new GridLayout(1, 2));

      dateFlow.add(noteDateLabel);
      dateFlow.add(noteDate);
      idFlow.add(machineIDLabel);
      idFlow.add(machineID);

      dateIdGrid.add(dateFlow);
      dateIdGrid.add(idFlow);

      // topFlow.add(topGrid);
      JPanel notePanel = new JPanel(new FlowLayout());
      JLabel noteLabel = new JLabel("Note:  ");
      noteLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
      noteLabel.setPreferredSize(new Dimension(600, 30));
      notePanel.add(noteLabel);
      final JTextArea marketerNote = new JTextArea(getMarketingNote(ID));
      marketerNote.setFont(new Font("Arial", Font.PLAIN, 14));
      marketerNote.setEditable(false);
      marketerNote.setPreferredSize(new Dimension(600, 200));
      JScrollPane scrollText = new JScrollPane(marketerNote);
      JPanel scrollPanel = new JPanel(new FlowLayout());
      scrollPanel.add(scrollText);

      // panels for marketer note

      JPanel reNoteFlow = new JPanel(new BorderLayout(0, 20));
      // adds to the flow layouts for centering

      reNoteFlow.add(notePanel, BorderLayout.NORTH);
      reNoteFlow.add(scrollPanel, BorderLayout.CENTER);
      // adds to the main layout
      marketPanel.add(dateIdGrid, BorderLayout.NORTH);
      marketPanel.add(reNoteFlow, BorderLayout.CENTER);
      // marketPanel.setPreferredSize(new Dimension(400, 400));
      mainmarketPanel.add(marketPanel);
      // mainmarketPanel.add(Box.createVerticalGlue());
    }
    JScrollPane sPane = new JScrollPane(mainmarketPanel);
    mainPanel.add(sPane, BorderLayout.CENTER);
    // JPanel buttonPanel = new JPanel(new FlowLayout());
    JButton backButton = new JButton("Back");
    backButton.setPreferredSize(new Dimension(10, 50));
    backButton.setFont(new Font("Arial", Font.PLAIN, 18));
    // buttonPanel.add(backButton);
    mainPanel.add(backButton, BorderLayout.SOUTH);

    backButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            mainPanel.removeAll();
            // mainmarketPanel.setLayout( new GridLayout());
            localVendMarketingPanel(mainPanel);
            mainPanel.revalidate();
            mainPanel.repaint();
          }
        });
    return mainPanel;
  }
Esempio n. 18
0
 private JTextArea getTextArea() {
   JTextArea textArea = new JTextArea();
   textArea.setPreferredSize(new Dimension(350, 50));
   textArea.setLineWrap(true);
   return textArea;
 }
Esempio n. 19
0
  public NumbrixGUI() throws ParseException { // Board gameBoard) throws ParseException{

    // Board
    this.gameBoard = new Board();

    // Container
    setTitle(TITLE);
    setSize(WIDTH, HEIGHT);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    // About Frame
    jFrameAbout = new javax.swing.JFrame();
    jFrameAbout.setResizable(false);
    jFrameAbout.setPreferredSize(new Dimension(500, 300));

    jTextAreaAbout = new javax.swing.JTextArea();
    jTextAreaAbout.setBackground(new java.awt.Color(240, 240, 240));
    jTextAreaAbout.setColumns(20);
    jTextAreaAbout.setRows(10);
    jTextAreaAbout.setText(
        "\t\tNumbrix Version 1\n\nClass Project for Artificial Intelligence course.\nUniversity of Florida\nCISE\n\n\n\n\nby Rainer Ledesma\nhttp://www.cise.ufl.edu/~rledesma/\n");
    jTextAreaAbout.setFont(new java.awt.Font("Agency FB", 1, 20)); // NOI18N
    jTextAreaAbout.setEditable(false);
    jTextAreaAbout.setPreferredSize(new Dimension(500, 300));

    javax.swing.GroupLayout jFrameAboutLayout =
        new javax.swing.GroupLayout(jFrameAbout.getContentPane());
    jFrameAbout.getContentPane().setLayout(jFrameAboutLayout);
    jFrameAboutLayout.setHorizontalGroup(
        jFrameAboutLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameAboutLayout
                    .createSequentialGroup()
                    .addGap(11, 11, 11)
                    .addComponent(
                        jTextAreaAbout,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jFrameAboutLayout.setVerticalGroup(
        jFrameAboutLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameAboutLayout
                    .createSequentialGroup()
                    .addGap(0, 16, Short.MAX_VALUE)
                    .addComponent(
                        jTextAreaAbout,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        267,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 17, Short.MAX_VALUE)));
    //

    // Instructions Frame
    jFrameInstructions = new javax.swing.JFrame();
    jFrameInstructions.setResizable(false);
    jFrameInstructions.setPreferredSize(new Dimension(500, 300));

    jTextAreaInstructions = new javax.swing.JTextArea();
    jTextAreaInstructions.setBackground(new java.awt.Color(240, 240, 240));
    jTextAreaInstructions.setColumns(20);
    jTextAreaInstructions.setRows(10);
    jTextAreaInstructions.setText(
        "\t\tNumbrix\n"
            + "The object of Numbrix is to fill the board with sequence of consecutive \n"
            + "numbers from 1 to the maximun cell count. The numbers must fillow a \n"
            + "horizontal or vertical path (no diagonals)\n");
    jTextAreaInstructions.setFont(new java.awt.Font("Agency FB", 1, 20)); // NOI18N
    jTextAreaInstructions.setEditable(false);
    jTextAreaInstructions.setPreferredSize(new Dimension(500, 300));

    javax.swing.GroupLayout jFrameInstructionsLayout =
        new javax.swing.GroupLayout(jFrameInstructions.getContentPane());
    jFrameInstructions.getContentPane().setLayout(jFrameInstructionsLayout);
    jFrameInstructionsLayout.setHorizontalGroup(
        jFrameInstructionsLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameInstructionsLayout
                    .createSequentialGroup()
                    .addGap(11, 11, 11)
                    .addComponent(
                        jTextAreaInstructions,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jFrameInstructionsLayout.setVerticalGroup(
        jFrameInstructionsLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameInstructionsLayout
                    .createSequentialGroup()
                    .addGap(0, 16, Short.MAX_VALUE)
                    .addComponent(
                        jTextAreaInstructions,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        267,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 17, Short.MAX_VALUE)));
    //

    // File Chooser
    jFrameFileChooser = new javax.swing.JFrame();
    jFileChooser = new javax.swing.JFileChooser();
    jFileChooser.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
              jFileChooserActionPerformed(evt);
            } catch (Exception ex) {
              JOptionPane.showMessageDialog(frame, "File Exception");
            }
          }
        });

    javax.swing.GroupLayout jFrameFileChooserLayout =
        new javax.swing.GroupLayout(jFrameFileChooser.getContentPane());
    jFrameFileChooser.getContentPane().setLayout(jFrameFileChooserLayout);
    jFrameFileChooserLayout.setHorizontalGroup(
        jFrameFileChooserLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 618, Short.MAX_VALUE)
            .addGroup(
                jFrameFileChooserLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(
                        jFrameFileChooserLayout
                            .createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addComponent(
                                jFileChooser,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGap(18, 18, 18))));
    jFrameFileChooserLayout.setVerticalGroup(
        jFrameFileChooserLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 456, Short.MAX_VALUE)
            .addGroup(
                jFrameFileChooserLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(
                        jFrameFileChooserLayout
                            .createSequentialGroup()
                            .addGap(27, 27, 27)
                            .addComponent(
                                jFileChooser,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGap(32, 32, 32))));
    //

    // SidePanel
    jPanelSideBar = new javax.swing.JPanel();
    jButtonRESET = new javax.swing.JButton();
    jButtonSOLVE = new javax.swing.JButton();
    jButtonNEWGAME = new javax.swing.JButton();
    jLabelTIMER = new javax.swing.JLabel();
    jButtonPAUSE = new javax.swing.JButton();

    jButtonRESET.setText("RESET");
    jButtonRESET.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonRESETActionPerformed(evt);
          }
        });
    jButtonSOLVE.setText("SOLVE");
    jButtonSOLVE.setEnabled(false);
    jButtonSOLVE.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
              jButtonSOLVEActionPerformed(evt);
            } catch (IOException ex) {
              Logger.getLogger(NumbrixGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
    jButtonNEWGAME.setText("NEW GAME");
    jButtonNEWGAME.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonNEWGAMEActionPerformed(evt);
          }
        });
    jLabelTIMER.setText("TIMER");
    jLabelTIMER.setFont(new java.awt.Font("Agency FB", 1, 18));
    jButtonPAUSE.setText("PAUSE");
    jButtonPAUSE.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonPAUSEActionPerformed(evt);
          }
        });
    jLabelClock = new javax.swing.JLabel();
    jLabelClock.setFont(new java.awt.Font("Agency FB", 1, 24)); // NOI18N
    jLabelClock.setText("10 : 99 : 60");

    javax.swing.GroupLayout jPanelSideBarLayout = new javax.swing.GroupLayout(jPanelSideBar);
    jPanelSideBar.setLayout(jPanelSideBarLayout);
    jPanelSideBarLayout.setHorizontalGroup(
        jPanelSideBarLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanelSideBarLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanelSideBarLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                jButtonRESET,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButtonSOLVE,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButtonNEWGAME,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                136,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButtonPAUSE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGroup(
                                jPanelSideBarLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanelSideBarLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabelTIMER)
                                            .addComponent(
                                                jLabelClock,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                97,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(0, 0, Short.MAX_VALUE)))
                    .addContainerGap()));
    jPanelSideBarLayout.setVerticalGroup(
        jPanelSideBarLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                jPanelSideBarLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabelTIMER)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jLabelClock,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        32,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jButtonPAUSE)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
                    .addComponent(jButtonNEWGAME)
                    .addGap(18, 18, 18)
                    .addComponent(jButtonRESET)
                    .addGap(18, 18, 18)
                    .addComponent(jButtonSOLVE)
                    .addContainerGap()));
    ////////

    // Menu
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItemNewGame = new javax.swing.JMenuItem();
    jMenuItemExit = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItemInstructions = new javax.swing.JMenuItem();
    jMenuItemAbout = new javax.swing.JMenuItem();

    jMenu1.setText("File");
    jMenu2.setText("Edit");

    jMenuItemNewGame.setText("New Game");
    jMenuItemExit.setText("Exit");
    jMenuItemInstructions.setText("Instructions");
    jMenuItemAbout.setText("About Numbrix");

    jMenuBar1.add(jMenu1);
    jMenuBar1.add(jMenu2);
    jMenu1.add(jMenuItemNewGame);
    jMenu1.add(jMenuItemExit);
    jMenu2.add(jMenuItemInstructions);
    jMenu2.add(jMenuItemAbout);

    setJMenuBar(jMenuBar1);

    jMenuItemNewGame.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemNewGameActionPerformed(evt);
          }
        });
    jMenuItemExit.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemExitActionPerformed(evt);
          }
        });
    jMenuItemInstructions.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemInstructionsActionPerformed(evt);
          }
        });
    jMenuItemAbout.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemAboutActionPerformed(evt);
          }
        });
    //

    // SolvedBoardPanel
    jPanelSolvedBoard = new javax.swing.JPanel();
    jPanelSolvedBoard.setBackground(new java.awt.Color(255, 255, 255));

    // Solved Board Frame
    jFrameSolvedBoard = new javax.swing.JFrame();
    jFrameSolvedBoard.setTitle("Numbrix Solution");
    javax.swing.GroupLayout jFrameSolvedBoardLayout =
        new javax.swing.GroupLayout(jFrameSolvedBoard.getContentPane());
    jFrameSolvedBoard.getContentPane().setLayout(jFrameSolvedBoardLayout);
    jFrameSolvedBoardLayout.setHorizontalGroup(
        jFrameSolvedBoardLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
            .addGroup(
                jFrameSolvedBoardLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(
                        jPanelSolvedBoard,
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        400,
                        Short.MAX_VALUE)));
    jFrameSolvedBoardLayout.setVerticalGroup(
        jFrameSolvedBoardLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
            .addGroup(
                jFrameSolvedBoardLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(
                        jPanelSolvedBoard,
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        300,
                        Short.MAX_VALUE)));

    // BoardPanel
    boardPanel = new javax.swing.JPanel();
    boardPanel.setBackground(new java.awt.Color(255, 255, 255));
    // Clock
    gameTimer = new GameTimer(jLabelClock);
    this.gameTimer.start();
    this.gameTimer.run();

    // Initialize
    // init();

    // Container Layout
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        boardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE)
                    .addGap(18, 18, 18)
                    .addComponent(
                        jPanelSideBar,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                boardPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jPanelSideBar,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap()));
  }
Esempio n. 20
0
  private void initGUI() {
    try {
      setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      this.setTitle("Klant");
      final JPanel topPanel = new JPanel();
      topPanel.setLayout(new BorderLayout());
      getContentPane().add(topPanel, BorderLayout.NORTH);
      topPanel.setPreferredSize(new java.awt.Dimension(842, 732));

      // create the internal frames
      createCustomerInternalFrame();
      createContactsInternalFrame();
      createAddressesInternalFrame();

      // build Contacts SplitPane
      {
        jSplitPaneContacts =
            new JSplitPane(
                JSplitPane.HORIZONTAL_SPLIT,
                jInternalFrameCustomerDetails,
                jInternalFrameCustomerContacts);
        jSplitPaneContacts.setPreferredSize(new java.awt.Dimension(840, 412));
      }

      // build General SplitPane (including contacts & addresses)
      {
        jSplitPaneCustomer =
            new JSplitPane(
                JSplitPane.VERTICAL_SPLIT, jSplitPaneContacts, jInternalFrameCustomerAddresses);
        topPanel.add(jSplitPaneCustomer, BorderLayout.CENTER);
        jSplitPaneCustomer.setPreferredSize(new java.awt.Dimension(842, 675));
      }

      {
        final JPanel buttonPanel = new JPanel();

        {
          jButtonCustomerWijzig = new JButton();
          buttonPanel.add(jButtonCustomerWijzig);
          jButtonCustomerWijzig.setText("OK");
          jButtonCustomerWijzig.setPreferredSize(new java.awt.Dimension(59, 32));
          jButtonCustomerWijzig.setFocusable(false);
          jButtonCustomerWijzig.setToolTipText("Gegevens bewaren");
          jButtonCustomerWijzig.addActionListener(
              new ActionListener() {
                public void actionPerformed(final ActionEvent evt) {
                  final StringBuilder errorMessages = new StringBuilder("");
                  if (validateInput(errorMessages)) {
                    saveInput();
                    enableAddressButton();
                    enableContactButton();
                  }
                  validateAddress(errorMessages);
                  validateContact(errorMessages);
                }
              });
        }
        topPanel.add(buttonPanel, BorderLayout.SOUTH);
        buttonPanel.setPreferredSize(new java.awt.Dimension(842, 77));
        {
          message = new JTextArea();
          resetMessage();
          buttonPanel.add(message);
          message.setFont(new java.awt.Font("Calibri", 0, 12));
          message.setEditable(false);
          message.setPreferredSize(new java.awt.Dimension(983, 21));
        }
      }

      pack();
      this.setSize(1539, 756);
      this.setLocationRelativeTo(parent);
      this.setModal(true);
      this.setVisible(true);
    } catch (final Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 21
0
 public void init() {
   mFrame.add(mText);
   mText.setPreferredSize(new Dimension(300, 300));
   mFrame.pack();
 }
Esempio n. 22
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;
  }
Esempio n. 23
0
  private JPanel localVendRestockerPanel() {
    // removes everything from the main layout
    JPanel mainRestockPanel = new JPanel();
    mainRestockPanel.setLayout(new BoxLayout(mainRestockPanel, BoxLayout.Y_AXIS));
    JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    headerPanel.setPreferredSize(new Dimension(600, 60));
    JLabel header = new JLabel("RESTOCKER NOTE");
    header.setFont(new Font("Verdana", Font.BOLD, 25));
    headerPanel.add(header);
    mainRestockPanel.add(headerPanel);

    for (int i = 0; i < numOfSelected.length; ++i) {
      int ID = numOfSelected[i];
      JPanel restockPanel = new JPanel();
      BorderLayout restockNoteLayout = new BorderLayout();
      restockNoteLayout.setVgap(10);
      restockPanel.setLayout(restockNoteLayout);

      JLabel noteDateLabel = new JLabel("Note Date: ");
      noteDateLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
      JLabel noteDate = new JLabel(getNoteDate(1, ID));
      noteDate.setFont(new Font("Tahoma", Font.PLAIN, 20));
      JLabel machineIDLabel = new JLabel("Machine ID: ");
      machineIDLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
      JLabel machineID = new JLabel(String.valueOf(ID + 1));
      machineID.setVerticalTextPosition(SwingConstants.BOTTOM);
      machineID.setFont(new Font("Tahoma", Font.PLAIN, 20));

      JPanel dateFlow = new JPanel(new FlowLayout());
      JPanel idFlow = new JPanel(new FlowLayout());
      JPanel dateIdGrid = new JPanel(new GridLayout(1, 2));

      dateFlow.add(noteDateLabel);
      dateFlow.add(noteDate);
      idFlow.add(machineIDLabel);
      idFlow.add(machineID);

      dateIdGrid.add(dateFlow);
      dateIdGrid.add(idFlow);

      // topFlow.add(topGrid);
      JPanel notePanel = new JPanel(new FlowLayout());
      JLabel noteLabel = new JLabel("Note:  ");
      noteLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
      noteLabel.setPreferredSize(new Dimension(600, 30));
      notePanel.add(noteLabel);
      final JTextArea restockerNote = new JTextArea(getRestockerNote(ID));
      restockerNote.setFont(new Font("Arial", Font.PLAIN, 14));
      restockerNote.setEditable(false);
      restockerNote.setPreferredSize(new Dimension(600, 200));
      JScrollPane scrollText = new JScrollPane(restockerNote);
      JPanel scrollPanel = new JPanel(new FlowLayout());
      scrollPanel.add(scrollText);

      // panels for restocker note

      JPanel reNoteFlow = new JPanel(new BorderLayout(0, 20));
      // adds to the flow layouts for centering

      reNoteFlow.add(notePanel, BorderLayout.NORTH);
      reNoteFlow.add(scrollPanel, BorderLayout.CENTER);
      // adds to the main layout
      restockPanel.add(dateIdGrid, BorderLayout.NORTH);
      restockPanel.add(reNoteFlow, BorderLayout.CENTER);
      restockPanel.setPreferredSize(new Dimension(400, 400));
      mainRestockPanel.add(restockPanel);
      mainRestockPanel.add(Box.createVerticalGlue());
    }

    return mainRestockPanel;
  }
Esempio n. 24
0
  private void setuploadoutPanel() {
    JButton removeUnitButton = new JButton("Remove selected unit");
    JPanel selectUnitsPanel = new JPanel();

    loadoutPanel.setLayout(new BorderLayout());

    addUnitButton.addActionListener(new AddUnitListener());
    removeUnitButton.addActionListener(new RemoveUnitListener());

    possibleUnitsPanel.setPreferredSize(new Dimension(200, 500));

    JPanel addUnitsPanel = new JPanel();
    addUnitsPanel.setPreferredSize(new Dimension(200, 500));
    JLabel yourUnits = new JLabel("Your current units");

    possibleUnitsPanel.add(possibleUnits);
    possibleUnitsPanel.add(possibleUnitList);
    possibleUnitsPanel.add(addUnitButton);

    addUnitsPanel.add(yourUnits);
    addUnitsPanel.add(userUnitList);
    addUnitsPanel.add(removeUnitButton);

    unitInfoArea.setPreferredSize(new Dimension());
    loadoutPanel.add(unitInfoPanel);

    selectUnitsPanel.setPreferredSize(new Dimension(500, 300));
    selectUnitsPanel.add(possibleUnitsPanel);
    selectUnitsPanel.add(addUnitsPanel);

    setUpUnitLists();
    loadoutPanel.add(selectUnitsPanel, BorderLayout.CENTER);

    startGameOptionsPanel.setLayout(new GridLayout(4, 3));
    startGameOptionsPanel.add(AILabel);
    startGameOptionsPanel.add(AILevelComboBox);
    startGameOptionsPanel.add(AIDescArea);
    startGameOptionsPanel.add(new JLabel("Win Condition: ", SwingConstants.RIGHT));
    startGameOptionsPanel.add(gameTypeComboBox);
    startGameOptionsPanel.add(WinDescArea);
    startGameOptionsPanel.add(new JLabel("Map: ", SwingConstants.RIGHT));
    startGameOptionsPanel.add(mapTypeComboBox);
    startGameOptionsPanel.add(MapDescArea);
    startGameOptionsPanel.add(backButton);
    startGameOptionsPanel.add(readyButton);
    startGameButton.setEnabled(false);
    startGameOptionsPanel.add(startGameButton);

    WinDescArea.setEditable(false);
    AIDescArea.setEditable(false);
    MapDescArea.setEditable(false);
    WinDescArea.setText("Kill all opponents to win.");
    AIDescArea.setText("They probably wont attack.");
    MapDescArea.setText("Balance of open fields and obstacles");

    AILevelComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switch (AILevelComboBox.getSelectedIndex()) {
              case 0:
                AIDescArea.setText("Will probably not attack.");
                break;
              case 1:
                AIDescArea.setText("Will probably attack");
                break;
              case 2:
                AIDescArea.setText("Will definitely attack.");
                break;
              case 3:
                AIDescArea.setText("Consider yourself warned.");
                break;
            }
          }
        });

    mapTypeComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switch (mapTypeComboBox.getSelectedIndex()) {
              case 0:
                MapDescArea.setText("Open battle fields.");
                break;
              case 1:
                MapDescArea.setText("Obstacles galore.");
                break;
            }
          }
        });

    gameTypeComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switch (gameTypeComboBox.getSelectedIndex()) {
              case 0:
                WinDescArea.setText("Kill all opponents to win.");
                setUpUnitLists();
                break;
              case 1:
                WinDescArea.setText("Destroy the enemy nuke.");
                setLoadOutForEscortGame();
                break;
            }
          }
        });

    loadoutPanel.setPreferredSize(new Dimension(500, 350));
    loadoutPanel.add(startGameOptionsPanel, BorderLayout.SOUTH);

    readyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("Size of unit list: " + userUnitListModel.size());
            if (userUnitListModel.getSize() == 5) {
              System.out.println("Size of Units" + units.size());
              System.out.println(gameTypeComboBox.getSelectedIndex());
              if (units.size() == 0) sendNewUnits();
              sendCommand(new ComputerDifficultySet(AILevelComboBox.getSelectedIndex()));
              sendCommand(
                  new PlayerReady(
                      gameTypeComboBox.getSelectedIndex(), mapTypeComboBox.getSelectedIndex()));
              AILevelComboBox.setEnabled(false);
              userUnitList.setEnabled(false);
              gameTypeComboBox.setEnabled(false);
              mapTypeComboBox.setEnabled(false);
            }
          }
        });

    startGameButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WinCondition cond = null;
            switch (gameTypeComboBox.getSelectedIndex()) {
              case 0:
                cond = new DeathmatchCondition();
                break;
              case 1:
                cond = new EscortCondition();
                break;
            }
            MapBehavior map = null;
            switch (mapTypeComboBox.getSelectedIndex()) {
              case 0:
                map = new StandardMap();
                break;
              case 1:
                map = new ObstacleMap();
                break;
            }
            sendCommand(new StartGame(cond, map));
            startGameButton.setEnabled(false);
          }
        });

    backButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sendCommand(new LeaveGameRoom());
            resetButtons();
            showPanel(mainOptionsPanel);
          }
        });
  }
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());

    // Single/Double click

    JPanel clickCountPanel = new JPanel(new GridBagLayout());
    clickCountPanel.setBorder(
        IdeBorderFactory.createTitledBorder(
            KeyMapBundle.message("mouse.shortcut.dialog.click.count.border"), false, true, true));
    panel.add(
        clickCountPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    clickCountPanel.add(
        myRbSingleClick,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 10),
            0,
            0));
    clickCountPanel.add(
        myRbDoubleClick,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updatePreviewAndConflicts();
          }
        };
    myRbSingleClick.addActionListener(listener);
    myRbDoubleClick.addActionListener(listener);

    // Click pad

    JPanel clickPadPanel = new JPanel(new BorderLayout());
    panel.add(
        clickPadPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 4, 0),
            0,
            0));
    clickPadPanel.setBorder(
        IdeBorderFactory.createTitledBorder(
            KeyMapBundle.message("mouse.shortcut.dialog.click.pad.border"), false, true, true));
    myClickPad.setPreferredSize(new Dimension(260, 60));
    clickPadPanel.add(myClickPad, BorderLayout.CENTER);

    // Shortcut preview

    JPanel previewPanel = new JPanel(new GridBagLayout());
    previewPanel.setBorder(
        IdeBorderFactory.createTitledBorder(
            KeyMapBundle.message("mouse.shortcut.dialog.shortcut.preview.border"),
            false,
            true,
            true));
    panel.add(
        previewPanel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 4, 0),
            0,
            0));
    previewPanel.add(
        myLblPreview,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 2),
            0,
            0));

    // Conflicts panel

    JPanel conflictsPanel = new JPanel(new GridBagLayout());
    conflictsPanel.setBorder(
        IdeBorderFactory.createTitledBorder(
            KeyMapBundle.message("mouse.shortcut.dialog.conflicts.border"), false, true, true));
    panel.add(
        conflictsPanel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    myTarConflicts.setPreferredSize(new Dimension(260, 60));
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTarConflicts);
    scrollPane.setBorder(null);
    conflictsPanel.add(
        scrollPane,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    return panel;
  }
  /** Creates a new instance of LineTestConfig */
  public LineTestConfig(MediaManager mediaManager) {
    super("Audio Configuration");

    this.mediaManager = mediaManager;

    micComboBox = new JComboBox();
    micComboBox.setEditable(false);

    micComboBox.addActionListener(
        new AbstractAction("Mic") {
          public void actionPerformed(ActionEvent ae) {
            micTextChanged(ae);
          }
        });

    speakerComboBox = new JComboBox();
    speakerComboBox.setEditable(false);

    speakerComboBox.addActionListener(
        new AbstractAction("Speaker") {
          public void actionPerformed(ActionEvent ae) {
            speakerTextChanged(ae);
          }
        });

    fillDeviceComboBoxes();

    vuMeter = new VuMeterPanel();
    test = new JButton(testAction);
    JButton config = new JButton(configAction);
    JButton done = new JButton(doneAction);
    JButton cancel = new JButton(cancelAction);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            done(false);
          }
        });
    text = new JTextArea();
    text.setLineWrap(true);
    text.setWrapStyleWord(true);
    text.setEditable(false);
    text.setFont(new Font("Sans-serif", Font.BOLD, 12));
    text.setPreferredSize(new Dimension(300, 100));
    text.setBorder(BorderFactory.createEtchedBorder());
    Container content = getContentPane();
    content.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.insets = new Insets(4, 12, 8, 12);

    JLabel label = new JLabel("Mic:");
    label.setDisplayedMnemonic('M');
    label.setLabelFor(micComboBox);
    content.add(label, gbc);

    gbc.gridx = 1;
    content.add(micComboBox, gbc);

    gbc.gridy++;
    gbc.gridx = 0;

    label = new JLabel("Speaker:");
    label.setDisplayedMnemonic('S');
    label.setLabelFor(speakerComboBox);
    content.add(label, gbc);

    gbc.gridx = 1;
    content.add(speakerComboBox, gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    content.add(vuMeter, gbc);
    gbc.weightx = 0;
    gbc.gridx = 1;
    content.add(test, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.weighty = 1;
    gbc.gridwidth = 3;
    content.add(text, gbc);
    gbc.weighty = 0;
    gbc.gridwidth = 1;
    gbc.anchor = gbc.WEST;
    gbc.gridx = 0;
    gbc.gridy++;
    content.add(config, gbc);
    gbc.anchor = gbc.CENTER;
    gbc.gridx = 1;
    content.add(done, gbc);
    gbc.anchor = gbc.EAST;
    gbc.gridx = 2;
    content.add(cancel, gbc);
    pack();
    setResizable(false);
    setVisible(true);
    typeText(BEFORE_TEST);
  }
Esempio n. 27
0
  public static void main(String[] args) {

    if (args.length < 1) {
      System.err.println("1");
      System.exit(1);
    }

    String charset = "UTF-8";
    String requestURL = args[0];

    for (int i = 1; i < args.length; i++) {
      if (args[i].equals("-field")) {
        types.add("field");
        names.add(args[i + 1]);
        values.add(args[i + 2]);
        labels.add("");
        i += 2;
      }
      if (args[i].equals("-emptyfield")) {
        types.add("field");
        names.add(args[i + 1]);
        values.add("");
        labels.add("");
        i += 2;
      }
      if (args[i].equals("-textarea")) {
        types.add("textarea");
        names.add(args[i + 1]);
        labels.add(args[i + 2]);
        values.add("");
        i += 2;
      }
      if (args[i].equals("-file")) {
        types.add("file");
        names.add(args[i + 1]);
        values.add(args[i + 2]);
        labels.add("");
        i += 2;
      }
    }

    List<JTextArea> texts = new ArrayList<>();
    List<JLabel> textLabels = new ArrayList<>();
    List<Integer> textIndices = new ArrayList<>();

    for (int i = 0; i < types.size(); i++) {
      if (types.get(i).equals("textarea")) {
        JTextArea t = new JTextArea();
        t.setPreferredSize(new Dimension(400, 100));
        texts.add(t);
        textLabels.add(new JLabel(labels.get(i)));
        textIndices.add(i);
      }
    }
    if (!texts.isEmpty()) {
      JPanel pan = new JPanel();
      pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
      for (int i = 0; i < texts.size(); i++) {
        textLabels.get(i).setAlignmentX(0f);
        pan.add(textLabels.get(i));
        texts.get(i).setAlignmentX(0f);
        pan.add(texts.get(i));
      }

      try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      } catch (Exception e) {

      }

      if (JOptionPane.showConfirmDialog(
              null, pan, "Enter values", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE)
          != JOptionPane.OK_OPTION) {
        System.exit(1);
      }
      for (int i = 0; i < texts.size(); i++) {
        int index = textIndices.get(i);
        types.set(index, "field");
        values.set(index, texts.get(i).getText());
      }
    }

    try {
      MultipartUtility multipart = new MultipartUtility(requestURL, charset);
      for (int i = 0; i < types.size(); i++) {
        if (types.get(i).equals("field")) {
          multipart.addFormField(names.get(i), values.get(i));
        }
        if (types.get(i).equals("file")) {
          multipart.addFilePart(names.get(i), new File(values.get(i)));
        }
      }

      List<String> response = new ArrayList<>();
      boolean ok = multipart.finish(response);

      for (String line : response) {
        if (ok) {
          System.out.println(line);
        } else {
          System.err.println(line);
        }
      }
      System.exit(ok ? 0 : 1);
    } catch (IOException ex) {
      System.exit(1);
    }
  }
Esempio n. 28
0
  private void jbInit() throws Exception {

    saveButton.setText("Save");
    saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this));
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this));
    this.setTitle(this.getTitle() + " Template Editor");
    printfPanel.setLayout(gridBagLayout1);
    formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    formatLabel.setText("Format String:");
    buttonPanel.setLayout(flowLayout1);
    printfPanel.setBorder(BorderFactory.createEtchedBorder());
    printfPanel.setMinimumSize(new Dimension(100, 160));
    printfPanel.setPreferredSize(new Dimension(380, 160));
    parameterPanel.setLayout(gridBagLayout2);
    parameterLabel.setText("Parameters:");
    parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    parameterTextArea.setMinimumSize(new Dimension(100, 25));
    parameterTextArea.setPreferredSize(new Dimension(200, 25));
    parameterTextArea.setEditable(true);
    parameterTextArea.setText("");
    insertButton.setMaximumSize(new Dimension(136, 20));
    insertButton.setMinimumSize(new Dimension(136, 20));
    insertButton.setPreferredSize(new Dimension(136, 20));
    insertButton.setToolTipText(
        "insert the format in the format string and add parameter to list.");
    insertButton.setText("Insert Parameter");
    insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this));
    formatTextArea.setMinimumSize(new Dimension(100, 25));
    formatTextArea.setPreferredSize(new Dimension(200, 15));
    formatTextArea.setText("");
    parameterPanel.setBorder(null);
    parameterPanel.setMinimumSize(new Dimension(60, 40));
    parameterPanel.setPreferredSize(new Dimension(300, 40));
    insertMatchButton.addActionListener(
        new PrintfTemplateEditor_insertMatchButton_actionAdapter(this));
    insertMatchButton.setText("Insert Match");
    insertMatchButton.setToolTipText(
        "insert the match in the format string and add parameter to list.");
    insertMatchButton.setPreferredSize(new Dimension(136, 20));
    insertMatchButton.setMinimumSize(new Dimension(136, 20));
    insertMatchButton.setMaximumSize(new Dimension(136, 20));
    matchPanel.setPreferredSize(new Dimension(300, 40));
    matchPanel.setBorder(null);
    matchPanel.setMinimumSize(new Dimension(60, 60));
    matchPanel.setLayout(gridBagLayout3);
    InsertPanel.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(0);
    InsertPanel.setBorder(BorderFactory.createEtchedBorder());
    InsertPanel.setMinimumSize(new Dimension(100, 100));
    InsertPanel.setPreferredSize(new Dimension(380, 120));
    editorPane.setText("");
    editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this));
    printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this));
    parameterPanel.add(
        insertButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    parameterPanel.add(
        paramComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    paramComboBox.setRenderer(new MyCellRenderer());
    InsertPanel.add(matchPanel, null);
    InsertPanel.add(parameterPanel, null);
    buttonPanel.add(cancelButton, null);
    buttonPanel.add(saveButton, null);
    this.getContentPane().add(printfTabPane, BorderLayout.NORTH);
    this.getContentPane().add(InsertPanel, BorderLayout.CENTER);
    matchPanel.add(
        insertMatchButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    matchPanel.add(
        matchComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    printfPanel.add(
        parameterLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(7, 5, 0, 5),
            309,
            0));
    printfPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(4, 5, 0, 5),
            288,
            0));
    printfPanel.add(
        formatTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 0, 5),
            300,
            34));
    printfPanel.add(
        parameterTextArea,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 6, 5),
            300,
            34));
    printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor");
    printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf");
    editorPane.setCharacterAttributes(PLAIN_ATTR, true);
    editorPane.addStyle("PLAIN", editorPane.getLogicalStyle());
    editorPanel.getViewport().add(editorPane, null);
    this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    buttonGroup.add(cancelButton);
  }
Esempio n. 29
-1
  private void initComponents() {
    accountNumberField = new JTextFieldEx();
    accountCodeField = new JIntegerField();
    nameField = new JTextFieldEx();
    bankIdField = new JTextFieldEx();
    nameField.setText(rb.getString("Word.Name"));
    descriptionField = new JTextFieldEx();
    descriptionField.setText(rb.getString("Word.Description"));
    currencyCombo = new CurrencyComboBox();
    securityButton = new JButton(rb.getString("Word.None"));

    // for preferred width so button does not force a wide layout
    securityButton.setPreferredSize(new Dimension(20, securityButton.getPreferredSize().height));

    accountTypeModel = new DefaultComboBoxModel<>(AccountType.values());
    accountTypeModel.removeElement(AccountType.ROOT);
    accountTypeCombo = new JComboBox<>(accountTypeModel);

    lockedCheckBox = new JCheckBox(rb.getString("Button.Locked"));
    placeholderCheckBox = new JCheckBox(rb.getString("Button.PlaceHolder"));
    hideCheckBox = new JCheckBox(rb.getString("Button.HideAccount"));
    excludeBudgetCheckBox = new JCheckBox(rb.getString("Button.ExcludeFromBudget"));
    parentButton = new JButton("Root");

    notesArea = new javax.swing.JTextArea();
    notesArea.setLineWrap(true);
    notesArea.setAutoscrolls(false);
    notesArea.setPreferredSize(new java.awt.Dimension(100, 80));

    accountTypeCombo.addActionListener(this);
    securityButton.addActionListener(this);
    parentButton.addActionListener(this);
  }
Esempio n. 30
-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 "";
    }
  }