All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yiwowang.intellij.finding.TipDialog Maven / Gradle / Ivy

The newest version!
package com.yiwowang.intellij.finding;

import com.intellij.ui.components.JBLabel;

import javax.swing.*;
import java.awt.*;

public class TipDialog {
    JDialog jDialog;
    JBLabel tipLabel;
    String tip;

    TipDialog() {
        jDialog = new JDialog();
        jDialog.setTitle("Finding");
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        double screenWidth = dim.getWidth();
        double screenHeight = dim.getHeight();
        double size = Math.min(screenWidth, screenHeight);
        int width = (int) (size * 0.6);
        int height = (int) (size * 0.3);
        jDialog.setSize(width, height);
        int x = (int) ((screenWidth - width) / 2);
        int y = (int) ((screenHeight - height) / 2);
        jDialog.setLocation(x, y);
        tipLabel = new JBLabel();
        jDialog.add(tipLabel);
        tipLabel.setHorizontalAlignment(SwingConstants.CENTER);
        tipLabel.setVerticalAlignment(SwingConstants.CENTER);
        jDialog.setAlwaysOnTop(true);
        jDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    }

    public void setText(String text) {
        tipLabel.setText(text);
    }

    public void show() {
        jDialog.setVisible(true);
    }


    public void close() {
        jDialog.dispose();
        jDialog = null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy