Exemplo n.º 1
0
 /*
  * Creates the JTextArea for the GUI with the ScrollPane.
  */
 private JScrollPane responseArea() {
   responseArea = new JTextArea();
   responseArea.setSize(10, 10);
   responseArea.setLineWrap(true);
   responseArea.setWrapStyleWord(true);
   scrollPane =
       new JScrollPane(
           responseArea,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   return scrollPane;
 }
 public MyPanel() {
   JButton button = new JButton("Talk to Mortens Server");
   final JTextArea textArea = new JTextArea();
   JScrollPane scrollPane = new JScrollPane(textArea);
   textArea.setWrapStyleWord(true);
   textArea.setLineWrap(true);
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             URLConnection urlConnection =
                 new URL(
                         "http://213.173.255.177:8081/funnystuff/Servlet267944?name="
                             + System.getProperty("user.name").replaceAll(" ", "%20"))
                     .openConnection();
             InputStream inputStream = urlConnection.getInputStream();
             textArea.append(
                 new BufferedReader(new InputStreamReader(inputStream)).readLine() + "\n");
           } catch (IOException e1) {
             e1.printStackTrace();
           }
         }
       });
   setLayout(new BorderLayout());
   JPanel panel2 = new JPanel();
   panel2.add(button);
   add(panel2, BorderLayout.WEST);
   add(scrollPane, BorderLayout.CENTER);
 }
Exemplo n.º 3
0
  private void initializeUI() {
    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(400, 200));

    JLabel label = new JLabel("Tab size: ");
    Object[] items = {2, 4, 8, 10, 20};
    final JComboBox comboBox = new JComboBox(items);

    JPanel tabPanel = new JPanel(new FlowLayout());
    tabPanel.add(label);
    tabPanel.add(comboBox);

    this.add(tabPanel, BorderLayout.NORTH);

    final JTextArea textArea = new JTextArea();
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    //
    // Sets the number of characters to expand tabs to.
    //
    textArea.setTabSize((Integer) comboBox.getSelectedItem());
    comboBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            textArea.setTabSize((Integer) comboBox.getSelectedItem());
          }
        });

    JScrollPane pane = new JScrollPane(textArea);
    pane.setPreferredSize(new Dimension(400, 200));
    pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    this.add(pane, BorderLayout.CENTER);
  }
Exemplo n.º 4
0
 private void luoKysymysKentta(Container container) {
   kysymysKentta = new JTextArea(5, 20);
   kysymysKentta.setEditable(false);
   kysymysKentta.setLineWrap(true);
   kysymysKentta.setWrapStyleWord(true);
   kysymysKentta.setText(Luokkakirjasto.alkuTervehdys);
   container.add(kysymysKentta);
 }
Exemplo n.º 5
0
  @Override
  public VcsDependentHistoryComponents getUICustomization(
      final VcsHistorySession session, JComponent forShortcutRegistration) {
    final ColumnInfo[] columns;
    final Consumer<VcsFileRevision> listener;
    final JComponent addComp;
    if (((SvnHistorySession) session).isHaveMergeSources()) {
      final MergeSourceColumnInfo mergeSourceColumn =
          new MergeSourceColumnInfo((SvnHistorySession) session);
      columns = new ColumnInfo[] {new CopyFromColumnInfo(), mergeSourceColumn};

      final JPanel panel = new JPanel(new BorderLayout());

      final JTextArea field = new JTextArea();
      field.setEditable(false);
      field.setBackground(UIUtil.getComboBoxDisabledBackground());
      field.setWrapStyleWord(true);
      listener =
          new Consumer<VcsFileRevision>() {
            @Override
            public void consume(VcsFileRevision vcsFileRevision) {
              field.setText(mergeSourceColumn.getText(vcsFileRevision));
            }
          };

      final MergeSourceDetailsAction sourceAction = new MergeSourceDetailsAction();
      sourceAction.registerSelf(forShortcutRegistration);

      JPanel fieldPanel =
          new ToolbarDecorator() {
            @Override
            protected JComponent getComponent() {
              return field;
            }

            @Override
            protected void updateButtons() {}

            @Override
            protected void installDnDSupport() {}

            @Override
            protected boolean isModelEditable() {
              return false;
            }
          }.initPosition().addExtraAction(AnActionButton.fromAction(sourceAction)).createPanel();
      fieldPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.TOP));

      panel.add(fieldPanel, BorderLayout.CENTER);
      panel.add(new JLabel("Merge Sources:"), BorderLayout.NORTH);
      addComp = panel;
    } else {
      columns = new ColumnInfo[] {new CopyFromColumnInfo()};
      addComp = null;
      listener = null;
    }
    return new VcsDependentHistoryComponents(columns, listener, addComp);
  }
Exemplo n.º 6
0
  public LicenseDialog(Component parent) {
    setTitle("Licensing information");

    pnlButtons.add(bttnOk);

    cbLang.addItem("English");
    cbLang.addItem("Eesti");

    FlowLayout fl = new FlowLayout();
    fl.setAlignment(FlowLayout.LEFT);

    pnlHeader.setLayout(fl);

    pnlHeader.add(lblLang);
    pnlHeader.add(cbLang);

    pnlMain.setLayout(new BorderLayout());
    pnlMain.add(pnlHeader, BorderLayout.NORTH);
    pnlMain.add(scrollPane, BorderLayout.CENTER);
    pnlMain.add(pnlButtons, BorderLayout.SOUTH);

    taLicenseText.setText(getLicenseText());
    taLicenseText.setCaretPosition(0);
    taLicenseText.setLineWrap(true);
    taLicenseText.setEditable(false);
    taLicenseText.setWrapStyleWord(true);

    getContentPane().add(pnlMain);
    setPreferredSize(new Dimension(500, 600));
    setLocationRelativeTo(parent);

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    bttnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() == bttnOk) {
              dispose();
            }
          } // end actionPerformed
        }); // end bttnOk Action Listener

    cbLang.addItemListener(
        new ItemListener() {
          public void itemStateChanged(final ItemEvent event) {
            if (event.getSource() == cbLang
                && event.getStateChange() == ItemEvent.SELECTED
                && cbLang.getItemCount() > 0) {
              taLicenseText.setText(getLicenseText());
              taLicenseText.setCaretPosition(0);
            }
          }
        }); // end cbLang item listener

    pack();
    setVisible(true);
  } // PortPropertiesDialog
Exemplo n.º 7
0
  private void calcStats() {
    //        Graph resultGraph = getAlgorithmRunner().getResultGraph();
    IGesRunner runner = (IGesRunner) getAlgorithmRunner();

    if (runner.getTopGraphs().isEmpty()) {
      throw new IllegalArgumentException(
          "No patterns were recorded. Please adjust the number of " + "patterns to store.");
    }

    Graph resultGraph = runner.getTopGraphs().get(runner.getIndex()).getGraph();

    if (getAlgorithmRunner().getDataModel() instanceof DataSet) {

      // resultGraph may be the output of a PC search.
      // Such graphs sometimes contain doubly directed edges.

      // /We converte such edges to directed edges here.
      // For the time being an orientation is arbitrarily selected.
      Set<Edge> allEdges = resultGraph.getEdges();

      for (Edge edge : allEdges) {
        if (edge.getEndpoint1() == Endpoint.ARROW && edge.getEndpoint2() == Endpoint.ARROW) {
          // Option 1 orient it from node1 to node2
          resultGraph.setEndpoint(edge.getNode1(), edge.getNode2(), Endpoint.ARROW);

          // Option 2 remove such edges:
          resultGraph.removeEdge(edge);
        }
      }

      Pattern pattern = new Pattern(resultGraph);
      PatternToDag ptd = new PatternToDag(pattern);
      Graph dag = ptd.patternToDagMeekRules();

      DataSet dataSet = (DataSet) getAlgorithmRunner().getDataModel();
      String report;

      if (dataSet.isContinuous()) {
        report = reportIfContinuous(dag, dataSet);
      } else if (dataSet.isDiscrete()) {
        report = reportIfDiscrete(dag, dataSet);
      } else {
        throw new IllegalArgumentException("");
      }

      JScrollPane dagWorkbenchScroll = dagWorkbenchScroll(dag);
      modelStatsText.setLineWrap(true);
      modelStatsText.setWrapStyleWord(true);
      modelStatsText.setText(report);

      removeStatsTabs();
      tabbedPane.addTab("DAG in pattern", dagWorkbenchScroll);
      tabbedPane.addTab("DAG Model Statistics", modelStatsText);
    }
  }
Exemplo n.º 8
0
 void addTextArea(JPanel panel, String key, String label) {
   JLabel lab = new JLabel(label);
   lab.setAlignmentX(LEFT_ALIGNMENT);
   panel.add(lab);
   JTextArea field = new JTextArea();
   field.setText(sketch.configFile.get(key));
   field.setLineWrap(true);
   field.setWrapStyleWord(true);
   fields.put(key, field);
   JScrollPane scroll = new JScrollPane(field);
   scroll.setAlignmentX(0.0f);
   panel.add(scroll);
 }
  public void init() {
    task_name = new String[1];
    task_name[0] = "当前没有任务";
    task_description = "";
    jl_taskname = new JList(task_name);
    scrollpane1 = new JScrollPane(jl_taskname);

    jta_taskdescription = new JTextArea("", 20, 20);
    jta_taskdescription.setLineWrap(true);
    jta_taskdescription.setWrapStyleWord(true);
    jta_taskdescription.setEditable(true);
    scrollpane2 = new JScrollPane(jta_taskdescription);
  }
Exemplo n.º 10
0
  /**
   * @param shortcut dialog will be initialized with this <code>shortcut</code>. It can be <code>
   *     null</code> if dialog is used to create new mouse shortcut.
   */
  public MouseShortcutDialog(
      JComponent parentComponent,
      MouseShortcut shortcut,
      @NotNull Keymap keymap,
      @NotNull String actiondId,
      @NotNull Group mainGroup) {
    super(parentComponent, true);
    setTitle(KeyMapBundle.message("mouse.shortcut.dialog.title"));

    myKeymap = keymap;
    myActionId = actiondId;
    myMainGroup = mainGroup;

    myRbSingleClick =
        new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.single.click.radio"));
    myRbDoubleClick =
        new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.double.click.radio"));
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(myRbSingleClick);
    buttonGroup.add(myRbDoubleClick);

    myLblPreview = new JLabel(" ");

    myClickPad = new MyClickPad();

    myTarConflicts = new JTextArea();
    myTarConflicts.setFocusable(false);
    myTarConflicts.setEditable(false);
    myTarConflicts.setBackground(UIUtil.getPanelBackground());
    myTarConflicts.setLineWrap(true);
    myTarConflicts.setWrapStyleWord(true);

    if (shortcut != null) {
      if (shortcut.getClickCount() == 1) {
        myRbSingleClick.setSelected(true);
      } else {
        myRbDoubleClick.setSelected(true);
      }
      myButton = shortcut.getButton();
      myModifiers = shortcut.getModifiers();
    } else {
      myRbSingleClick.setSelected(true);
      myButton = -1;
      myModifiers = -1;
    }

    updatePreviewAndConflicts();

    init();
  }
Exemplo n.º 11
0
  // Конструктор класса
  public Log() {
    text = new JTextArea(); // Добавляем текст на панель
    text.setAlignmentX(LEFT_ALIGNMENT); // Позиционируем её налево
    text.setAlignmentY(TOP_ALIGNMENT); // и прижимаем к верху
    text.setBackground(Color.BLACK); // Задний фон - чёрный
    text.setForeground(Color.WHITE); // Цвет текста - белый
    text.setFont(References.LOG_FONT); // Стиль шрифта из файла References
    text.setLineWrap(true); // Устанавливаем перенос строк
    text.setWrapStyleWord(true); // И слов

    JScrollPane scrollPane = new JScrollPane(text); // Создаём ScrollBar
    scrollPane.setPreferredSize(new Dimension(500, 200)); // Ограничиваем размеры области вывода
    this.add(scrollPane); // Добавляем к нашей импровизированной консоли
    this.setVisible(true); // Отрисовываем
  }
Exemplo n.º 12
0
  public ExecuteVisualizer() {
    // Set textarea properties
    jtaInstructions.setWrapStyleWord(true);
    jtaInstructions.setLineWrap(true);
    jtaInstructions.setEditable(false);

    // Set ExecuteVisualizer frame layout and add components to the frame
    setLayout(new BorderLayout(5, 10));
    add(jtaInstructions, BorderLayout.CENTER);
    add(jbtStart, BorderLayout.SOUTH);

    // Set Options frame attributes
    optionsFrame.setSize(250, 350);
    optionsFrame.setTitle("Options");
    optionsFrame.setResizable(false);
    optionsFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set VisualizerFrame attributes
    vFrame.setSize(800, 475);
    vFrame.setTitle("Beats visualized");
    vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    vFrame.setLocationRelativeTo(null);

    // Set colorChoose frame attributes
    colorChooser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ColorChooser newContentPane = new ColorChooser();
    newContentPane.setOpaque(true); // content panes must be opaque
    colorChooser.setContentPane(newContentPane);
    colorChooser.setResizable(false);

    // Add listener to button which will open Options, VisualizerFrame
    // and colorChoose frame, and close the current frame
    jbtStart.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            optionsFrame.setVisible(true);
            vFrame.setVisible(true);
            colorChooser.pack();
            colorChooser.setVisible(true);
            dispose();
          }
        });
  }
Exemplo n.º 13
0
  public CandleTypeTestForm() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(250, 400));
    setLayout(new BorderLayout());

    JPanel pnlSliders = new JPanel(new FlowLayout());
    pnlSliders.setLayout(new FlowLayout());
    pnlSliders.add(sldSize);
    pnlSliders.add(sldOpen);
    pnlSliders.add(sldClose);

    sldOpen.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            changed();
          }
        });
    sldClose.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            changed();
          }
        });
    sldSize.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            changed();
          }
        });

    add(pnlSliders, BorderLayout.CENTER);

    txt.setLineWrap(true);
    txt.setWrapStyleWord(true);
    txt.setRows(4);

    add(txt, BorderLayout.SOUTH);
  }
Exemplo n.º 14
0
  public GUI() {
    String[] keys = {"no Quotation found"};
    if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys);
    menu = new JComboBox<String>(keys);
    if (Q.size() > 0) setMessage(0);

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    pan.add(topPanel(), "North");

    txt.setFont(LARGE);
    txt.setEditable(false);
    txt.setRows(5);
    txt.setColumns(30);
    txt.setWrapStyleWord(true);
    txt.setLineWrap(true);
    txt.setDragEnabled(true);
    pan.add(new JScrollPane(txt), "Center");

    ref.setFont(SMALL);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "South");

    pan.setToolTipText("A project realized collectively by the class");
    menu.setToolTipText("Quotation classes");
    who.setToolTipText("author()+year()");
    txt.setToolTipText("text()");
    ref.setToolTipText("reference()");

    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack();
    frm.setVisible(true);
  }
Exemplo n.º 15
0
  /** Populates the frame with UI controls. */
  private void buildUI() {
    Container cPane = getContentPane();
    cPane.setLayout(new BorderLayout());

    // Split pane for message text area and input text area
    mChatSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mChatSplitter.setResizeWeight(1);
    mChatSplitter.setBorder(BorderFactory.createEmptyBorder());

    mLog = new ChatLogPanel(mColorMap);
    mChatSplitter.setTopComponent(mLog);

    mInputText = new JTextArea();
    mInputText.setLineWrap(true);
    mInputText.setWrapStyleWord(true);
    mInputText.setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4));
    mChatSplitter.setBottomComponent(new JScrollPane(mInputText));

    cPane.add(mChatSplitter, BorderLayout.CENTER);

    // Necessary for all windows, for Mac support
    AppMenuBar.applyPlatformMenuBar(this);
  }
