⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tipwindow.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 */
package com.sshtools.ui.awt.tooltips;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.IllegalComponentStateException;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Window;

import com.sshtools.ui.awt.ImageTextLabel;


class TipWindow extends Window {
  private ImageTextLabel textLabel;
  private long lastShow;
  private boolean dismissed;
  private Component component;
  private String text;

  TipWindow(Frame owner) {
    super(owner);
    textLabel = new ImageTextLabel() {
      public void paint(Graphics g) {
        super.paint(g);
        g.setColor(getForeground());
        Dimension s = getSize();
        g.drawRect(0, 0, s.width -1 , s.height -1);
      }
    };
    textLabel.setMargin(new Insets(2, 2, 2, 2));
    setLayout(new GridLayout(1, 1));
    add(textLabel);
  }
  
  boolean isDismissed() {
    return dismissed;
  }

  boolean isOutOfDate() {
    return (System.currentTimeMillis() > (lastShow + 5000));
  }
  
  synchronized void dismiss() {
    dismissed = true;
    hide();
  }

  synchronized void popup(int x, int y, Component component, String text) {
     
    invalidate();
    textLabel.setText(text);
    textLabel.setForeground(ToolTipManager.getInstance().foreground);
    textLabel.setBackground(ToolTipManager.getInstance().background);
    validate();
    pack();
    try {
        if(x != -1 && y != -1) {
		    setLocation(x + 8, y + 8);
        }
        else {
		    Point p = component.getLocationOnScreen();
		    Dimension s = component.getSize();
		    setLocation(p.x + 8, p.y + s.height  + 8);
        }
	    setVisible(true);
	    toFront();
	    lastShow = System.currentTimeMillis();
	    dismissed = false;      
    }
    catch(IllegalComponentStateException icse) {
      
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -