Ejemplo n.º 1
0
    DataPanel(@NotNull Project project, boolean multiRoot, @NotNull Disposable disposable) {
      super(UIUtil.HTML_MIME, "");
      myProject = project;
      myMultiRoot = multiRoot;
      setEditable(false);
      setOpaque(false);
      putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

      EditorColorsManager.getInstance()
          .addEditorColorsListener(
              new EditorColorsAdapter() {
                @Override
                public void globalSchemeChange(EditorColorsScheme scheme) {
                  update();
                }
              },
              disposable);

      DefaultCaret caret = (DefaultCaret) getCaret();
      caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

      addHyperlinkListener(
          new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent e) {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED
                  && SHOW_OR_HIDE_BRANCHES.equals(e.getDescription())) {
                myExpanded = !myExpanded;
                update();
              } else {
                BrowserHyperlinkListener.INSTANCE.hyperlinkUpdate(e);
              }
            }
          });
    }
Ejemplo n.º 2
0
  public PrinterStatusPanel(Executor exe) {
    this.exe = exe;
    myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.PAGE_AXIS));
    myPanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.black), "Printer Status"));

    // Temperature plot
    tempPanel = new TemperaturePanel(exe);

    // Text Area for Log Messages
    statusText.setEditable(false);
    statusText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, FONT_SIZE));
    statusText.setLineWrap(false);
    statusText.setText(OFFLINE_MESSAGE);
    final DefaultCaret caret = (DefaultCaret) statusText.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane(statusText);
    scrollPane.setViewportView(statusText);

    final JSplitPane splitPane =
        new JSplitPane(JSplitPane.VERTICAL_SPLIT, tempPanel.getPanel(), scrollPane);
    splitPane.setDividerLocation(300);
    myPanel.add(splitPane);
    GuiAppender.setTextArea(statusText);
  }
  /**
   * @param codep
   * @return
   */
  protected Caret installCaret(CodePoint codep) {
    // The caret will track the positions across the users' editings.
    final DefaultCaret place = new DefaultCaret();
    place.setUpdatePolicy(DefaultCaret.UPDATE_WHEN_ON_EDT);
    place.install(txtEditor);
    // remove mouse listeners from component, since we don't want the mouse to modify our caret
    txtEditor.removeMouseListener(place);
    txtEditor.removeMouseMotionListener(place);
    txtEditor.removeFocusListener(place);
    // configure visibility and set proper positions
    place.setVisible(false);
    place.setSelectionVisible(false);
    place.setDot(codep.y);
    place.moveDot(codep.x);
    log.info("Installed Caret for " + codep);
    place.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            log.fine(e.getSource() + " at " + e.toString());
            // when the caret changes, update the display
            updateName();
          }
        });
    return place;
  }
Ejemplo n.º 4
0
  protected void textAreaAction(ActionEvent e) {
    JScrollBar scrollBar = textAreaScrollPane.getVerticalScrollBar();
    int extent = scrollBar.getModel().getExtent();
    boolean atBottom = scrollBar.getValue() + extent == scrollBar.getMaximum();

    if (atBottom) {
      caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    } else {
      caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    if (mainWindow.notifyTextEntered(ChatArea.this, e.getActionCommand())) {
      appendText(
          "%s > %s%n",
          (mainWindow != null ? mainWindow.getChatDisplayName() : ""), e.getActionCommand());
      textField.setText("");
    }
  }
Ejemplo n.º 5
0
  public GameWindow(GraphicalUI ui) {
    this.ui = ui;
    this.cardButtonMap = new HashMap();

    initComponents();
    DefaultCaret caret = (DefaultCaret) jTextAreaOutput.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    setup();
  }
Ejemplo n.º 6
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmAplicacaoHospital = new JFrame();
    frmAplicacaoHospital.setTitle("Aplicacao Hospital");
    frmAplicacaoHospital.setBounds(100, 100, 800, 400);
    frmAplicacaoHospital.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    GroupLayout groupLayout = new GroupLayout(frmAplicacaoHospital.getContentPane());
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addComponent(
                panel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addComponent(
                        panel, GroupLayout.PREFERRED_SIZE, 355, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    JScrollPane scrollPane = new JScrollPane();
    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_panel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 764, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_panel.setVerticalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_panel
                    .createSequentialGroup()
                    .addGap(35)
                    .addComponent(
                        scrollPane, GroupLayout.PREFERRED_SIZE, 283, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(37, Short.MAX_VALUE)));

    textArea = new JTextArea();
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    scrollPane.setViewportView(textArea);
    panel.setLayout(gl_panel);
    frmAplicacaoHospital.getContentPane().setLayout(groupLayout);
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    try {
      app = new AplicacaoHospital(this);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 7
0
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
Ejemplo n.º 8
0
 @Override
 public void addContent() {
   consolePane = new JTextArea();
   consolePane.setBackground(panelColor);
   consolePane.setForeground(Color.white);
   consolePane.setEditable(false);
   PrintStream out = new PrintStream(new TextAreaOutputStream(consolePane));
   System.setOut(out);
   System.setErr(out);
   scrollPane = new JScrollPane(consolePane);
   DefaultCaret caret = (DefaultCaret) consolePane.getCaret();
   caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
   this.add(scrollPane, BorderLayout.CENTER);
 }
Ejemplo n.º 9
0
 public Consola() {
   text = new WebTextArea();
   // false para que pueda escribir para la derecha.
   text.setLineWrap(false);
   text.setWrapStyleWord(true);
   text.setMargin(5);
   text.setFont(new Font("monospaced", Font.PLAIN, 16));
   text.setEditable(false);
   text.setDoubleBuffered(true);
   text.setSelectionColor(Color.YELLOW);
   scroll = new WebScrollPane(text, false, true);
   scroll.setPreferredSize(null);
   // Hacer que baje el documento a medida que se escribe
   DefaultCaret caret = (DefaultCaret) text.getCaret();
   caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
 }
Ejemplo n.º 10
0
 public Debugger() {
   super("Debug console");
   debugField = new JTextArea();
   debugField.setEditable(false);
   debugField.setLineWrap(true);
   debugField.setFont(new Font("Arial", Font.PLAIN, 14));
   DefaultCaret c = ((DefaultCaret) debugField.getCaret());
   c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
   jps = new JScrollPane(debugField);
   add(jps);
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   setSize((int) d.getHeight(), (int) d.getWidth());
   setLocation(0, 0);
   setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   pack();
   setVisible(true);
 }
Ejemplo n.º 11
0
  public ProgressDialog(RuntimeGUI parent) {
    super(parent.myService.getFrame(), "new components");
    this.parent = parent;
    Container display = getContentPane();

    // north
    JPanel north = new JPanel();
    display.add(north, BorderLayout.NORTH);

    spinner = new JLabel();
    north.add(spinner);

    actionText = new JLabel("");
    north.add(actionText);

    // center
    reportArea = new JTextArea("details\n", 5, 10);
    reportArea.setLineWrap(true);
    reportArea.setEditable(false);
    reportArea.setBackground(SystemColor.control);

    scrollPane = new JScrollPane(reportArea);
    DefaultCaret caret = (DefaultCaret) reportArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    display.add(scrollPane, BorderLayout.CENTER);

    // south
    JPanel south = new JPanel();
    display.add(south, BorderLayout.SOUTH);
    okToUpdates.addActionListener(this);
    cancel.addActionListener(this);
    restart.addActionListener(this);
    noWorky.addActionListener(this);
    hideButtons();
    south.add(okToUpdates);
    south.add(cancel);
    south.add(restart);
    south.add(noWorky);
    south.add(buttonText);
    // setPreferredSize(new Dimension(350, 300));
    setSize(320, 300);
  }
Ejemplo n.º 12
0
  /**
   * Creates a new ChatGUI form
   *
   * @param gui
   */
  public ChatGUI(final GUI gui) {
    this.gui = gui;
    initComponents();
    // JTextArea automatically updates to scroll down ;)
    DefaultCaret caret = (DefaultCaret) jTextPane1.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    listSelectionListener =
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent listSelectionEvent) {
            try {
              gui.setRemoteIpAdress(jList1.getSelectedValue().toString());
              String username = jList1.getSelectedValue().toString();
              String[] ipadress = username.split("@");
              jLabel2.setText(ipadress[1]);
            } catch (UnknownHostException ex) {
              Logger.getLogger(ChatGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        };
    jList1.addListSelectionListener(listSelectionListener);
  }
Ejemplo n.º 13
0
  /** Build the interface. */
  private void buildUI() {
    if (colorEnabled) {
      JTextPane text = new JTextPane();
      this.textComponent = text;
    } else {
      JTextArea text = new JTextArea();
      this.textComponent = text;
      text.setLineWrap(true);
    }
    textComponent.addMouseListener(this);
    textComponent.setFont(getMonospaceFont());
    textComponent.setEditable(false);
    DefaultCaret caret = (DefaultCaret) textComponent.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    document = textComponent.getDocument();
    document.addDocumentListener(new LimitLinesDocumentListener(numLines, true));

    JScrollPane scrollText = new JScrollPane(textComponent);
    scrollText.setBorder(null);
    scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    add(scrollText, BorderLayout.CENTER);
  }
Ejemplo n.º 14
0
  public void setUpGUI() {
    main_chat_panel = new JPanel(new BorderLayout());
    main_chat_panel.setPreferredSize(new Dimension(250, 530));

    message_area_panel = new JPanel(new BorderLayout());
    message_area_panel.setBorder(new EmptyBorder(5, 5, 0, 0));

    message_area = new JTextArea();
    message_area.setEditable(false);
    message_area.setLineWrap(true);

    message_area.setBackground(Color.WHITE);

    DefaultCaret caret = (DefaultCaret) message_area.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    message_area_panel.add(new JScrollPane(message_area), BorderLayout.CENTER);

    chat_area_panel = new JPanel(new BorderLayout());
    chat_area_panel.setBorder(new EmptyBorder(3, 0, 0, 0));

    chat_area = new JTextField(50);
    chat_area.setBackground(Color.WHITE);
    chat_area.addKeyListener(this);

    send_button = new JButton("SEND");
    send_button.addActionListener(this);

    chat_area_panel.add(chat_area, BorderLayout.CENTER);
    chat_area_panel.add(send_button, BorderLayout.EAST);

    main_chat_panel.add(message_area_panel, BorderLayout.CENTER);
    main_chat_panel.add(chat_area_panel, BorderLayout.SOUTH);

    this.add(main_chat_panel);
  }
Ejemplo n.º 15
0
  /**
   * Construct the GUI for a logger.
   *
   * @param titleMessage for the title bar of the dialog box
   * @param width initial width of the resizeable dialog box
   * @param height initial height of the resizeable dialog box
   * @param exitApplicationOnClose if true, when the dialog box is closed (X-d out), will exit the
   *     application with success status
   * @param visible if true, will be made visible after construction
   */
  protected void createGUI(
      String titleMessage, int width, int height, boolean exitApplicationOnClose, boolean visible) {
    Border panelBorder = BorderFactory.createEtchedBorder();

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

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

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

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

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

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

    if (exitApplicationOnClose) {
      // Note that unlike for JFrame, EXIT_ON_CLOSE is NOT a valid value to pass to
      // setDefaultCloseOperation(), so have to do this with WindowListener
      outputDialog.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              // System.err.println("DialogMessageLogger.WindowAdapter.windowClosing()");
              // dispose();
              System.exit(0);
            }
          });
    }
  }
Ejemplo n.º 16
0
  public static void main(String[] args) {
    f = new JFrame("Server");
    f.setVisible(true);
    f.setSize(500, 360);
    f.setLocation(100, 100);
    f.setLayout(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setBackground(Color.black);
    f.setAlwaysOnTop(true);

    a = new JTextArea();
    a.setVisible(true);
    a.setSize(f.getWidth(), f.getHeight() - 60);
    a.setLocation(0, 0);
    a.setEditable(false);
    a.setBackground(Color.black);
    a.setForeground(Color.white);
    DefaultCaret caret = (DefaultCaret) a.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    b = new JTextField();
    b.setVisible(true);
    b.setSize(f.getWidth() - 110, 20);
    b.setLocation(5, f.getHeight() - 65);
    b.setBackground(Color.black);
    b.setForeground(Color.white);
    f.add(b);

    c = new JScrollPane(a);
    c.setVisible(true);
    c.setSize(f.getWidth() - 20, f.getHeight() - 70);
    c.setLocation(1, 1);
    c.setBackground(Color.black);
    c.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    c.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    c.setAutoscrolls(true);
    f.add(c);

    d = new JButton("INVIA");
    d.setVisible(true);
    d.setSize(90, 20);
    d.setLocation(f.getWidth() - 105, f.getHeight() - 65);
    f.add(d);

    f.repaint();

    f.addComponentListener(
        new ComponentListener() {

          @Override
          public void componentShown(ComponentEvent arg0) {}

          @Override
          public void componentResized(ComponentEvent arg0) {
            a.setSize(f.getWidth(), f.getHeight() - 60);
            b.setSize(f.getWidth() - 110, 20);
            b.setLocation(5, f.getHeight() - 65);
            c.setSize(f.getWidth() - 20, f.getHeight() - 70);
            d.setLocation(f.getWidth() - 100, f.getHeight() - 65);
          }

          @Override
          public void componentMoved(ComponentEvent arg0) {}

          @Override
          public void componentHidden(ComponentEvent arg0) {}
        });

    b.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            console();
          }
        });

    d.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            console();
          }
        });

    Thread t = new Thread(new restart());
    t.start();

    s = new Server();
    s.start(6677);
  }