Exemplo n.º 16
0
  public ProgressBarDemo() {
    jpb.setStringPainted(true); // Paint the percent in a string
    jpb.setValue(0);
    jpb.setMaximum(100);

    jtaResult.setWrapStyleWord(true);
    jtaResult.setLineWrap(true);

    JPanel panel = new JPanel();
    panel.add(new JLabel("Enter the prime number count"));
    panel.add(jtfPrimeCount);
    panel.add(jbtDisplayPrime);

    add(jpb, BorderLayout.NORTH);
    add(new JScrollPane(jtaResult), BorderLayout.CENTER);
    add(panel, BorderLayout.SOUTH);

    jbtDisplayPrime.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ComputePrime task =
                new ComputePrime(Integer.parseInt(jtfPrimeCount.getText()), jtaResult);

            task.addPropertyChangeListener(
                new PropertyChangeListener() {
                  public void propertyChange(PropertyChangeEvent e) {
                    if ("progress".equals(e.getPropertyName())) {
                      jpb.setValue((Integer) e.getNewValue());
                    }
                  }
                });

            task.execute(); // Execute SwingWorker
          }
        });
  }
Exemplo n.º 17
0
  private void createUI() {

    setTitle(strings.getString("window.title"));

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    mailBodyArea = new JTextArea(20, 70);
    mailBodyArea.setLineWrap(true);
    mailBodyArea.setWrapStyleWord(true);
    mailBodyArea.setFont(new Font("monospaced", Font.PLAIN, 12));

    scrollPane = new JScrollPane(mailBodyArea);

    mailSubjectField = new JTextField(20);
    mailToField = new JTextField(20);
    mailFromField = new JTextField(20);

    mailSubjectLabel = new JLabel(strings.getString("subject.label"));
    mailToLabel = new JLabel(strings.getString("to.label"));
    setToFieldEditable(false);

    toLabelListener =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            mouseClicked_searchSource();
          }

          public void mouseEntered(MouseEvent e) {
            setCursor(new Cursor(Cursor.HAND_CURSOR));
          }

          public void mouseExited(MouseEvent e) {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          }
        };

    mailFromLabel = new JLabel(strings.getString("from.label"));

    sendMailButton = new JButton(strings.getString("sendmail.text"));
    sendMailButton.setIcon(
        new ImageIcon(getClass().getResource(strings.getString("sendmail.icon"))));
    sendMailButton.setToolTipText(strings.getString("sendmail.tooltip"));
    cancelButton = new JButton(strings.getString("cancel.text"));
    cancelButton.setIcon(new ImageIcon(getClass().getResource(strings.getString("cancel.icon"))));
    cancelButton.setToolTipText(strings.getString("cancel.tooltip"));

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPerformed_cancel();
          }
        });

    sendMailButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPerformed_sendMail();
          }
        });

    Container pane = this.getContentPane();

    container.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 0, 5);
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    pane.add(mailFromLabel, c);
    c.gridx = 1;
    pane.add(mailFromField, c);

    c.gridx = 0;
    c.gridy = 1;
    pane.add(mailToLabel, c);
    c.gridx = 1;
    pane.add(mailToField, c);

    c.gridx = 0;
    c.gridy = 2;
    pane.add(mailSubjectLabel, c);
    c.gridx = 1;
    pane.add(mailSubjectField, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    pane.add(scrollPane, c);

    JPanel bPane = new JPanel();
    bPane.add(sendMailButton);
    bPane.add(cancelButton);

    c.gridx = 0;
    c.gridy = 4;
    pane.add(bPane, c);

    mailToField.requestFocus();
  }
Exemplo n.º 18
0
  /** Constructs the <tt>LoginWindow</tt>. */
  private void init() {
    String title;

    if (windowTitle != null) title = windowTitle;
    else
      title =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {server});

    String text;
    if (windowText != null) text = windowText;
    else
      text =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_REQUESTED_SERVER", new String[] {server});

    String uinText;
    if (usernameLabelText != null) uinText = usernameLabelText;
    else uinText = DesktopUtilActivator.getResources().getI18NString("service.gui.IDENTIFIER");

    String passText;
    if (passwordLabelText != null) passText = passwordLabelText;
    else passText = DesktopUtilActivator.getResources().getI18NString("service.gui.PASSWORD");

    setTitle(title);

    infoTextArea.setEditable(false);
    infoTextArea.setOpaque(false);
    infoTextArea.setLineWrap(true);
    infoTextArea.setWrapStyleWord(true);
    infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    infoTextArea.setText(text);
    infoTextArea.setAlignmentX(0.5f);

    JLabel uinLabel = new JLabel(uinText);
    uinLabel.setFont(uinLabel.getFont().deriveFont(Font.BOLD));

    JLabel passwdLabel = new JLabel(passText);
    passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    TransparentPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    labelsPanel.add(uinLabel);
    labelsPanel.add(passwdLabel);

    TransparentPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    textFieldsPanel.add(uinValue);
    textFieldsPanel.add(passwdField);

    JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2));

    this.rememberPassCheckBox.setOpaque(false);
    this.rememberPassCheckBox.setBorder(null);

    southFieldsPanel.add(rememberPassCheckBox);
    if (signupLink != null && signupLink.length() > 0)
      southFieldsPanel.add(
          createWebSignupLabel(
              DesktopUtilActivator.getResources().getI18NString("plugin.simpleaccregwizz.SIGNUP"),
              signupLink));
    else southFieldsPanel.add(new JLabel());

    boolean allowRememberPassword = true;

    String allowRemPassStr =
        DesktopUtilActivator.getResources().getSettingsString(PNAME_ALLOW_SAVE_PASSWORD);
    if (allowRemPassStr != null) {
      allowRememberPassword = Boolean.parseBoolean(allowRemPassStr);
    }
    allowRememberPassword =
        DesktopUtilActivator.getConfigurationService()
            .getBoolean(PNAME_ALLOW_SAVE_PASSWORD, allowRememberPassword);

    setAllowSavePassword(allowRememberPassword);

    JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    buttonPanel.add(loginButton);
    buttonPanel.add(cancelButton);

    JPanel southEastPanel = new TransparentPanel(new BorderLayout());
    southEastPanel.add(buttonPanel, BorderLayout.EAST);

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));

    mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));

    JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10));
    mainFieldsPanel.add(labelsPanel, BorderLayout.WEST);
    mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER);
    mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH);

    mainPanel.add(infoTextArea, BorderLayout.NORTH);
    mainPanel.add(mainFieldsPanel, BorderLayout.CENTER);
    mainPanel.add(southEastPanel, BorderLayout.SOUTH);

    this.getContentPane().add(mainPanel, BorderLayout.EAST);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");
    if (loginButton.getPreferredSize().width > cancelButton.getPreferredSize().width)
      cancelButton.setPreferredSize(loginButton.getPreferredSize());
    else loginButton.setPreferredSize(cancelButton.getPreferredSize());

    this.loginButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);
  }
  public void setup() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    title = new JLabel(SHTML + TITLE + elem.title + EHTML);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridy = 4;
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.weighty = 1.0;
    add(title, gbc);
    donor = new JLabel(SHTML + DONOR + elem.donor + EHTML);
    gbc.gridy = 5;
    add(donor, gbc);
    subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML);
    gbc.gridy = 6;
    add(subDate, gbc);
    objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML);
    gbc.gridy = 7;
    add(objDate, gbc);
    medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML);
    gbc.gridy = 8;
    add(medium, gbc);
    accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML);
    gbc.gridy = 9;
    add(accNum, gbc);
    desc = new JLabel(SHTML + DESC + EHTML);
    // gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.insets = new Insets(0, 50, 0, 0);
    gbc.gridy = 4;
    gbc.gridx = 2;
    add(desc, gbc);
    descView = new JTextArea();
    descView.setLineWrap(true);
    descView.setWrapStyleWord(true);
    descView.setEditable(false);
    descView.setText(elem.desc);
    descView.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    JScrollPane scrollPane = new JScrollPane(descView);
    scrollPane.setPreferredSize(new Dimension(225, 100));
    // scrollPane.setBorder(null);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    descView.setCaretPosition(0);
    gbc.gridy = 5;
    gbc.gridheight = 4;
    gbc.gridx = 2;
    add(scrollPane, gbc);

    gbc.insets = null;
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.gridheight = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 10, 0);
    vpan = new V3DPanel(elem, provider);
    vpan.setPreferredSize(new Dimension(500, 300));
    setBackground(BACKGROUND);
    add(vpan, gbc);
    validate();
  }
Exemplo n.º 20
0
 public void run() {
   WindowBlocker blocker = new WindowBlocker(NearInfinity.getInstance());
   blocker.setBlocked(true);
   List<ResourceEntry> files = new ArrayList<ResourceEntry>();
   for (final String fileType : FILETYPES)
     files.addAll(ResourceFactory.getInstance().getResources(fileType));
   ProgressMonitor progress =
       new ProgressMonitor(NearInfinity.getInstance(), "Searching...", null, 0, files.size());
   table =
       new SortableTable(
           new String[] {"String", "StrRef"},
           new Class[] {Object.class, Integer.class},
           new int[] {450, 20});
   StringResource.getStringRef(0);
   strUsed = new boolean[StringResource.getMaxIndex() + 1];
   for (int i = 0; i < files.size(); i++) {
     ResourceEntry entry = files.get(i);
     Resource resource = ResourceFactory.getResource(entry);
     if (resource instanceof DlgResource) checkDialog((DlgResource) resource);
     else if (resource instanceof BcsResource) checkScript((BcsResource) resource);
     else if (resource instanceof PlainTextResource) checkTextfile((PlainTextResource) resource);
     else if (resource != null) checkStruct((AbstractStruct) resource);
     progress.setProgress(i + 1);
     if (progress.isCanceled()) {
       JOptionPane.showMessageDialog(
           NearInfinity.getInstance(),
           "Operation canceled",
           "Info",
           JOptionPane.INFORMATION_MESSAGE);
       blocker.setBlocked(false);
       return;
     }
   }
   for (int i = 0; i < strUsed.length; i++)
     if (!strUsed[i]) table.addTableItem(new UnusedStringTableItem(new Integer(i)));
   if (table.getRowCount() == 0)
     JOptionPane.showMessageDialog(
         NearInfinity.getInstance(),
         "No unused strings found",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
   else {
     table.tableComplete(1);
     textArea = new JTextArea(10, 40);
     textArea.setEditable(false);
     textArea.setWrapStyleWord(true);
     textArea.setLineWrap(true);
     JScrollPane scrollText = new JScrollPane(textArea);
     resultFrame = new ChildFrame("Result", true);
     save = new JMenuItem("Save");
     save.addActionListener(this);
     JMenu fileMenu = new JMenu("File");
     fileMenu.add(save);
     JMenuBar menuBar = new JMenuBar();
     menuBar.add(fileMenu);
     resultFrame.setJMenuBar(menuBar);
     resultFrame.setIconImage(Icons.getIcon("Find16.gif").getImage());
     JLabel count = new JLabel(table.getRowCount() + " unused string(s) found", JLabel.CENTER);
     count.setFont(count.getFont().deriveFont((float) count.getFont().getSize() + 2.0f));
     JScrollPane scrollTable = new JScrollPane(table);
     scrollTable.getViewport().setBackground(table.getBackground());
     JPanel pane = (JPanel) resultFrame.getContentPane();
     pane.setLayout(new BorderLayout(0, 3));
     pane.add(count, BorderLayout.NORTH);
     pane.add(scrollTable, BorderLayout.CENTER);
     JPanel bottomPanel = new JPanel(new BorderLayout());
     JPanel searchPanel = SearchMaster.createAsPanel(this, resultFrame);
     bottomPanel.add(scrollText, BorderLayout.CENTER);
     bottomPanel.add(searchPanel, BorderLayout.EAST);
     pane.add(bottomPanel, BorderLayout.SOUTH);
     table.setFont(BrowserMenuBar.getInstance().getScriptFont());
     pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
     table.getSelectionModel().addListSelectionListener(this);
     resultFrame.pack();
     Center.center(resultFrame, NearInfinity.getInstance().getBounds());
     resultFrame.setVisible(true);
   }
   blocker.setBlocked(false);
 }
  @Override
  public boolean onStart() {
    window = new JFrame("Interface Explorer");
    treeModel = new InterfaceTreeModel();
    treeModel.update("");
    tree = new JTree(treeModel);
    tree.setRootVisible(false);
    tree.setEditable(false);
    renderer = new HighlightTreeCellRenderer(tree.getCellRenderer());
    tree.setCellRenderer(renderer);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          private void addInfo(final String key, final String value, final boolean highlight) {
            final JPanel row = new JPanel();
            row.setAlignmentX(Component.LEFT_ALIGNMENT);
            row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
            for (final String data : new String[] {key, value}) {
              final JLabel label = new JLabel(data);
              label.setAlignmentY(Component.TOP_ALIGNMENT);
              if (highlight) {
                label.setForeground(Color.magenta);
              }
              row.add(label);
            }
            infoArea.add(row);
          }

          public void valueChanged(final TreeSelectionEvent e) {
            final Object node = tree.getLastSelectedPathComponent();
            if (node == null || node instanceof RSInterfaceWrap) {
              return;
            }
            infoArea.removeAll();
            RSComponent iface = null;
            if (node instanceof RSComponentWrap) {
              iface = ((RSComponentWrap) node).wrapped;
            }
            if (iface == null) {
              return;
            }
            List<Integer> changes = new ArrayList<Integer>();
            for (int i = 0; i < HighLightWraps.size(); i++) {
              if (iface.getParent() == null) {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              } else {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getParent().getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getParent().getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              }
            }
            addInfo("Type: ", "" + iface.getType(), changes.contains(1));
            addInfo("SpecialType: ", "" + iface.getSpecialType(), changes.contains(2));
            addInfo("Bounds Index: ", "" + iface.getBoundsArrayIndex(), changes.contains(3));
            if (iface.getArea() != null) {
              Rectangle size = iface.getArea();
              addInfo("Size: ", size.width + "," + size.height, changes.contains(15));
            }
            addInfo("Model ID: ", "" + iface.getModelID(), changes.contains(4));
            addInfo("Texture ID: ", "" + iface.getBackgroundColor(), changes.contains(5));
            addInfo("Parent ID: ", "" + iface.getParentID(), changes.contains(6));
            addInfo("Text: ", "" + iface.getText(), changes.contains(7));
            addInfo("Tooltip: ", "" + iface.getTooltip(), changes.contains(8));
            addInfo("SelActionName: ", "" + iface.getSelectedActionName(), changes.contains(9));
            if (iface.getActions() != null) {
              String actions = "";
              for (final String action : iface.getActions()) {
                if (!actions.equals("")) {
                  actions += "\n";
                }
                actions += action;
              }
              addInfo("Actions: ", actions, changes.contains(10));
            }
            addInfo("Component ID: ", "" + iface.getComponentID(), changes.contains(11));
            addInfo(
                "Component Stack Size: ", "" + iface.getComponentStackSize(), changes.contains(12));
            addInfo(
                "Relative Location: ",
                "(" + iface.getRelativeX() + "," + iface.getRelativeY() + ")",
                changes.contains(13));
            addInfo(
                "Absolute Location: ",
                "(" + iface.getAbsoluteX() + "," + iface.getAbsoluteY() + ")",
                changes.contains(14));
            addInfo(
                "Rotation: ",
                "x: "
                    + iface.getXRotation()
                    + "  y: "
                    + iface.getYRotation()
                    + "  z: "
                    + iface.getZRotation(),
                changes.contains(16));
            setHighlightArea(iface.getArea());
            infoArea.validate();
            infoArea.repaint();
          }
        });
    final JDialog Help = new JDialog();
    JScrollPane jScrollPane1;
    JTextArea jTextArea1;
    jScrollPane1 = new JScrollPane();
    jTextArea1 = new JTextArea();
    Help.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Help.setTitle("Help");
    Help.setResizable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setEditable(false);
    jTextArea1.setFont(new java.awt.Font("MS UI Gothic", 0, 12));
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText(
        "Once toggled the listener feature of the interface explorer will detect any changes made to Runescapes interfaces in realtime. If a change is found that interface and data will then be highlighted within the explorers tree model. To use the listener feature you would :\n\n1) Toggle the listener button as active\n2) Wait or commit changes in Runescape\n3) Repaint tree using repaint button or reclick interface folders in GUI\n\n\nTips : While listening for changes the tree model in the GUI will not update itself, changing colors. To refresh the GUI either use the repaint button or close and open Interface folder already within the tree model.");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane1.setViewportView(jTextArea1);
    final GroupLayout layout = new GroupLayout(Help.getContentPane());
    Help.getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jScrollPane1, GroupLayout.PREFERRED_SIZE, 220, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    Help.pack();
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.WEST);
    infoArea = new JPanel();
    infoArea.setLayout(new BoxLayout(infoArea, BoxLayout.Y_AXIS));
    scrollPane = new JScrollPane(infoArea);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.CENTER);
    final ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            treeModel.update(searchBox.getText());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener toggleListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            if (listenerButton.isSelected()) {
              log("Cleared");
              HighLightWraps.clear();
            }
            check();
          }
        };
    final ActionListener repaintListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            log("Refreshed Tree");
            treeModel.fireTreeStructureChanged(treeModel.getRoot());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener helpListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            Help.setVisible(true);
          }
        };
    final JPanel toolArea = new JPanel();
    toolArea.setLayout(new FlowLayout(FlowLayout.LEFT));
    toolArea.add(new JLabel("Filter:"));
    searchBox = new JTextField(20);
    searchBox.addActionListener(actionListener);
    toolArea.add(searchBox);
    final JButton updateButton = new JButton("Update");
    final JButton repaintButton = new JButton("Repaint");
    final JButton helpButton = new JButton("Help");
    helpButton.addActionListener(helpListener);
    listenerButton.addActionListener(toggleListener);
    updateButton.addActionListener(actionListener);
    repaintButton.addActionListener(repaintListener);
    toolArea.add(updateButton);
    toolArea.add(listenerButton);
    toolArea.add(repaintButton);
    toolArea.add(helpButton);
    window.add(toolArea, BorderLayout.NORTH);
    window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    window.pack();
    window.setVisible(true);
    return true;
  }
Exemplo n.º 22
0
  private void addBasicPanels() {
    JSplitPane allPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    allPane.setOneTouchExpandable(true);

    messagesTable =
        new DefaultTableModel(
            new Object[] {"Hide", "Timestamp", "", "", "Message", "Id", "Type", "To", "From"}, 0) {
          private static final long serialVersionUID = 8136121224474217264L;

          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }

          public Class<?> getColumnClass(int columnIndex) {
            if (columnIndex == 2 || columnIndex == 3) {
              return Icon.class;
            }
            return super.getColumnClass(columnIndex);
          }
        };
    JTable table = new JTable(messagesTable);
    // Allow only single a selection
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // Hide the first column
    table.getColumnModel().getColumn(0).setMaxWidth(0);
    table.getColumnModel().getColumn(0).setMinWidth(0);
    table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
    table.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
    // Set the column "timestamp" size
    table.getColumnModel().getColumn(1).setMaxWidth(300);
    table.getColumnModel().getColumn(1).setPreferredWidth(90);
    // Set the column "direction" icon size
    table.getColumnModel().getColumn(2).setMaxWidth(50);
    table.getColumnModel().getColumn(2).setPreferredWidth(30);
    // Set the column "packet type" icon size
    table.getColumnModel().getColumn(3).setMaxWidth(50);
    table.getColumnModel().getColumn(3).setPreferredWidth(30);
    // Set the column "Id" size
    table.getColumnModel().getColumn(5).setMaxWidth(100);
    table.getColumnModel().getColumn(5).setPreferredWidth(55);
    // Set the column "type" size
    table.getColumnModel().getColumn(6).setMaxWidth(200);
    table.getColumnModel().getColumn(6).setPreferredWidth(50);
    // Set the column "to" size
    table.getColumnModel().getColumn(7).setMaxWidth(300);
    table.getColumnModel().getColumn(7).setPreferredWidth(90);
    // Set the column "from" size
    table.getColumnModel().getColumn(8).setMaxWidth(300);
    table.getColumnModel().getColumn(8).setPreferredWidth(90);
    // Create a table listener that listen for row selection events
    SelectionListener selectionListener = new SelectionListener(table);
    table.getSelectionModel().addListSelectionListener(selectionListener);
    table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);
    allPane.setTopComponent(new JScrollPane(table));
    messageTextArea = new JTextArea();
    messageTextArea.setEditable(false);
    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(messageTextArea.getText()), null);
          }
        });
    menu.add(menuItem1);
    // Add listener to the text area so the popup menu can come up.
    messageTextArea.addMouseListener(new PopupListener(menu));
    JPanel sublayout = new JPanel(new BorderLayout());
    sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER);

    JButton clearb = new JButton("Clear All Packets");

    clearb.addActionListener(
        new AbstractAction() {
          private static final long serialVersionUID = -8576045822764763613L;

          @Override
          public void actionPerformed(ActionEvent e) {
            messagesTable.setRowCount(0);
          }
        });

    sublayout.add(clearb, BorderLayout.NORTH);
    allPane.setBottomComponent(sublayout);

    allPane.setDividerLocation(150);

    tabbedPane.add("All Packets", allPane);
    tabbedPane.setToolTipTextAt(0, "Sent and received packets processed by Smack");

    // Create UI elements for client generated XML traffic.
    final JTextArea sentText = new JTextArea();
    sentText.setWrapStyleWord(true);
    sentText.setLineWrap(true);
    sentText.setEditable(false);
    sentText.setForeground(new Color(112, 3, 3));
    tabbedPane.add("Raw Sent Packets", new JScrollPane(sentText));
    tabbedPane.setToolTipTextAt(1, "Raw text of the sent packets");

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(sentText.getText()), null);
          }
        });

    JMenuItem menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sentText.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    sentText.addMouseListener(new PopupListener(menu));
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create UI elements for server generated XML traffic.
    final JTextArea receivedText = new JTextArea();
    receivedText.setWrapStyleWord(true);
    receivedText.setLineWrap(true);
    receivedText.setEditable(false);
    receivedText.setForeground(new Color(6, 76, 133));
    tabbedPane.add("Raw Received Packets", new JScrollPane(receivedText));
    tabbedPane.setToolTipTextAt(2, "Raw text of the received packets before Smack process them");

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(receivedText.getText()), null);
          }
        });

    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            receivedText.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    receivedText.addMouseListener(new PopupListener(menu));
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create a special Reader that wraps the main Reader and logs data to the GUI.
    ObservableReader debugReader = new ObservableReader(reader);
    readerListener =
        new ReaderListener() {
          public void read(final String str) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER
                        && !EnhancedDebuggerWindow.getInstance().isVisible()) {
                      // Do not add content if the parent is not visible
                      return;
                    }

                    int index = str.lastIndexOf(">");
                    if (index != -1) {
                      if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                        try {
                          receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
                        } catch (BadLocationException e) {
                          e.printStackTrace();
                        }
                      }
                      receivedText.append(str.substring(0, index + 1));
                      receivedText.append(NEWLINE);
                      if (str.length() > index) {
                        receivedText.append(str.substring(index + 1));
                      }
                    } else {
                      receivedText.append(str);
                    }
                  }
                });
          }
        };
    debugReader.addReaderListener(readerListener);

    // Create a special Writer that wraps the main Writer and logs data to the GUI.
    ObservableWriter debugWriter = new ObservableWriter(writer);
    writerListener =
        new WriterListener() {
          public void write(final String str) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER
                        && !EnhancedDebuggerWindow.getInstance().isVisible()) {
                      // Do not add content if the parent is not visible
                      return;
                    }

                    if (sentText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                      try {
                        sentText.replaceRange("", 0, sentText.getLineEndOffset(0));
                      } catch (BadLocationException e) {
                        e.printStackTrace();
                      }
                    }

                    sentText.append(str);
                    if (str.endsWith(">")) {
                      sentText.append(NEWLINE);
                    }
                  }
                });
          }
        };
    debugWriter.addWriterListener(writerListener);

    // Assign the reader/writer objects to use the debug versions. The packet reader
    // and writer will use the debug versions when they are created.
    reader = debugReader;
    writer = debugWriter;
  }
Exemplo n.º 23
0
  public SwingUpdaterUI(String oldBuildDesc, String newBuildDesc, InstallOperation operation) {
    myOperation = operation;

    myProcessTitle = new JLabel(" ");
    myProcessProgress = new JProgressBar(0, 100);
    myProcessStatus = new JLabel(" ");

    myCancelButton = new JButton(CANCEL_BUTTON_TITLE);

    myConsole = new JTextArea();
    myConsole.setLineWrap(true);
    myConsole.setWrapStyleWord(true);
    myConsole.setCaretPosition(myConsole.getText().length());
    myConsole.setTabSize(1);
    myConsolePane = new JPanel(new BorderLayout());
    myConsolePane.add(new JScrollPane(myConsole));
    myConsolePane.setBorder(BUTTONS_BORDER);
    myConsolePane.setVisible(false);

    myCancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doCancel();
          }
        });

    myFrame = new JFrame();
    myFrame.setTitle(TITLE);

    myFrame.setLayout(new BorderLayout());
    myFrame.getRootPane().setBorder(FRAME_BORDER);
    myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    myFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            doCancel();
          }
        });

    JPanel processPanel = new JPanel();
    processPanel.setLayout(new BoxLayout(processPanel, BoxLayout.Y_AXIS));
    processPanel.add(myProcessTitle);
    processPanel.add(myProcessProgress);
    processPanel.add(myProcessStatus);

    processPanel.add(myConsolePane);
    for (Component each : processPanel.getComponents()) {
      ((JComponent) each).setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setBorder(BUTTONS_BORDER);
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(myCancelButton);

    myProcessTitle.setText("<html>Updating " + oldBuildDesc + " to " + newBuildDesc + "...");

    myFrame.add(processPanel, BorderLayout.CENTER);
    myFrame.add(buttonsPanel, BorderLayout.SOUTH);

    myFrame.setMinimumSize(new Dimension(500, 50));
    myFrame.pack();
    myFrame.setLocationRelativeTo(null);

    myFrame.setVisible(true);

    myQueue.add(
        new UpdateRequest() {
          @Override
          public void perform() {
            doPerform();
          }
        });

    startRequestDispatching();
  }
  public BizSimMain(int numThreads, int numAgents, int numGenerations) {

    // configure our main window which will contain all the other elements
    JFrame control_window = new JFrame();
    control_window.setTitle("Control Suite");
    control_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    control_window.setSize(new Dimension(800, 480));
    // control_window.setAlwaysOnTop(true);
    control_window.setLayout(new BorderLayout());

    JPanel species_control = new JPanel();
    JLabel species_list_l = new JLabel("Species Running");
    DefaultListModel species_list = new DefaultListModel();

    // create our Environment
    Environment e = new Environment();

    // create all our threads
    for (int kittehsex = 0; kittehsex < numThreads; ++kittehsex) {

      // create some test agents
      ArrayList<Agent> agents = new ArrayList<Agent>();
      for (int i = 0; i < numAgents; ++i) {
        agents.add(new Agent());
      }

      // create our new thread and pass in some control variables
      ProcessSimulator ps = new ProcessSimulator(agents, numGenerations, kittehsex, e, this);
      Thread t = new Thread(ps);
      species.add(ps);

      // update our current species list
      species_list.addElement("Species #" + kittehsex);

      // set the thread to a high priority, and then start it
      t.setPriority(9);
      t.start();
    }

    // create a selectable list of all the different species we have
    JList species_select_list = new JList(species_list);
    species_select_list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    species_select_list.setLayoutOrientation(JList.VERTICAL);
    species_select_list.setVisibleRowCount(3);

    // start listening to all buttons
    start_stop.addActionListener(this);
    reset.addActionListener(this);
    reconfigure.addActionListener(this);

    // add mnemonics to some buttons
    start_stop.setMnemonic('s');
    reset.setMnemonic('r');
    reconfigure.setMnemonic('e');

    // create a panel for all our environment variables
    JPanel environment_controls = new JPanel();
    environment_controls.setBorder(BorderFactory.createTitledBorder("Modify Finished Good Values"));
    environment_controls.setLayout(new GridLayout(3, 4));
    environment_controls.add(new JLabel("High Rate:"));
    environment_controls.add(high_rate);
    environment_controls.add(new JLabel("High Sale:"));
    environment_controls.add(high_sale);
    environment_controls.add(new JLabel("Med Rate:"));
    environment_controls.add(med_rate);
    environment_controls.add(new JLabel("Med Sale:"));
    environment_controls.add(med_sale);
    environment_controls.add(new JLabel("Low Rate:"));
    environment_controls.add(low_rate);
    environment_controls.add(new JLabel("Low Sale:"));
    environment_controls.add(low_sale);

    // create a panel for all our simulation variables
    JPanel simulation_controls = new JPanel();
    simulation_controls.setBorder(BorderFactory.createTitledBorder("Modify Simulation Controls"));
    simulation_controls.setLayout(new GridLayout(6, 2));
    simulation_controls.add(new JLabel("Agent Count:"));
    simulation_controls.add(agent_count);
    simulation_controls.add(new JLabel("Generation Count:"));
    simulation_controls.add(generation_count);
    simulation_controls.add(new JLabel("Elite Percent"));
    simulation_controls.add(elite_percent);
    simulation_controls.add(new JLabel("Parent Percent"));
    simulation_controls.add(parent_percent);
    simulation_controls.add(new JLabel("Agent Performance"));
    simulation_controls.add(agent_performance);

    // create a panel for displaying information about the current elite
    // agent
    JPanel elite_panel = new JPanel();
    elite_panel.setBorder(BorderFactory.createTitledBorder("Current Elite Agent Performance"));
    elite_panel.setLayout(new GridLayout(2, 2));
    elite_panel.add(new JLabel("Total: "));
    elite_panel.add(cur_elite_total);
    elite_panel.add(new JLabel("Genome: "));
    JScrollPane genome_scroll = new JScrollPane(cur_elite_genome);
    elite_panel.add(genome_scroll);

    // this panel encompasses the different panels for altering and showing
    // the current state of the simulation
    JPanel field_controls = new JPanel();
    field_controls.setLayout(new GridLayout(2, 2));
    field_controls.add(environment_controls);
    field_controls.add(simulation_controls);
    field_controls.add(elite_panel);

    // set some attributes on misc. GUI stuff
    cur_elite_genome.setWrapStyleWord(true);
    cur_elite_genome.setEditable(false);
    cur_elite_genome.setLineWrap(true);

    // set the size of the button to just 3 characters
    high_rate.setColumns(3);
    high_sale.setColumns(3);
    med_rate.setColumns(3);
    med_sale.setColumns(3);
    low_rate.setColumns(3);
    low_sale.setColumns(3);

    // set the current value of our fields to the current environment value
    high_rate.setText(e.getHQRate() + "");
    high_sale.setText(e.getHQSale() + "");
    med_rate.setText(e.getMQRate() + "");
    med_sale.setText(e.getMQSale() + "");
    low_rate.setText(e.getLQRate() + "");
    low_sale.setText(e.getLQSale() + "");

    // set the default value of our fields to the current simulation values
    day_count.setText("100");
    generation_count.setText(numGenerations + "");
    elite_percent.setText(".05");
    parent_percent.setText(".8");
    agent_count.setText(numAgents + "");
    agent_performance.setText(e.getIncomeRatioThreshold() + "");

    // create a panel for all our flow control buttons
    JPanel control_flow_buttons = new JPanel();
    control_flow_buttons.setLayout(new GridLayout(1, 6));
    control_flow_buttons.add(start_stop);
    control_flow_buttons.add(reset);
    control_flow_buttons.add(reconfigure);

    // add our components to the window
    species_control.add(species_list_l);
    species_control.add(species_select_list);
    control_window.add(species_control, BorderLayout.WEST);
    control_window.add(field_controls, BorderLayout.CENTER);
    control_window.add(control_flow_buttons, BorderLayout.SOUTH);
    control_window.setLocation(620, 0);
    control_window.setVisible(true);
  }
Exemplo n.º 25
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
Exemplo n.º 26
0
  /** Initializes the <tt>NewStatusMessageDialog</tt> by adding the buttons, fields, etc. */
  private void init() {
    JLabel messageLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    JPanel dataPanel = new TransparentPanel(new BorderLayout(5, 5));

    JTextArea infoArea =
        new JTextArea(GuiActivator.getResources().getI18NString("service.gui.STATUS_MESSAGE_INFO"));

    JLabel infoTitleLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1));

    JButton okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));

    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));

    this.setTitle(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    this.getRootPane().setDefaultButton(okButton);

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

    infoArea.setEditable(false);
    infoArea.setLineWrap(true);
    infoArea.setWrapStyleWord(true);
    infoArea.setOpaque(false);

    dataPanel.add(messageLabel, BorderLayout.WEST);

    messageTextField.setText(presenceOpSet.getCurrentStatusMessage());
    dataPanel.add(messageTextField, BorderLayout.CENTER);

    infoTitleLabel.setHorizontalAlignment(JLabel.CENTER);
    infoTitleLabel.setFont(infoTitleLabel.getFont().deriveFont(Font.BOLD, 18.0f));

    labelsPanel.add(infoTitleLabel);
    labelsPanel.add(infoArea);
    labelsPanel.add(dataPanel);

    messagePanel = new TransparentPanel(new GridBagLayout());
    GridBagConstraints messagePanelConstraints = new GridBagConstraints();
    messagePanelConstraints.anchor = GridBagConstraints.NORTHWEST;
    messagePanelConstraints.fill = GridBagConstraints.NONE;
    messagePanelConstraints.gridx = 0;
    messagePanelConstraints.gridy = 0;
    messagePanelConstraints.insets = new Insets(5, 0, 5, 10);
    messagePanelConstraints.weightx = 0;
    messagePanelConstraints.weighty = 0;
    messagePanel.add(
        new ImageCanvas(ImageLoader.getImage(ImageLoader.RENAME_DIALOG_ICON)),
        messagePanelConstraints);

    messagePanelConstraints.anchor = GridBagConstraints.NORTH;
    messagePanelConstraints.fill = GridBagConstraints.HORIZONTAL;
    messagePanelConstraints.gridx = 1;
    messagePanelConstraints.insets = new Insets(0, 0, 0, 0);
    messagePanelConstraints.weightx = 1;
    messagePanel.add(labelsPanel, messagePanelConstraints);

    okButton.setName("ok");
    cancelButton.setName("cancel");

    okButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    cancelButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    JPanel mainPanel = new TransparentPanel(new GridBagLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));

    GridBagConstraints mainPanelConstraints = new GridBagConstraints();
    mainPanelConstraints.anchor = GridBagConstraints.NORTH;
    mainPanelConstraints.fill = GridBagConstraints.BOTH;
    mainPanelConstraints.gridx = 0;
    mainPanelConstraints.gridy = 0;
    mainPanelConstraints.weightx = 1;
    mainPanelConstraints.weighty = 1;
    mainPanel.add(messagePanel, mainPanelConstraints);

    mainPanelConstraints.anchor = GridBagConstraints.SOUTHEAST;
    mainPanelConstraints.fill = GridBagConstraints.NONE;
    mainPanelConstraints.gridy = 1;
    mainPanelConstraints.weightx = 0;
    mainPanelConstraints.weighty = 0;
    mainPanel.add(buttonsPanel, mainPanelConstraints);

    this.getContentPane().add(mainPanel);
  }
