vs6262
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору /* https://cratecode.com/info/java-swing-library http://www.java2s.com/Tutorials/Java/Scripting_in_Java/0040__Scripting_in_Java_eval.htm https://stackoverflow.com/questions/61122943/transparent-unclickable-and-unfocusable-window-in-java */ import javax.swing.*; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.metal.DefaultMetalTheme; import javax.swing.plaf.metal.MetalLookAndFeel; import java.awt.*; import java.util.function.*; public class Core { public static void main(String [] args) { new Core(); } public Point location; public int x_Core = 0; public int y_Core = 0; public Core() { JFrame frame = new JFrame(); JLabel label = new JLabel("Click in Frame 2 to transfer text!"); frame.add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(300, 300); frame.setSize(300, 300); // frame.setLocationRelativeTo(null); frame.setUndecorated(true); frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); JPanel panel = new JPanel(); panel.setBackground(Color.DARK_GRAY); frame.setContentPane(panel); MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme_000001()); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(frame); frame.setAlwaysOnTop(true); frame.setFocusableWindowState(false); frame.setResizable(false); frame.setVisible(true); location = frame.getLocationOnScreen(); x_Core = location.x; y_Core = location.y; Consumer<String> consumer = s -> label.setText(s); new Window_Login(consumer); } } class Window_Login{ private int clicks; public Window_Login(Consumer<String> consumer) { JFrame frame = new JFrame(); // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setLocation(x_Core+40, y_Core+40); frame.setSize(350, 250); frame.setLocationRelativeTo(null); // frame.getLocation(); frame.setUndecorated(true); frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); JPanel panel = new JPanel(); panel.setBackground(Color.DARK_GRAY); //5-zeiliges und 20-spaltiges Textfeld wird erzeugt JTextArea textfeld = new JTextArea(5, 20); //Text für das Textfeld wird gesetzt textfeld.setText("Lorem ipsum dolor sit amet, " + "consetetur sadipscing elitr, sed diam nonumy " + "eirmod tempor invidunt ut labore et " + "dolore magna aliquyam erat, sed diam voluptua. " + "At vero eos et accusam et justo duo dolores et " + "ea rebum."); //Zeilenumbruch wird eingeschaltet textfeld.setLineWrap(true); //Zeilenumbrüche erfolgen nur nach ganzen Wörtern textfeld.setWrapStyleWord(true); //Ein JScrollPane, der das Textfeld beinhaltet, wird erzeugt JScrollPane scrollpane = new JScrollPane(textfeld); //Scrollpane wird unserem Panel hinzugefügt panel.add(scrollpane); frame.add(panel); textfeld.append(", Peter"); frame.setContentPane(panel); MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme_000001()); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(frame); frame.setAlwaysOnTop(true); frame.setResizable(false); frame.setVisible(true); } } class MyDefaultMetalTheme_000001 extends DefaultMetalTheme { public ColorUIResource getWindowTitleInactiveBackground() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getWindowTitleBackground() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getPrimaryControlHighlight() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getPrimaryControlDarkShadow() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getPrimaryControl() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getControlHighlight() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getControlDarkShadow() { return new ColorUIResource(java.awt.Color.BLACK); } public ColorUIResource getControl() { return new ColorUIResource(java.awt.Color.BLACK); } } |