import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.util.Properties; import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.border.Border; public class Core { public static JFrame Info_000001 = null; public static JLabel Info_000001L = null; public static void main(String[] args) throws IOException { Properties prop = System.getProperties(); if ((System.getProperty("java.version").startsWith("21.") || System.getProperty("java.version").startsWith("22.") || System.getProperty("java.version").startsWith("23.") || System.getProperty("java.version").startsWith("24.") || System.getProperty("java.version").startsWith("25.")) && prop.getProperty("java.vendor").startsWith("Oracle")) { System.out.println("OK"); System.out.println("JVM Version : " + System.getProperty("java.version")); System.out.println ("JVM Vendor : " + prop.getProperty("java.vendor")); CoreSecond.mainSecond(); // calling B class's method } else { System.out.println("Ups"); System.out.println("JVM Version : " + System.getProperty("java.version")); System.out.println ("JVM Vendor : " + prop.getProperty("java.vendor")); String InfoText = "Systemrequirements: Oracle JVM (21 - 25)"; new Info_000001(InfoText); } } } class Info_000001 { public Info_000001(String ToolTipText) { new Info_000001_Helper(ToolTipText); } } class Info_000001_Helper { private static final Dimension PAN1_DIM = new Dimension(1000, 800); public Info_000001_Helper(String ToolTipText) { int _w = 350; int _h = 64; // of the screen in pixels Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); // width will store the width of the screen int width = (int) size.getWidth(); // height will store the height of the screen int height = (int) size.getHeight(); Core.Info_000001 = new JFrame(""); //frame.setExtendedState(JFrame.MAXIMIZED_BOTH); Core.Info_000001.setUndecorated(true); // <-- the title bar is removed here Core.Info_000001.getContentPane().setBackground(new Color(1f,0f,0f,.5f )); Core.Info_000001.setBackground(new Color(1f,0f,0f,.5f )); Core.Info_000001.getRootPane().setBackground(new Color(1f,0f,0f,.5f )); Core.Info_000001.setAlwaysOnTop(true); Core.Info_000001.setLocation((int)Math.round(width/2-_w/2), (int)Math.round(height/2-_h/2)); Core.Info_000001.setSize(_w, _h); Timer timer = new Timer(20000, new ActionListener() { public void actionPerformed(ActionEvent e) { Core.Info_000001.setVisible(false); Core.Info_000001.dispose(); } }); timer.setRepeats(false); timer.start(); JPanel panelCore = new RoundedPanel_000002(4, Color.decode("#0000ff")); JLabel myLabel= new JLabel(""); // myLabel.setBounds(90,30,10,26); myLabel.setBounds(30, 2, 300, 20); myLabel.setText(ToolTipText); myLabel.setBackground(new Color(1f,0f,0f,.5f )); myLabel.setForeground(Color.decode("#ffffff")); myLabel.setFont(new Font("Ariel", Font.PLAIN, 16)); panelCore.add(myLabel); // JPanel panelCore = new JPanel(); //panel.setBounds(0, 0, _w-20, _h-20); panelCore.setSize(_w-60, _h-20); panelCore.setBackground(Color.DARK_GRAY); // pan1.setBounds(0, 0, 900, 600); panelCore.setPreferredSize(PAN1_DIM); // frame1.add(pan1); panelCore.setLayout(null); JLabel label = new JLabel(""); // JButton mit Text "Drück mich" wird erstellt JButton button = new JButton("Close") { public JToolTip createToolTip() { JToolTip tip = super.createToolTip(); tip.setBackground(Color.BLACK); tip.setForeground(Color.WHITE); return tip; } }; button.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { button.setBackground(Color.DARK_GRAY); } public void mouseExited(java.awt.event.MouseEvent evt) { button.setBackground(Color.BLACK); } }); button.setBounds(110,30,130,26); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); Border bored = BorderFactory.createLineBorder(Color.decode("#FFFFFF")); button.setBorder(bored); button.setToolTipText("Close"); button.setBackground(Color.BLACK); button.setForeground(Color.WHITE); //button. /* button.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e){ // System.out.println("You clicked the button"); //Info_000001.dispatchEvent(new WindowEvent(Core.Info_000001, WindowEvent.WINDOW_CLOSING)); //Core.Info_000001.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); */ //button. button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Core.Info_000001.dispose(); } }); panelCore.add(label); panelCore.add(button); // Core.Info_000001.add(panelCore); panelCore.setBounds(10,10,100,60); // panelCore.setOpaque(false); Core.Info_000001.add(panelCore); Core.Info_000001.setVisible(true); } } class RoundedPanel_000002 extends JPanel { private Color backgroundColor; private int cornerRadius = 15; public RoundedPanel_000002(LayoutManager layout, int radius) { super(layout); cornerRadius = radius; } public RoundedPanel_000002(LayoutManager layout, int radius, Color bgColor) { super(layout); cornerRadius = radius; backgroundColor = bgColor; } public RoundedPanel_000002(int radius) { super(); cornerRadius = radius; } public RoundedPanel_000002(int radius, Color bgColor) { super(); cornerRadius = radius; backgroundColor = bgColor; } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Dimension arcs = new Dimension(cornerRadius, cornerRadius); int width = getWidth(); int height = getHeight(); Graphics2D graphics = (Graphics2D) g; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //Draws the rounded panel with borders. if (backgroundColor != null) { graphics.setColor(backgroundColor); } else { graphics.setColor(getBackground()); } graphics.fillRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height); //paint background graphics.setColor(Color.decode("#ffffff")); graphics.drawRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height); //paint border } } |