package showip3;
import java.awt.*;
import static java.awt.GraphicsDevice.WindowTranslucency.*;
import java.awt.event.*;
import java.awt.geom.Ellipse2D;
import java.io.FileInputStream;
import java.io.IOException;
import javax.swing.border.EtchedBorder;
//network
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.swing.*;
public class ShowIP3 extends JFrame {
public ShowIP3() {
super("ShapedWindow");
setLayout(new GridBagLayout());
// It is best practice to set the window's shape in
// the componentResized method. Then, if the window
// changes size, the shape will be correctly recalculated.
/*addComponentListener(new ComponentAdapter() {
// Give the window an elliptical shape.
// If the window is resized, the shape is recalculated here.
@Override
public void componentResized(ComponentEvent e) {
setShape(new Ellipse2D.Double(0,0,getWidth(),getHeight()));
}
});*/
setUndecorated(true);
setSize(new Dimension(300,80));
//setLocation(500,280);
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension screenSize = tk.getScreenSize();
int screenHeight = screenSize.height-125;
int screenWidth = screenSize.width-310;
this.setLocation(screenWidth,screenHeight);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CheckIP IPx = new CheckIP();
String IPx2 = IPx.setIP;
JLabel label1 = new JLabel();
label1.setText(IPx2);
label1.setSize(new Dimension(120,80));
label1.setVerticalAlignment(SwingConstants.CENTER );
label1.setHorizontalAlignment(SwingConstants.CENTER);
label1.setBorder ( BorderFactory.createEtchedBorder ( EtchedBorder.LOWERED ) );
label1.setForeground((Color.red));
label1.setFont(new Font("",Font.BOLD | Font.ITALIC,48));
add(label1);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Determine what the GraphicsDevice can support.
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
final boolean isTranslucencySupported =
gd.isWindowTranslucencySupported(TRANSLUCENT);
//If shaped windows aren't supported, exit.
if (!gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT)) {
System.err.println("Shaped windows are not supported");
System.exit(0);
}
//If translucent windows aren't supported,
//create an opaque window.
if (!isTranslucencySupported) {
System.out.println(
"Translucency is not supported, creating an opaque window");
}
// Create the GUI on the event-dispatching thread
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ShowIP3 sw = new ShowIP3();
// Set the window to 70% translucency, if supported.
if (isTranslucencySupported) {
sw.setOpacity(0.7f);
}
// Display the window.
sw.setVisible(true);
}
});
}
}