Esempio n. 1
0
  /**
   * Constructor: The one we're working on right now.
   *
   * @param id
   * @param label
   * @param desktop
   */
  public kCodeWindow(String id, String label, JDesktopPane desktop) {

    this.id = id;
    this.desktop = desktop;

    // make the editor portions

    TextAreaDefaults editareaSettings = new PdeTextAreaDefaults();
    editareaSettings.rows = TEXTAREA_DEFAULT_ROWS;
    editareaSettings.cols = TEXTAREA_DEFAULT_COLS;
    textarea = new JEditTextArea(editareaSettings);
    textarea.getDocument().setTokenMarker(Editor.pdeTokenMarker);
    textarea.setEventsEnabled(
        false); // suppress JEditTextArea events (not that anyone is listening to it)
    textarea.setEditable(true);
    textarea.setHorizontalOffset(TEXTAREA_HORIZ_OFFSET);
    textarea.getPainter().setLineHighlightEnabled(false); // else looks funny
    textarea.getPainter().setBackground(kConstants.CODE_WINDOW_COLOR);
    setShortcutKeystrokes();
    JScrollPane scrollPane = new JScrollPane(textarea);
    scrollPane.setBorder(null);
    //    scrollPane.setOpaque(true);

    editFrame = new JInternalFrame(label, true, false, false, false);
    editFrame.setContentPane(textarea);
    editFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    editFrame.setSize(editFrame_DEFAULT_WIDTH, editFrame_DEFAULT_HEIGHT);
    editFrame.setBorder(null);
    editFrame.setOpaque(true);

    // make the triangle
    triangleFrame = new JInternalFrame("", false, false, false, false);
    triangleFrame.setOpaque(false);
    triangleFrame
        .getRootPane()
        .setBackground(new Color(0, 0, 0, 0)); // needs this to actually do the trick
    triangleFrame.setContentPane(
        new Triangle("SE", 0, TRIANGLE_BASE, TRIANGLE_DEFAULT_HEIGHT, TRIANGLE_BASE));
    triangleFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    triangleFrame.setSize(TRIANGLE_BASE, TRIANGLE_DEFAULT_HEIGHT);
    triangleFrame.setBorder(null);

    // remove the ability to move the triangle iframe
    MouseMotionListener[] actions =
        (MouseMotionListener[]) triangleFrame.getListeners(MouseMotionListener.class);
    for (int i = 0; i < actions.length; i++) triangleFrame.removeMouseMotionListener(actions[i]);

    // make the buttons
    moveButton = new JButton(Base.getImageIcon("codewindow-activ-move.gif", desktop));
    moveButton.setDisabledIcon(Base.getImageIcon("codewindow-inact-move.gif", desktop));
    moveButton.setVisible(true);
    moveButton.setBorder(null);
    moveButton.setOpaque(false);
    moveButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    closeButton = new JButton(Base.getImageIcon("codewindow-activ-close.gif", desktop));
    closeButton.setDisabledIcon(Base.getImageIcon("codewindow-inact-close.gif", desktop));
    closeButton.setVisible(true);
    closeButton.setBorder(null);
    closeButton.setOpaque(false);
    closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
    buttonPanel.setBorder(null);
    buttonPanel.setOpaque(false);
    buttonPanel.add(moveButton);
    buttonPanel.add(closeButton);

    buttonFrame = new JInternalFrame("", false, false, false, false);
    buttonFrame.setContentPane(buttonPanel);
    buttonFrame.setOpaque(false);
    buttonFrame.getRootPane().setBackground(new Color(0, 0, 0, 0));
    buttonFrame.setSize(BUTTON_ICON_WIDTH * 2 + BUTTON_GAP, BUTTON_ICON_HEIGHT);
    buttonFrame.setBorder(null);

    // myriad event handling

    installFocusHandlers(buttonPanel);

    // hide code window when escape key is hit
    textarea.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setVisible(false);
          }
        });
    // add dragging function of the move button,
    // reset the triangle after mouse release, and shift the editFrame
    // along with the mouse when the user is moving the window
    mxMouseControl moveListener = createMoveListener();
    moveButton.addMouseListener(moveListener);
    moveButton.addMouseMotionListener(moveListener);
    closeButton.addMouseListener(createCloseListener());
    // listens to resizing of editFrame and adjusts the position of the
    // buttons and the shape of the triangle accordingly
    editFrame.addComponentListener(createResizeListener());
    // when code windows are on top of each other, layers them correctly
    // such that when the user clicks on any part of a code window
    // all three component internal frames are brought to the top
    // so they appear "focused" also
    InternalFrameListener iframeListener =
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            moveToFrontLayer();
          }

          public void internalFrameDeactivated(InternalFrameEvent e) {
            moveToBackLayer();
          }
        };
    editFrame.addInternalFrameListener(iframeListener);
    buttonFrame.addInternalFrameListener(iframeListener);
    triangleFrame.addInternalFrameListener(iframeListener);

    // add everything to desktop

    desktop.add(editFrame);
    desktop.add(buttonFrame);
    desktop.add(triangleFrame);
    moveToBackLayer();
  }
Esempio n. 2
0
  // ´°¿ÚµÄ»ù±¾ÅäÖÃ
  public void initWindow() {
    dispose();
    setUndecorated(true);
    setRootPaneCheckingEnabled(false);
    setSize(380, 296);
    setResizable(false);
    javax.swing.plaf.InternalFrameUI jf = jif.getUI();
    ((javax.swing.plaf.basic.BasicInternalFrameUI) jf).setNorthPane(null);
    jif.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 2));
    jif.setSize(380, 296);
    jif.setEnabled(false);

    jsetup.setBounds(287, -2, 28, 20);
    jclose.setBounds(343, -2, 39, 20);
    jmin.setBounds(315, -2, 28, 20);
    jif.getContentPane().add(jsetup);
    jif.getContentPane().add(jclose);
    jif.getContentPane().add(jmin);

    setJLabel(header);
    header.setBounds(20, 140, 87, 87);
    jif.getContentPane().add(header);

    setJLabel(photo);
    photo.setBounds(23, 142, 83, 83);
    jif.getContentPane().add(photo);

    userInput.setBounds(118, 142, 188, 25);
    userInput.setEditable(true);
    userInput.setFont(new Font("Times New Roman", 0, 14));
    jif.getContentPane().add(userInput);

    setJLabel(register);
    register.setBounds(316, 144, 51, 16);
    jif.getContentPane().add(register);

    pwdInput.setBounds(118, 175, 188, 25);
    jif.getContentPane().add(pwdInput);

    setJLabel(minaFind);
    minaFind.setBounds(316, 178, 51, 16);
    jif.getContentPane().add(minaFind);

    remPwd.setBounds(117, 210, 72, 16);
    jif.getContentPane().add(remPwd);
    setJCheckbox(remPwd);

    autoLogin.setBounds(202, 210, 72, 16);
    jif.getContentPane().add(autoLogin);
    setJCheckbox(autoLogin);

    setJLabel(swit);
    swit.setBounds(15, 255, 25, 25);
    jif.getContentPane().add(swit);

    setButton(jlogin);
    jlogin.setBounds(115, 247, 165, 40);
    jlogin.setFont(new Font("ËÎÌå", 0, 12));
    jlogin.setIconTextGap(-108);
    jif.getContentPane().add(jlogin);

    setJLabel(right);
    right.setBounds(333, 248, 38, 38);
    jif.getContentPane().add(right);

    setJLabel(state);
    state.setBounds(92, 210, 11, 11);
    jif.getContentPane().add(state, 3);

    setWindowDray(jif);
    jif.getContentPane().add(bg);
    getContentPane().add(jif);
    setLocation(
        (Toolkit.getDefaultToolkit().getScreenSize().width - getSize().width) / 2,
        (Toolkit.getDefaultToolkit().getScreenSize().height - getSize().height) / 2);
    setButton(jsetup);
    setButton(jclose);
    setButton(jmin);

    this.setTitle("PQQ-http://www.yanyulin.info");
    this.setIconImage(new ImageIcon(getClass().getResource("pics/xiaomi.jpg")).getImage());
    setAlwaysOnTop(true);
    jif.setVisible(true);
    setVisible(true);
  }