Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Need Java-help или первые шаги в Java-программировании.

Модерирует : ShIvADeSt

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

vs6262



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

 
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.awt.*;
import java.awt.event.*;
import java.util.function.*;
 
public class Core {
 
    public static void main(String[] args) {
        new Core();
    }
 
    public boolean Window_Errors_00001 = true;
 
    public Point location;
 
    // 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();
 
    int _W_Main = 700;
    int _H_Main = 600;
    int _X_Main = Math.round(width / 2 - _W_Main / 2);
    int _Y_Main = Math.round(height / 2 - _H_Main / 2);
 
    int _W_Error = 800;
    int _H_Error = 500;
 
    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(_X_Main, _Y_Main);
        frame.setSize(_W_Main, _H_Main);
        // 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.setFocusableWindowState(false);
        frame.setResizable(false);
 
 
       frame.setVisible(true);
 
            location = frame.getLocationOnScreen();
            int _X_Error = Math.round(location.x + _W_Main / 2 - _W_Error / 2);
            int _Y_Error = Math.round(location.y + _H_Main / 2 - _H_Error / 2);
            //x_Core = location.x;
            //y_Core = location.y;
 
 
            if (Window_Errors_00001 == true) {
                Consumer<String> consumer = s -> label.setText(s);
                new Window_Errors_00001(_W_Error, _H_Error, _X_Error, _Y_Error);
            }
        }
    }
 
    class Window_Errors_00001 {
        private static final Dimension PAN1_DIM = new Dimension(1000, 800);
 
        JTextArea textfeld;
 
       public Window_Errors_00001(int _w, int _h, int _x, int _y) {
            JFrame frame = new JFrame();
            // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.dispatchEvent(new WindowEvent(frame,WindowEvent.WINDOW_CLOSING));
 
            frame.setLocation(_x, _y);
            frame.setSize(_w, _h);
 
            frame.setUndecorated(true);
            frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
 
            JPanel panel = new JPanel();
            panel.setBackground(Color.DARK_GRAY);
            // pan1.setBounds(0, 0, 900, 600);
            panel.setPreferredSize(PAN1_DIM);
            // frame1.add(pan1);
            panel.setLayout(null);
//            panel.setLocation(5, 5);
           // panel.setLayout(new FlowLayout());
          //  panel.setBackground(Color.DARK_GRAY);
 
            //5-zeiliges und 20-spaltiges Textfeld wird erzeugt
            textfeld = new JTextArea("",5, 5);
            textfeld.setBounds(10,10,200,270);
            textfeld.setBackground(Color.BLACK);
            textfeld.setForeground(Color.WHITE);
            textfeld.setSelectionStart(5);
            textfeld.setSelectionEnd(20);
            textfeld.setEditable(false);
/*
            //Text f&#252;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.");
*/
            textfeld.setLineWrap(true);
            textfeld.setWrapStyleWord(true);
 
            //Zeilenumbruch wird eingeschaltet
            textfeld.setLineWrap(true);
            //Zeilenumbr&#252;che erfolgen nur nach ganzen W&#246;rtern
            textfeld.setWrapStyleWord(true);
            //Ein JScrollPane, der das Textfeld beinhaltet, wird erzeugt
 
//            JScrollPane scrollpane = new JScrollPane(textfeld);
            JScrollPane sp3 = new JScrollPane(textfeld,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                   // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            sp3.setBounds(textfeld.getX(), textfeld.getY(), textfeld.getWidth() + 10,
                    textfeld.getHeight() + 10);
 
           panel.add(textfeld);
           panel.add(sp3);
//          panel.add(scrollpane);
           frame.add(panel);
 
// JButton mit Text "Dr&#252;ck mich" wird erstellt
            JButton button = new JButton("Close") {
                public JToolTip createToolTip() {
                    JToolTip tip = super.createToolTip();
                    tip.setBackground(Color.BLUE);
                    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(UIManager.getColor("control"));
                }
            });
 
            button.setBounds(10,300,200,60);
            button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 
            Border bored = BorderFactory.createLineBorder(Color.decode("#FFFFFF"));
 
            button.setBorder(bored);
 
            button.setToolTipText("Close");
            //button.setBackground(Color.BLUE);
            button.setForeground(Color.WHITE);
            //button.
            button.addActionListener(new ActionListener() {
                    public void actionPerformed (ActionEvent e){
                        // System.out.println("You clicked the button");
                        frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
                    }
                });
 
            panel.add(button);
 
            frame.add(panel);
 
            frame.setContentPane(panel);
 
            MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme_000001());
            try {
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            } catch (Exception e) {
                e.printStackTrace();
            }
 
            SwingUtilities.updateComponentTreeUI(frame);
 
            //           frame.toFront();
            frame.setAlwaysOnTop(true);
 
            frame.setResizable(false);
 
            frame.setVisible(true);
 
            String str1 = "######                                             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.";
 
            for(int i = 0; i < 1; i++) {
                try {
                    // System.out.println(new Date( ));
                    Thread.sleep(300);
                        textfeld.append(str1 + ", Peter. " + str1 + str1);
                    // System.out.println(new Date( ));
                } catch (Exception e) {
                    System.out.println(e);
                }
            }
/*
            while (true) {
                try {
                   // System.out.println(new Date( ));
                    Thread.sleep(5*60*100);
                    textfeld.append(", Peter");
                   // System.out.println(new Date( ));
                } catch (Exception e) {
                    System.out.println(e);
                }
            }
*/
    }
}
 
 
    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);
        }
    }
 
 
 

Всего записей: 2189 | Зарегистр. 25-02-2013 | Отправлено: 09:25 09-02-2024 | Исправлено: vs6262, 09:55 09-02-2024
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Need Java-help или первые шаги в Java-программировании.


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru