private void initDebugTextPane() {
    HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
    HTMLDocument htmlDocument = new HTMLDocument();

    debugTextPane.setEditable(false);
    debugTextPane.setBackground(Color.WHITE);
    debugTextPane.setEditorKit(htmlEditorKit);
    htmlEditorKit.install(debugTextPane);
    debugTextPane.setDocument(htmlDocument);
  }
Exemple #2
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;
  }
  About() {
    window = new JWindow();
    this.setPreferredSize(new Dimension(650, 550));
    this.setVisible(true);
    this.setLayout(null);

    JTextPane text = new JTextPane();
    text.setBounds(5, 150, 625, 525);
    text.setVisible(true);
    text.setEditable(false);
    text.setOpaque(false);
    HTMLEditorKit htmlKit =
        new HTMLEditorKit() {
          public Parser getParser() {
            return super.getParser();
          }
        };
    HTMLDocument htmlDoc = new HTMLDocument();
    text.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              if (Desktop.isDesktopSupported()) {
                try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
                  return;
                } catch (IOException e1) {
                } catch (URISyntaxException e1) {
                }
              }
              try {
                Runtime.getRuntime().exec("xdg-open ".concat(e.getURL().toString()));
              } catch (IOException ioex) {
                ControlRoom.log(
                    Level.WARNING,
                    "Failed to show file: '"
                        + e.getURL().toString()
                        + "'. Possible unsupported File Manager...",
                    null);
              }
            }
          }
        });
    text.setEditorKit(htmlKit);
    text.setDocument(htmlDoc);
    try {
      BufferedReader reader =
          new BufferedReader(
              new InputStreamReader(
                  this.getClass().getResourceAsStream("/resources/about.html"), "UTF-8"));
      htmlKit.read(reader, htmlDoc, htmlDoc.getLength());
    } catch (IOException ioex) {
      ControlRoom.log(Level.SEVERE, "Failed to read about.html", ioex);
    } catch (BadLocationException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }

    text.addMouseListener(this);
    window.getContentPane().add(text);
    window.getContentPane().add(this);
    window.addMouseListener(this);
    window.pack();
    ControlRoom.setWindowRelativeToCentral(window);
    window.setVisible(true);
    window.setAlwaysOnTop(true);
  }
  public IRCBOT(boolean uList, String channel, int chatNum) {

    // chatter = new ChatDisplay("<html><body bgcolor='black'><table border=0pt width=100%>");
    winNum = chatNum;
    URL iconURL = getClass().getResource("P_300x300.png");
    ImageIcon icon = new ImageIcon(iconURL);
    setIconImage(icon.getImage());

    Action doNothing =
        new AbstractAction() {

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

    channelName = channel;
    standardWindow = uList;

    chatInput = new JTextArea(4, 55);
    chatInput.setWrapStyleWord(true);
    chatInput.setLineWrap(true);
    chatInput.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doNothing");
    chatScreen = new JTextPane();
    chatScreen.setContentType("text/html");
    chatScreen.setEditorKit(kit);
    chatScreen.setDocument(doc);
    userList = new JTextPane();
    registeredUserList = new JTextPane();
    sendButton = new JButton("SEND");
    g_start = new JButton("START");
    g_end = new JButton("END");
    g_reroll = new JButton("secret");

    JLabel l_giveaway = new JLabel("Giveaway", JLabel.CENTER);
    JLabel l_chat = new JLabel("Chat", JLabel.CENTER);
    JLabel l_uList = new JLabel("User List", JLabel.CENTER);

    sendButton.addActionListener(this);
    g_start.addActionListener(this);
    g_end.addActionListener(this);
    g_reroll.addActionListener(this);

    g_start.setEnabled(false); // disabled for basic irc client
    g_end.setEnabled(false);
    g_reroll.setEnabled(false);

    // String start = "<html><body>";

    Dimension min = new Dimension(100, 1);
    Dimension pref = new Dimension(150, 1);
    Dimension max = new Dimension(600, 600);
    // chatScreen.setMinimumSize(min);
    // userList.setMinimumSize(min);
    // chatInput.addKeyListener(KeyBoardListener);

    JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
    JPanel left = new JPanel(new BorderLayout(5, 5));
    JPanel mid = new JPanel(new BorderLayout(5, 5));
    JPanel right = new JPanel(new BorderLayout(5, 5));
    JPanel giveaway_buttons = new JPanel(new BorderLayout(5, 5));

    JPanel sendBar = new JPanel();
    scrollChat = new JScrollPane(chatScreen);
    JScrollPane scrollChatInput = new JScrollPane(chatInput);
    userListScroll = new JScrollPane(userList);
    JScrollPane regUserListScroll = new JScrollPane(registeredUserList);

    userListScroll.setMinimumSize(min);
    // userListScroll.setPreferredSize(pref);
    // userListScroll.setMaximumSize(new Dimension(800,600));
    // userListScroll.setPreferredSize(new Dimension(100,100));
    // scrollChat.setPreferredSize(pref);
    scrollChat.setMinimumSize(min);
    // scrollChat.setMaximumSize(new Dimension(500,500));
    regUserListScroll.setPreferredSize(pref);

    mid.add(l_chat, BorderLayout.NORTH);
    mid.add(scrollChat, BorderLayout.CENTER);

    right.add(l_uList, BorderLayout.NORTH);
    right.add(userListScroll, BorderLayout.CENTER);

    giveaway_buttons.add(g_start, BorderLayout.WEST);
    giveaway_buttons.add(g_end, BorderLayout.CENTER);
    giveaway_buttons.add(g_reroll, BorderLayout.PAGE_END);

    left.add(giveaway_buttons, BorderLayout.PAGE_END);

    JSplitPane chat_userList = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mid, right);
    chat_userList.setOneTouchExpandable(true);
    chat_userList.setDividerLocation(500);
    chat_userList.setResizeWeight(0.5);
    chat_userList.setContinuousLayout(true);
    // chat_userList.setPreferredSize(new Dimension(100,100));
    chat_userList.setMinimumSize(min);
    // chat_userList.setMaximumSize(max);

    userListScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
    // scroll.add(chatScreen);

    sendBar.add(scrollChatInput);
    sendBar.add(sendButton);

    if (standardWindow) {

      mainPanel.add(chat_userList, BorderLayout.CENTER);
      mainPanel.add(sendBar, BorderLayout.PAGE_END);

      JMenuBar menuBar = new JMenuBar();
      JMenu fileMenu = new JMenu("File");
      settings = new JMenuItem("Settings");

      settings.addActionListener(this);

      fileMenu.add(settings);
      menuBar.add(fileMenu);

      left.add(l_giveaway, BorderLayout.NORTH);
      left.add(regUserListScroll, BorderLayout.CENTER);
      // left.setBorder(new EmptyBorder(0,5,0,0));
      // chat_userList.setBorder(new EtchedBorder(0,0,0,5));
      mainPanel.add(left, BorderLayout.WEST);
      mainPanel.add(menuBar, BorderLayout.PAGE_START);
      // mainPanel.setBorder(new EmptyBorder(0,10,10,10));
    } else {
      mainPanel.add(scrollChat, BorderLayout.CENTER);
    }
    registeredUserList.setEditable(false);
    userList.setEditable(false);
    chatScreen.setEditable(false);

    registeredUserList.setFont(new Font("Courier New", Font.PLAIN, 12));
    chatScreen.setFont(new Font("Courier New", Font.PLAIN, 12));
    chatInput.setFont(new Font("Courier New", Font.PLAIN, 12));

    getContentPane().add(mainPanel);
    setSize(800, 500);
    setVisible(true);
    setResizable(true);
    setLocationRelativeTo(null);
    setTitle("IRC Chatter");
    setMinimumSize(new Dimension(500, 200));

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            // System.out.println("\n\n\n\n\n\\n\nCLOSEDWINDOW\n\n\n\n\n\n\n\n");
            if (sock.isSafe() == true) sock.outputText("PART " + channelName + "\r\n");
            // System.out.println("\n\n\n\n\n\\n\nCLOSEDWINDOW\n\n\n\n\n\n\n\n");
          }
        });
    chatInput.addKeyListener(this);
    chatInput.requestFocus();
  }
Exemple #5
0
 public void setDocument(Document doc) {
   super.setDocument(new OverwritableDocument(this, doc));
 }