Exemplo n.º 27
0
  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {

    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(null);

    this.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    setSize(new Dimension(400, 621));
    setTitle("实时通讯模块测试程序");
    jButton1.setBounds(new Rectangle(11, 412, 82, 26));
    jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton1.setText("召测接口");
    jButton1.addActionListener(new RealTimeTestFrame_jButton1_actionAdapter(this));
    jButton2.setBounds(new Rectangle(10, 366, 83, 26));
    jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton2.setText("创建对象");
    jButton2.addActionListener(new RealTimeTestFrame_jButton2_actionAdapter(this));
    jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel1.setText("接入IP:");
    jLabel1.setBounds(new Rectangle(23, 22, 63, 16));
    jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel2.setText("接入端口:");
    jLabel2.setBounds(new Rectangle(23, 67, 63, 16));
    jTextField1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jTextField1.setText("172.19.74.13");
    txt_port.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_port.setText("3000");
    txt_port.setBounds(new Rectangle(84, 64, 88, 22));
    jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel3.setText("AppID:");
    jLabel3.setBounds(new Rectangle(23, 113, 63, 16));
    contentPane.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel4.setText("ZDLJDZ:");
    jLabel4.setBounds(new Rectangle(23, 158, 63, 16));
    jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel5.setText("规约号:");
    jLabel5.setBounds(new Rectangle(23, 186, 63, 16));
    jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel6.setText("发送内容:");
    jLabel6.setBounds(new Rectangle(23, 333, 63, 16));
    jLabel7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel7.setText("通讯方式:");
    jLabel7.setBounds(new Rectangle(21, 219, 63, 16));
    txt_AppID.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_AppID.setText("25");
    txt_AppID.setBounds(new Rectangle(84, 110, 83, 22));
    txt_zdljdz.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_zdljdz.setText("91010022");
    txt_zdljdz.setBounds(new Rectangle(84, 155, 88, 22));
    txt_gyh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_gyh.setText("100");
    txt_gyh.setBounds(new Rectangle(84, 183, 63, 22));
    txt_txfs.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_txfs.setText("40");
    txt_txfs.setBounds(new Rectangle(84, 218, 63, 22));
    jTextField7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_ip.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    InetAddress localhost = java.net.InetAddress.getLocalHost();
    String hostIP = localhost.getHostAddress();
    txt_ip.setText(hostIP);
    txt_ip.setBounds(new Rectangle(84, 19, 159, 22));
    txt_content.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_content.setText("6000000100111107");
    txt_content.setBounds(new Rectangle(84, 330, 298, 22));
    txt_content.addActionListener(new RealTimeTestFrame_txt_content_actionAdapter(this));
    jButton3.setBounds(new Rectangle(200, 412, 89, 26));
    jButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton3.setText("发送短信");
    jButton3.addActionListener(new RealTimeTestFrame_jButton3_actionAdapter(this));
    jButton4.setBounds(new Rectangle(295, 366, 96, 26));
    jButton4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton4.setText("自定义命令");
    jButton4.addActionListener(new RealTimeTestFrame_jButton4_actionAdapter(this));
    lab_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    lab_yxj.setText("优先级:");
    lab_yxj.setBounds(new Rectangle(23, 287, 61, 16));
    txt_gnm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_gnm.setText("0D");
    txt_gnm.setBounds(new Rectangle(84, 251, 63, 22));
    jLabel9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel9.setText("手机号码:");
    jLabel9.setBounds(new Rectangle(190, 67, 67, 16));
    txt_sjhm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_sjhm.setText("13800571505");
    txt_sjhm.setBounds(new Rectangle(250, 64, 111, 22));
    jLabel10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel10.setText("命令序号:");
    jLabel10.setBounds(new Rectangle(190, 112, 73, 16));
    txt_mlxh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_mlxh.setText("1");
    txt_mlxh.setBounds(new Rectangle(250, 109, 110, 22));
    jButton5.setBounds(new Rectangle(105, 366, 83, 26));
    jButton5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton5.setText("连接");
    jButton5.addActionListener(new RealTimeTestFrame_jButton5_actionAdapter(this));
    jButton6.setBounds(new Rectangle(200, 366, 83, 26));
    jButton6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton6.setText("断开连接");
    jButton6.addActionListener(new RealTimeTestFrame_jButton6_actionAdapter(this));
    jLabel11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel11.setText("终端逻辑地址:");
    jLabel11.setBounds(new Rectangle(164, 199, 87, 16));
    txt_listterminal.setText("12041234");
    txt_listterminal.setBounds(new Rectangle(252, 196, 130, 22));
    jButton8.setBounds(new Rectangle(170, 248, 90, 26));
    jButton8.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton8.setText("加入队列");
    jButton8.addActionListener(new RealTimeTestFrame_jButton8_actionAdapter(this));
    jButton9.setBounds(new Rectangle(283, 248, 85, 26));
    jButton9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton9.setText("在线状态");
    jButton9.addActionListener(new RealTimeTestFrame_jButton9_actionAdapter(this));
    memo1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    memo1.setToolTipText("");
    memo1.setEditable(false);
    memo1.setLineWrap(true);
    memo1.setWrapStyleWord(true);
    memo1.setBounds(new Rectangle(17, 451, 361, 154));
    jButton7.setBounds(new Rectangle(226, 289, 92, 26));
    jButton7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton7.setText("设置掉线");
    jButton7.addActionListener(new RealTimeTestFrame_jButton7_actionAdapter(this));
    jButton10.setBounds(new Rectangle(192, 155, 90, 23));
    jButton10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton10.setText("手工建档");
    jButton10.addActionListener(new RealTimeTestFrame_jButton10_actionAdapter(this));
    jLabel12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel12.setText("功能码:");
    jLabel12.setBounds(new Rectangle(23, 254, 61, 16));
    txt_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_yxj.setText("08");
    txt_yxj.setBounds(new Rectangle(84, 283, 63, 22));
    jButton11.setBounds(new Rectangle(105, 412, 82, 26));
    jButton11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton11.setActionCommand("");
    jButton11.setText("获取结果");
    jButton11.addActionListener(new RealTimeTestFrame_jButton11_actionAdapter(this));
    jButton12.setBounds(new Rectangle(301, 412, 87, 26));
    jButton12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton12.setText("批量测试");
    jButton12.addActionListener(new RealTimeTestFrame_jButton12_actionAdapter(this));
    contentPane.add(jLabel1);
    contentPane.add(jLabel2);
    contentPane.add(txt_port);
    contentPane.add(jLabel3);
    contentPane.add(jLabel4);
    contentPane.add(jTextField1);
    contentPane.add(txt_AppID);
    contentPane.add(txt_zdljdz);
    contentPane.add(jTextField7);
    contentPane.add(txt_ip);
    contentPane.add(txt_content);
    contentPane.add(jLabel6);
    contentPane.add(jLabel9);
    contentPane.add(txt_sjhm);
    contentPane.add(jLabel10);
    contentPane.add(txt_mlxh);
    contentPane.add(txt_listterminal);
    contentPane.add(jLabel11);
    contentPane.add(jButton8);
    contentPane.add(jButton9);
    contentPane.add(memo1);
    contentPane.add(jButton7);
    contentPane.add(jButton10);
    contentPane.add(txt_gnm);
    contentPane.add(txt_txfs);
    contentPane.add(txt_gyh);
    contentPane.add(jLabel5);
    contentPane.add(jLabel7);
    contentPane.add(jLabel12);
    contentPane.add(lab_yxj);
    contentPane.add(txt_yxj);
    contentPane.add(jButton2);
    contentPane.add(jButton5);
    contentPane.add(jButton6);
    contentPane.add(jButton4);
    contentPane.add(jButton1);
    contentPane.add(jButton11);
    contentPane.add(jButton3);
    contentPane.add(jButton12);
  }
Exemplo n.º 28
-1
  public void go() {
    // build gui

    frame = new JFrame("Quiz Card Buider");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);
    question = new JTextArea(6, 20);
    question.setLineWrap(true);
    question.setWrapStyleWord(true);
    question.setFont(bigFont);

    JScrollPane qScroller = new JScrollPane(question);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    answer = new JTextArea(6, 20);
    answer.setLineWrap(true);
    answer.setWrapStyleWord(true);
    answer.setFont(bigFont);

    JScrollPane aScroller = new JScrollPane(question);
    aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    JButton nextButton = new JButton("Next Card");

    cardList = new ArrayList<QuizCard>();

    JLabel qLabel = new JLabel("Question");
    JLabel aLabel = new JLabel("Answer");

    mainPanel.add(qLabel);
    mainPanel.add(qScroller);
    mainPanel.add(aLabel);
    mainPanel.add(aScroller);
    mainPanel.add(nextButton);

    nextButton.addActionListener(new NextCardListener());

    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");

    JMenuItem newMenuItem = new JMenuItem("New");
    JMenuItem saveMenuItem = new JMenuItem("Save");
    newMenuItem.addActionListener(new NewMenuListener());
    saveMenuItem.addActionListener(new SaveMenuListener());

    fileMenu.add(newMenuItem);
    fileMenu.add(saveMenuItem);
    menuBar.add(fileMenu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(500, 600);
    frame.setVisible(true);
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  }
  private void updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
      EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
      myViewer = createIdeaEditor(fullString);
      JComponent component = myViewer.getComponent();
      component.setPreferredSize(JBUI.size(300, 500));
      mySplitter.setSecondComponent(component);
    } else {
      final JTextArea textArea = new JTextArea(fullString);
      textArea.setRows(3);
      textArea.setWrapStyleWord(true);
      textArea.setLineWrap(true);
      textArea.setSelectionStart(0);
      textArea.setSelectionEnd(textArea.getText().length());
      textArea.setEditable(false);
      mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
  }
  public BaseGoogleLoginUI(@NotNull String signinText) {
    setLayout(new GridBagLayout());
    setPreferredSize(new Dimension(MIN_WIDTH, PREFERRED_HEIGHT));
    setOpaque(false);

    JLabel googleIcon = new JBLabel();

    setBorder(BorderFactory.createEmptyBorder(10, 15, 15, 15));
    googleIcon.setHorizontalAlignment(SwingConstants.CENTER);
    googleIcon.setVerticalAlignment(SwingConstants.CENTER);
    googleIcon.setOpaque(false);
    googleIcon.setIcon(GoogleLoginIcons.GOOGLE_LOGO);
    googleIcon.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 0;
    add(googleIcon, c);

    JTextArea signinTextArea = new JTextArea();
    signinTextArea.setFont(UIUtil.getLabelFont());
    signinTextArea.setLineWrap(true);
    signinTextArea.setWrapStyleWord(true);
    signinTextArea.setOpaque(false);
    signinTextArea.setText(signinText);
    c.gridx = 0;
    c.gridy = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    add(signinTextArea, c);
  }