Ejemplo n.º 17
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
  /**
   * Constructs a X509 certificate panel.
   *
   * @param certificates <tt>X509Certificate</tt> objects
   */
  public X509CertificatePanel(Certificate[] certificates) {
    setLayout(new BorderLayout(5, 5));

    // Certificate chain list
    TransparentPanel topPanel = new TransparentPanel(new BorderLayout());
    topPanel.add(
        new JLabel(
            "<html><body><b>"
                + R.getI18NString("service.gui.CERT_INFO_CHAIN")
                + "</b></body></html>"),
        BorderLayout.NORTH);

    DefaultMutableTreeNode top = new DefaultMutableTreeNode();
    DefaultMutableTreeNode previous = top;
    for (int i = certificates.length - 1; i >= 0; i--) {
      Certificate cert = certificates[i];
      DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert);
      previous.add(next);
      previous = next;
    }
    JTree tree = new JTree(top);
    tree.setBorder(new BevelBorder(BevelBorder.LOWERED));
    tree.setRootVisible(false);
    tree.setExpandsSelectedPaths(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(
        new DefaultTreeCellRenderer() {

          @Override
          public Component getTreeCellRendererComponent(
              JTree tree,
              Object value,
              boolean sel,
              boolean expanded,
              boolean leaf,
              int row,
              boolean hasFocus) {
            JLabel component =
                (JLabel)
                    super.getTreeCellRendererComponent(
                        tree, value, sel, expanded, leaf, row, hasFocus);
            if (value instanceof DefaultMutableTreeNode) {
              Object o = ((DefaultMutableTreeNode) value).getUserObject();
              if (o instanceof X509Certificate) {
                component.setText(getSimplifiedName((X509Certificate) o));
              } else {
                // We don't know how to represent this certificate type,
                // let's use the first 20 characters
                String text = o.toString();
                if (text.length() > 20) {
                  text = text.substring(0, 20);
                }
                component.setText(text);
              }
            }
            return component;
          }
        });
    tree.getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {

              @Override
              public void valueChanged(TreeSelectionEvent e) {
                valueChangedPerformed(e);
              }
            });
    tree.setSelectionPath(
        new TreePath((((DefaultTreeModel) tree.getModel()).getPathToRoot(previous))));
    topPanel.add(tree, BorderLayout.CENTER);

    add(topPanel, BorderLayout.NORTH);

    // Certificate details pane
    Caret caret = infoTextPane.getCaret();
    if (caret instanceof DefaultCaret) {
      ((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    /*
     * Make JEditorPane respect our default font because we will be using it
     * to just display text.
     */
    infoTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);

    infoTextPane.setOpaque(false);
    infoTextPane.setEditable(false);
    infoTextPane.setContentType("text/html");
    infoTextPane.setText(toString(certificates[0]));

    final JScrollPane certScroll = new JScrollPane(infoTextPane);
    certScroll.setPreferredSize(new Dimension(300, 500));
    add(certScroll, BorderLayout.CENTER);
  }
Ejemplo n.º 19
0
  public ChatClient(String n) {
    super(n + "'s Client");
    name = n;

    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    this.addWindowListener(this);

    setSize(545, 345);

    JPanel panel = new JPanel();

    panel.add(active);
    panel.add(activelist);

    scrollactive.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollactive.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollactive.setViewportView(activelist);
    panel.add(scrollactive);

    activelist.addListSelectionListener(
        e -> {
          selectedIndex = activelist.getSelectedIndex();
          System.out.println(selectedIndex);
        });

    panel.add(history);

    JScrollPane scroll_bars =
        new JScrollPane(
            history,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    panel.add(scroll_bars);
    panel.add(msglab);
    panel.add(message);

    history.setEditable(false);

    DefaultCaret caret = (DefaultCaret) history.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    message.addActionListener(
        e -> {
          try {
            output = new PrintWriter(s.getOutputStream(), true);
          } catch (Exception e1) {

            e1.printStackTrace();
          }

          String tmp = message.getText();
          if (!tmp.equals("")) {
            if (!activelist.isSelectionEmpty()) {
              output.println("@#$PW@#$");
              output.println(selectedIndex);
              output.println(name + ": " + tmp);
              history.append("(PW) " + name + ": " + tmp + "\n");
            } else {
              output.println(name + ": " + tmp);
            }
          }

          message.setText("");
        });

    String[] test = {"Anonymous", "Anonymous"};
    activelist.setListData(test);

    this.setContentPane(panel);

    Thread t = new Thread(this);
    t.start();

    setVisible(true);
  }
Ejemplo n.º 20
0
  /** Create panel at the bottom with differents consoles to report injection process. */
  public PanelBottom() {
    // Object creation after customization
    this.consoleTab.getProxy().setEditable(false);
    SwingAppender.register(this.consoleTab);

    this.chunkTab = new JPopupTextArea().getProxy();
    this.chunkTab.setEditable(false);

    this.binaryTab = new JPopupTextArea().getProxy();
    this.binaryTab.setEditable(false);

    this.javaTab.getProxy().setEditable(false);
    SwingAppender.register(this.javaTab);

    this.network = new JSplitPaneWithZeroSizeDivider();
    this.network.setResizeWeight(1);
    this.network.setDividerSize(0);
    this.network.setDividerLocation(600);
    this.network.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 0, HelperGUI.COMPONENT_BORDER));
    this.networkTable =
        new JTable(0, 4) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }

          @Override
          public String getToolTipText(MouseEvent e) {
            String tip = null;
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);

            try {
              // comment row, exclude heading
              if (rowIndex != 0 && colIndex == 1) {
                tip = getValueAt(rowIndex, colIndex).toString();
              }
            } catch (RuntimeException e1) {
              // catch null pointer exception if mouse is over an empty line
            }

            return "<html><p width=\"1024\">" + tip + "</p></html>";
          }
        };

    new TableFilterHeader(this.networkTable, AutoChoices.ENABLED);

    this.networkTable.setComponentPopupMenu(new JPopupMenuTable(this.networkTable));
    this.networkTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    this.networkTable.setRowSelectionAllowed(true);
    this.networkTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.networkTable.setRowHeight(20);
    this.networkTable.setGridColor(Color.LIGHT_GRAY);
    this.networkTable.getTableHeader().setReorderingAllowed(false);

    this.networkTable.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            PanelBottom.this.networkTable.requestFocusInWindow();
            // move selected row and place cursor on focused cell
            if (SwingUtilities.isRightMouseButton(e)) {
              Point p = e.getPoint();

              // get the row index that contains that coordinate
              int rowNumber = PanelBottom.this.networkTable.rowAtPoint(p);
              int colNumber = PanelBottom.this.networkTable.columnAtPoint(p);
              // Get the ListSelectionModel of the JTable
              DefaultListSelectionModel model =
                  (DefaultListSelectionModel) PanelBottom.this.networkTable.getSelectionModel();
              DefaultListSelectionModel model2 =
                  (DefaultListSelectionModel)
                      PanelBottom.this.networkTable.getColumnModel().getSelectionModel();

              PanelBottom.this.networkTable.setRowSelectionInterval(rowNumber, rowNumber);
              model.moveLeadSelectionIndex(rowNumber);
              model2.moveLeadSelectionIndex(colNumber);
            }
          }
        });

    this.networkTable.setModel(
        new DefaultTableModel() {
          private String[] columns = {
            I18n.NETWORK_TAB_METHOD_COLUMN,
            I18n.NETWORK_TAB_URL_COLUMN,
            I18n.NETWORK_TAB_SIZE_COLUMN,
            I18n.NETWORK_TAB_TYPE_COLUMN
          };

          @Override
          public int getColumnCount() {
            return this.columns.length;
          }

          @Override
          public String getColumnName(int index) {
            return this.columns[index];
          }
        });

    class CenterRenderer extends DefaultTableCellRenderer {
      public CenterRenderer() {
        this.setHorizontalAlignment(JLabel.CENTER);
      }
    }

    DefaultTableCellRenderer centerHorizontalAlignment = new CenterRenderer();
    this.networkTable.getColumnModel().getColumn(2).setCellRenderer(centerHorizontalAlignment);
    this.networkTable.getColumnModel().getColumn(3).setCellRenderer(centerHorizontalAlignment);

    this.networkTable
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), null);
    this.networkTable
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), null);

    Set<AWTKeyStroke> forward =
        new HashSet<AWTKeyStroke>(
            this.networkTable.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    forward.add(KeyStroke.getKeyStroke("TAB"));
    this.networkTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forward);
    Set<AWTKeyStroke> backward =
        new HashSet<AWTKeyStroke>(
            this.networkTable.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
    backward.add(KeyStroke.getKeyStroke("shift TAB"));
    this.networkTable.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backward);

    final TableCellRenderer tcrOs = this.networkTable.getTableHeader().getDefaultRenderer();
    this.networkTable
        .getTableHeader()
        .setDefaultRenderer(
            new TableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                JLabel lbl =
                    (JLabel)
                        tcrOs.getTableCellRendererComponent(
                            table, value, isSelected, hasFocus, row, column);
                lbl.setBorder(
                    BorderFactory.createCompoundBorder(
                        BorderFactory.createMatteBorder(0, 0, 1, 1, Color.LIGHT_GRAY),
                        BorderFactory.createEmptyBorder(0, 5, 0, 5)));
                return lbl;
              }
            });

    JScrollIndicator scroller = new JScrollIndicator(this.networkTable);
    scroller.scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, -1, -1));
    scroller.scrollPane.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, -1, -1));
    this.network.setLeftComponent(scroller);

    MouseTabbedPane networkDetailTabs = new MouseTabbedPane();
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_RESPONSE_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabResponse));
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_SOURCE_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabSource));
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_PREVIEW_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabPreview));
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_HEADERS_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabHeader));
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_COOKIES_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabCookie));
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_PARAMS_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabParam));
    networkDetailTabs.addTab(
        I18n.NETWORK_TAB_TIMING_LABEL, new LightScrollPane(1, 1, 0, 0, networkTabTiming));

    DefaultCaret caret = (DefaultCaret) networkTabResponse.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    caret = (DefaultCaret) networkTabSource.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    caret = (DefaultCaret) networkTabPreview.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    caret = (DefaultCaret) networkTabHeader.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    caret = (DefaultCaret) networkTabCookie.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    caret = (DefaultCaret) networkTabParam.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    caret = (DefaultCaret) networkTabTiming.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

    networkTabHeader.setLineWrap(true);
    networkTabCookie.setLineWrap(true);
    networkTabParam.setLineWrap(true);
    networkTabResponse.setLineWrap(true);
    networkTabTiming.setLineWrap(true);
    networkTabSource.setLineWrap(true);

    networkTabPreview.setContentType("text/html");
    networkTabPreview.setEditable(false);

    this.networkTable.getColumnModel().getColumn(0).setResizable(false);
    this.networkTable.getColumnModel().getColumn(0).setPreferredWidth(120);
    this.networkTable.getColumnModel().getColumn(0).setMinWidth(120);
    this.networkTable.getColumnModel().getColumn(0).setMaxWidth(120);

    this.networkTable.getColumnModel().getColumn(2).setResizable(false);
    this.networkTable.getColumnModel().getColumn(2).setPreferredWidth(45);
    this.networkTable.getColumnModel().getColumn(2).setMinWidth(45);
    this.networkTable.getColumnModel().getColumn(2).setMaxWidth(45);

    this.networkTable.getColumnModel().getColumn(3).setResizable(false);
    this.networkTable.getColumnModel().getColumn(3).setPreferredWidth(85);
    this.networkTable.getColumnModel().getColumn(3).setMinWidth(85);
    this.networkTable.getColumnModel().getColumn(3).setMaxWidth(85);

    this.networkTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent event) {
                // prevent double event
                if (!event.getValueIsAdjusting()
                    && PanelBottom.this.networkTable.getSelectedRow() > -1) {
                  networkTabHeader.setText(
                      listHTTPHeader
                          .get(PanelBottom.this.networkTable.getSelectedRow())
                          .getHeader());
                  networkTabCookie.setText(
                      listHTTPHeader
                          .get(PanelBottom.this.networkTable.getSelectedRow())
                          .getCookie());
                  networkTabParam.setText(
                      listHTTPHeader.get(PanelBottom.this.networkTable.getSelectedRow()).getPost());

                  networkTabResponse.setText("");
                  for (String key :
                      listHTTPHeader
                          .get(PanelBottom.this.networkTable.getSelectedRow())
                          .getResponse()
                          .keySet()) {
                    networkTabResponse.append(
                        key
                            + ": "
                            + listHTTPHeader
                                .get(PanelBottom.this.networkTable.getSelectedRow())
                                .getResponse()
                                .get(key));
                    networkTabResponse.append("\n");
                  }

                  networkTabTiming.setText("?");
                  networkTabSource.setText(
                      listHTTPHeader.get(PanelBottom.this.networkTable.getSelectedRow()).source);
                  networkTabPreview.setText(
                      "<html>"
                          + listHTTPHeader.get(PanelBottom.this.networkTable.getSelectedRow())
                              .source
                          + "</html>");
                }
              }
            });

    this.network.setRightComponent(networkDetailTabs);

    MediatorGUI.register(new AdapterBottomTabbedPane());
    MediatorGUI.bottom().setBorder(BorderFactory.createEmptyBorder(1, 1, 0, 0));
    MediatorGUI.bottom().setMinimumSize(new Dimension());

    MediatorGUI.bottom()
        .addTab(
            "Console",
            new ImageIcon(getClass().getResource("/com/jsql/view/swing/images/console.gif")),
            new LightScrollPane(1, 1, 0, 0, this.consoleTab.getProxy()),
            I18n.CONSOLE_TAB_TOOLTIP);
    MediatorGUI.bottom()
        .setTabComponentAt(
            MediatorGUI.bottom().indexOfTab("Console"),
            new JLabel(
                I18n.CONSOLE_TAB_LABEL,
                new ImageIcon(getClass().getResource("/com/jsql/view/swing/images/console.gif")),
                SwingConstants.CENTER));

    // Order is important
    Preferences prefs = Preferences.userRoot().node(InjectionModel.class.getName());
    if (prefs.getBoolean(HelperGUI.JAVA_VISIBLE, false)) {
      this.insertJavaDebugTab();
    }
    if (prefs.getBoolean(HelperGUI.NETWORK_VISIBLE, true)) {
      this.insertNetworkTab();
    }
    if (prefs.getBoolean(HelperGUI.CHUNK_VISIBLE, true)) {
      this.insertChunkTab();
    }
    if (prefs.getBoolean(HelperGUI.BINARY_VISIBLE, true)) {
      this.insertBinaryTab();
    }

    MediatorGUI.bottom()
        .addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent arg0) {
                JTabbedPane tabs = MediatorGUI.bottom();
                if (tabs.getSelectedIndex() > -1) {
                  Component currentTabHeader = tabs.getTabComponentAt(tabs.getSelectedIndex());
                  if (currentTabHeader != null) {
                    currentTabHeader.setFont(currentTabHeader.getFont().deriveFont(Font.PLAIN));
                  }
                }
              }
            });

    this.setLayout(new OverlayLayout(this));

    BasicArrowButton showBottomButton = new BasicArrowButton(BasicArrowButton.SOUTH);
    showBottomButton.setBorderPainted(false);
    showBottomButton.setPreferredSize(showBottomButton.getPreferredSize());
    showBottomButton.setMaximumSize(showBottomButton.getPreferredSize());

    showBottomButton.addActionListener(PanelLeftRightBottom.HIDESHOWPANEL);

    JPanel arrowDownPanel = new JPanel();
    arrowDownPanel.setLayout(new BoxLayout(arrowDownPanel, BoxLayout.PAGE_AXIS));
    arrowDownPanel.setOpaque(false);
    showBottomButton.setOpaque(false);
    // Disable overlap with zerosizesplitter
    arrowDownPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));
    arrowDownPanel.setPreferredSize(new Dimension(17, 27));
    arrowDownPanel.setMaximumSize(new Dimension(17, 27));
    arrowDownPanel.add(showBottomButton);
    this.add(arrowDownPanel);
    this.add(MediatorGUI.bottom());

    // Do Overlay
    arrowDownPanel.setAlignmentX(1.0f);
    arrowDownPanel.setAlignmentY(0.0f);
    MediatorGUI.bottom().setAlignmentX(1.0f);
    MediatorGUI.bottom().setAlignmentY(0.0f);

    this.chunkTab.setLineWrap(true);
    this.binaryTab.setLineWrap(true);
  }
Ejemplo n.º 21
0
 public Console() { // TODO boolean JFrame or component
   textArea = new JTextArea();
   scrollPane = new JScrollPane(textArea);
   DefaultCaret caret = (DefaultCaret) textArea.getCaret();
   caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
 }
  public ProgressBarGeneticDialog(
      MainWindowInnerInterface mainWindow, DataLayerFacade dataLayer, Graph graph) {
    super(
        (JFrame) mainWindow,
        dataLayer.getString("GENETIC_ALGORITHM_RUNNING"),
        ModalityType.APPLICATION_MODAL);

    // create genetic graph from graph
    this.geneticGraph =
        new GeneticGraph(
            graph,
            graph.getAbstractHwComponentsCount()); // graph.getAbstractHwComponentsCount() * 2

    this.dataLayer = dataLayer;

    this.setLocationRelativeTo((JFrame) mainWindow);

    mainPanel = new JPanel(new BorderLayout());

    controlPanel = new JPanel();

    cancelButton = new JButton(dataLayer.getString("CANCEL"));
    cancelButton.addActionListener((ActionListener) this);
    cancelButton.setActionCommand(CANCEL_COMMAND);
    cancelButton.setEnabled(true);

    enoughQuality = new JButton(dataLayer.getString("ENOUGH_QUALITY"));
    enoughQuality.addActionListener((ActionListener) this);
    enoughQuality.setActionCommand(ENOUGH_QUALITY_COMMAND);
    enoughQuality.setEnabled(false);

    progressBar = new JProgressBar();
    progressBar.setIndeterminate(true);

    controlPanel.add(cancelButton);
    // controlPanel.add(enoughQuality);
    controlPanel.add(progressBar);

    taskOutput = new JTextArea(10, 35);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);
    DefaultCaret caret = (DefaultCaret) taskOutput.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    taskOutput.setFont(cancelButton.getFont());

    mainPanel.add(controlPanel, BorderLayout.PAGE_START);
    mainPanel.add(new JScrollPane(taskOutput), BorderLayout.CENTER);

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

    this.add(mainPanel);

    this.setSize(new Dimension(400, 300));
    this.setResizable(false);

    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            doCancelAction();
          }
        });
  }