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

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

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

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

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

vs6262



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

Код:
 
import com.sun.tools.javac.Main;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
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.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.function.*;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
 
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
 
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.AWTEvent;
import java.awt.MouseInfo;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.util.stream.Collectors;
 
import javax.swing.JFrame;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultCaret;
 
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
 
 
public class CoreSecond {
 
 
    public static String myJar =  "CoreSecond.jar";
    public static boolean Testing_in_IDE = false;
    public static boolean Window_Errors_00001 = true;
 
    public static String MyDefaultMetalTheme_000001_WindowColor = "170707";
 
 
    public static JTextArea textfeld;
    public static JLabel label;
    public static volatile List<String[]> _rowList = new ArrayList<String[]>();
    public static String Er_0001 = "";
    public static volatile List<String[]> Er_0002 = new ArrayList<String[]>();
    public static boolean Er_0003 = true;
    public static boolean Er_0004 = true;
    public static JLabel picLabel = null;
    public static JLabel picLabel_Settings = null;
    public static boolean picLabel_Triger = true;
    public static JFrame ToolTip_000001 = null;
    public static JLabel picLabel_ToolTip = null;
    public static JDialog Errors_Dialog_000001 = null;
    public static JFrame MainFrame_000001 = null;
    public static boolean FocusHelper_000001 = true;
 
 
    public static void mainSecond() throws IOException {
 
 
//  Check is it intellij
        boolean intellij = false;
        try {
            intellij = Main.class.getClassLoader().loadClass("com.intellij.rt.execution.application.AppMainV2") != null;
        } catch (ClassNotFoundException e) {
        }
        System.out.println(intellij);
        CoreSecond.Testing_in_IDE = intellij;
//  Check is it intellij END
 
/*
public static boolean isEclipse() {
    boolean isEclipse = System.getProperty("java.class.path").toLowerCase().contains("eclipse");
    return isEclipse;
}
*/
 
        new CoreSecond();
    }
 
    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 = 1100;
    int _H_Main = 800;
    int _X_Main = Math.round(width / 2 - _W_Main / 2);
    int _Y_Main = Math.round(height / 2 - _H_Main / 2);
 
    int _W_Error = 1200;
    int _H_Error = 700;
 
 
 
 
    public CoreSecond() throws IOException {
 
 
        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.setDefaultCloseOperation(JFrame.DISPOSE_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) {
            System.out.println(e);
        }
 
        SwingUtilities.updateComponentTreeUI(frame);
 
        new ProgramIcons_000001("don.png", "don.png", frame);
 
/*
        List<Image> icons = new ArrayList<Image>();
        icons.add(getImage("someImage16x16.gif"));
        icons.add(getImage("someImage32x32.gif"));
        frame.setIconImages(icons);
*/
 
 
        // Set System Icons
        ImageIcon img = new ImageIcon("./src/main/resources/icons/red.png");
        //frame.setIconImage(img.getImage());
 
//        frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("./src/main/resources/icons/don.&#252;ng")));
//        CoreSecond.class.getClassLoader().getResource("./src/main/resources/icons/don.&#252;ng");
 
 
        //   frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("./src/main/resources/icons/don.&#252;ng")));
 
 
//        frame.setIconImage(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("icon.jpg")));
 
 
        //frame.setAlwaysOnTop(true);
        frame.setFocusableWindowState(true);
        //      frame.setFocusableWindowState(false);
        frame.setResizable(true);
 
        // new setTextJTextarea_00001(CoreSecond.textfeld, str3);
 
      //  frame.addWindowFocusListener(new Listener());
/*
        frame.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
 
                frame.toFront();
                for (int i = 0; i < 1; i++) {
                    try {
                        // System.out.println(new Date( ));
                        Thread.sleep(20);
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            @Override
                            //myFrame is object of Window or JFrame
                            public void run() {
 
                                CoreSecond.Errors_Dialog_000001.toFront();
                                CoreSecond.Errors_Dialog_000001.requestFocus();
                                //myFrame.toFront();
                                //myFrame.repaint();
                            }
                        });
 
                    } catch (Exception _e) {
                        System.out.println(_e);
                    }
                }
                //System.out.println("Mouse was clicked on my frame!");
            }
        });
*/
 
        frame.setVisible(true);
 
        //frame.setAlwaysOnTop(true);
        frame.setLocationRelativeTo(null);
 
        frame.toFront();
 
 
 
 
 
        frame.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
 
                for (int i = 0; i < 1; i++) {
                    try {
                        // System.out.println(new Date( ));
                        Thread.sleep(0);
                        if (CoreSecond.MainFrame_000001 != null) {
                            CoreSecond.MainFrame_000001.toFront();
                        }
                        if (CoreSecond.Errors_Dialog_000001 != null) {
                            CoreSecond.Errors_Dialog_000001.toFront();
                            CoreSecond.Errors_Dialog_000001.requestFocus();
                        }
                    } catch (Exception _e) {
                        System.out.println(_e);
                    }
                }
            }
        });
 
 
 
        frame.addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent componentEvent) {
                // do stuff
                for (int i = 0; i < 1; i++) {
                    try {
                        // System.out.println(new Date( ));
                        Thread.sleep(0);
                        if (CoreSecond.MainFrame_000001 != null) {
                            CoreSecond.MainFrame_000001.toFront();
                        }
                        if (CoreSecond.Errors_Dialog_000001 != null) {
                            CoreSecond.Errors_Dialog_000001.toFront();
                            CoreSecond.Errors_Dialog_000001.requestFocus();
                        }
                    } catch (Exception _e) {
                        System.out.println(_e);
                    }
                }
            }
        });
 
 
 
 
/*
        Toolkit.getDefaultToolkit().addAWTEventListener(
                new Listener(), AWTEvent.MOUSE_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
*/
 
 
        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 (CoreSecond.Window_Errors_00001 == true) {
            //Consumer<String> consumer = s -> label.setText(s);
            new Window_Errors_00001(frame, _W_Error, _H_Error, _X_Error, _Y_Error);
 
        }
 
 
        CoreSecond.MainFrame_000001 = frame;
 
        while (true) {
            //for (int i = 0; i < 1; i++) {
                try {
                    Thread.sleep(1000);
                    CoreSecond.FocusHelper_000001 = true;
                } catch (Exception _e) {
                    System.out.println(_e);
                }
           // }
 
        }
    }
 
    /*
    public class Listener extends WindowAdapter {
        public void windowLostFocus(WindowEvent e)
        {
            // My Code
            //System.out.println("hkh");
 
            if (CoreSecond.FocusHelper_000001) {
                CoreSecond.FocusHelper_000001 = false;
 
                for (int i = 0; i < 1; i++) {
                    try {
                        // System.out.println(new Date( ));
                        Thread.sleep(20);
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            @Override
                            //myFrame is object of Window or JFrame
                            public void run() {
                                CoreSecond.MainFrame_000001.toFront();
                                CoreSecond.Errors_Dialog_000001.toFront();
                                CoreSecond.Errors_Dialog_000001.requestFocus();
                                //myFrame.toFront();
                                //myFrame.repaint();
                            }
                        });
 
                    } catch (Exception _e) {
                        System.out.println(_e);
                    }
 
                }
            }
 
 
 
 
        }
    }
*/
 
 
/*
    private static class Listener implements AWTEventListener {
        public void eventDispatched(AWTEvent event) {
            //System.out.print(MouseInfo.getPointerInfo().getLocation() + " | ");
            System.out.println(event);
        }
    }
*/
 
 
}
 
 
 
    class Window_Errors_00001 {
        private static final Dimension PAN1_DIM = new Dimension(1000, 800);
        private DefaultListModel model = new DefaultListModel();
        private JList list = new JList(model);
 
//        JTextArea textfeld;
 
       public Window_Errors_00001(JFrame _frame, int _w, int _h, int _x, int _y) throws IOException {
            JDialog frame = new JDialog();
            //JFrame frame = new JFrame("");
            // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.dispatchEvent(new WindowEvent(frame,WindowEvent.WINDOW_CLOSING));
 
            int __x = _frame.getLocationOnScreen().x;
            int __y = _frame.getLocationOnScreen().y;
            int __w = _frame.getWidth();
            int __h = _frame.getHeight();
            __x = Math.round(__w/2 + __x - _w/2);
            __y = Math.round(__h/2 + __y - _h/2);
            frame.setLocation(__x, __y);
            frame.setSize(_w, _h);
 
            frame.setUndecorated(true);
            frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
 
 
 
           JPanel panel = new JPanel();
            //panel.setBounds(0, 0, _w-20, _h-20);
            panel.setSize(_w-60, _h-20);
            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);
 
           CoreSecond.label = new  JLabel("");
           CoreSecond.label.setBounds(440, 130, 600, 20);
           CoreSecond.label.setFont(new Font("Arial", Font.PLAIN, 14));
 
//           label.setBackground(Color.BLACK);
           CoreSecond.label.setForeground(Color.WHITE);
 
 
 
 
//           label.setText("hophoi");
 
            //5-zeiliges und 20-spaltiges Textfeld wird erzeugt
            CoreSecond.textfeld = new JTextArea("",5, 5);
            CoreSecond.textfeld.setBounds(440,170,700,300);
            CoreSecond.textfeld.setBackground(Color.BLACK);
            CoreSecond.textfeld.setForeground(Color.WHITE);
            CoreSecond.textfeld.setSelectionStart(5);
            CoreSecond.textfeld.setSelectionEnd(20);
            CoreSecond.textfeld.setEditable(false);
 
           CoreSecond.textfeld.setFont(new Font("Serif", Font.ITALIC, 14));
           //CoreSecond.textfeld.setLineWrap(true);
           //CoreSecond.textfeld.setWrapStyleWord(true);
 
 
 
           Border border = BorderFactory.createLineBorder(Color.BLACK);
           CoreSecond.textfeld.setBorder(BorderFactory.createCompoundBorder(border,
                   BorderFactory.createEmptyBorder(10, 10, 10, 10)));
 
 
 
//            JScrollPane scrollpane = new JScrollPane(textfeld);
            JScrollPane sp3 = new JScrollPane(CoreSecond.textfeld,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                   // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
 
            //sp3.setBounds(12, 312, 477, 134);
            sp3.setBounds(CoreSecond.textfeld.getX(), CoreSecond.textfeld.getY(), CoreSecond.textfeld.getWidth() + 10,
                    CoreSecond.textfeld.getHeight() + 10);
 
           sp3.getViewport().getView().setBackground(Color.BLACK);
           sp3.getViewport().getView().setForeground(Color.WHITE);
 
           sp3.setBackground(Color.BLACK);
           sp3.setForeground(Color.BLACK);
/*
           DefaultCaret caret = (DefaultCaret)CoreSecond.textfeld.getCaret();
           caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
*/
//           JScrollPane sp3 = new JScrollPane(CoreSecond.textfeld), JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
/*
           //            JScrollPane scrollpane = new JScrollPane(textfeld);
           JScrollPane sp3 = new JScrollPane(list);
           sp3.setBounds(CoreSecond.textfeld.getX(), CoreSecond.textfeld.getY(), CoreSecond.textfeld.getWidth() + 10,
                   CoreSecond.textfeld.getHeight() + 10);
*/
            // scrollbar color
 
//           UIManager.put("ScrollBar.thumb", new ColorUIResource(new Color(57,57,57)));
//           UIManager.put("ScrollBar.foreground", Color.decode("#FF0000"));
 
/*
           // scrollbar colors
           UIManager.put("ScrollBar.trackHighlightForeground", (new Color(57,57,57)));
           UIManager.put("scrollbar", (new Color(57,57,57)));
           UIManager.put("ScrollBar.thumb", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.thumbHeight", 2);
           UIManager.put("ScrollBar.background", (new Color(57,57,57)));
           UIManager.put("ScrollBar.thumbDarkShadow", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.thumbShadow", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.thumbHighlight", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.trackForeground", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.trackHighlight", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.foreground", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.shadow", new ColorUIResource(new Color(57,57,57)));
           UIManager.put("ScrollBar.highlight", new ColorUIResource(new Color(57,57,57)));
*/
 
 
           sp3.getViewport().getView().setBackground(Color.BLACK);
           sp3.getViewport().getView().setForeground(Color.WHITE);
 
           sp3.getVerticalScrollBar().setPreferredSize(new Dimension(10, 0));
           sp3.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 10));
/*
           sp3.getVerticalScrollBar().setBackground(Color.decode("#777777"));
           sp3.getHorizontalScrollBar().setBackground(Color.decode("#777777"));
           sp3.getVerticalScrollBar().setForeground(Color.decode("#777777"));
           sp3.getHorizontalScrollBar().setForeground(Color.decode("#777777"));
           sp3.setBorder(BorderFactory.createLineBorder(Color.BLACK));
           sp3.getHorizontalScrollBar().setBackground(new Color(192, 192, 128));
           sp3.getVerticalScrollBar().setBackground(new Color(192, 192, 128));
*/
          // https://javawiki.sowas.com/doku.php?id=swing:uidefaults-uimanager
           // https://gist.github.com/ezhov-da/357f80b3182cce3ece19d47935d377b8
           
           UIManager.put("ScrollBar.background", Color.decode("#c0c080"));
           //UIManager.put("ScrollBar.darkShadow", Color.decode("#ff0000"));
           //UIManager.put("ScrollBar.shadow", Color.decode("#ff0000"));
          //sp3.setBorder(BorderFactory.createLineBorder(Color.decode("#00ff00")));
           //UIManager.put("ScrollBar.thumbDarkShadow", Color.decode("#ff0000"));
           //UIManager.put("ScrollBar.thumbShadow", Color.decode("#ff0000"));
           //UIManager.put("ScrollBar.thumbHighlight", Color.decode("#ff0000"));
           UIManager.put("Button.background", Color.decode("#c0c080"));
 
 
 
           panel.add(CoreSecond.textfeld);
           panel.add(sp3);
//           sp3.add(list);
//          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.BLACK);
                    tip.setForeground(Color.WHITE);
                    return tip;
                }
            };
 
           button.setBackground(Color.BLACK);
           button.setForeground(Color.WHITE);
           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(1000,600,150,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");
                        frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
                    }
                });
 
            panel.add(CoreSecond.label);
            panel.add(button);
 
            frame.add(panel);
 
            frame.setContentPane(panel);
 
            MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme_000001());
            try {
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            } catch (Exception e) {
                System.out.println(e);
            }
 
            SwingUtilities.updateComponentTreeUI(frame);
 
            new ProgramIcons_JDialog_000001("!red.png", "!red.png", frame);
            //           frame.toFront();
            //frame.setAlwaysOnTop(true);
 
            frame.setResizable(false);
 
 
 
 
 
           frame.setVisible(true);
 
           frame.toFront();
           //_frame.setLocationRelativeTo(null);
 
           new IconSettings_0001(panel, "settings.png", "Settings",  10, 100, 16, 16, 1);
 
 
 
           new Icon_0001(panel, "!red.png", "Hallo!!!", 10, 10, 16, 16, 1);
/*
           new Icon_0001(panel, "grey.png", "Hallo!!!", 10, 10, 16, 14, 300);
           new Icon_0001(panel, "yellow.png", "Hallo!!!", 10, 10, 16, 16, 600);
           new Icon_0001(panel, "white.png", "Hallo!!!", 10, 10, 16, 16, 900);
           new Icon_0001(panel, "green.png", "Hallo!!!", 10, 10, 16, 16, 1200);
           new Icon_0001(panel, "red.png", "Hallo!!!", 10, 10, 16, 16, 1500);
           new Icon_0001(panel, "blue.png", "Hallo!!!", 10, 10, 16, 14, 1800);
*/
            String str1 = "######                                             Lorem ipsum dolor sit amet,\n " +
                    "consetetur sadipscing elitr, sed diam nonumy \n" +
                    "eirmod tempor invidunt ut labore et \n" +
                    "dolore magna aliquyam erat, sed diam voluptua. \n" +
                    "At vero eos et accusam et justo duo dolores et \n" +
                    "ea rebum.\n";
/*
            for(int i = 0; i < 1; i++) {
                try {
                    // System.out.println(new Date( ));
                    Thread.sleep(100);
                        CoreSecond.textfeld.append(str1 + ", Peter. " + str1 + str1);
                    // System.out.println(new Date( ));
                } catch (Exception e) {
                    System.out.println(e);
                }
            }
*/
 
           String str2 = "++++++++++++++ \n######                                             Lorem ipsum dolor sit amet, " +
                   "consetetur sadipscing elitr,ioo&#252;oop  sed diam nonumy";
 
           String str3 = "++++++++++++++ \n######                                             Lorem ipsum dolor sit amet, " +
                   "consetetur sadipscing elitr,ioo&#252;oop  sed diam nonumy";
 
 
 
           str3 = str3.replaceAll("\\\\n", System.getProperty("line.separator"));
           str1 = str1.replaceAll("\\\\n", System.getProperty("line.separator"));
 
           new OutEr_0001("E000001", str1, "Main.class");
           new OutEr_0001("E000002", str2, "Main2.class");
           new OutEr_0001("E000003", str3+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1+str1, "Main3.class");
 
/*
           for(int i = 0; i <= 1; i++) {
               try {
                   new Aeeays_0001("", "", "", "row", 0);
                   new setTextJTextarea_00001(CoreSecond.textfeld, CoreSecond.Er_0002.get(0)[2], CoreSecond.Er_0002.get(0)[0], CoreSecond.Er_0002.get(0)[1], 10);
               } catch (Exception e) {
                   System.out.println(e);
               }
           }
 
 
           for(int i = 0; i <= 1; i++) {
               try {
                   new Aeeays_0001("", "", "", "row", 1);
                   new setTextJTextarea_00001(CoreSecond.textfeld, CoreSecond.Er_0002.get(0)[2], CoreSecond.Er_0002.get(0)[0], CoreSecond.Er_0002.get(0)[1], 1500);
               } catch (Exception e) {
                   System.out.println(e);
               }
           }
*/
 
 
 
           //CoreSecond.textfeld.setCaretPosition(CoreSecond.textfeld.getDocument().getLength());
 
          // new OutEr_0001("\ne");
/*
            while (true) {
                try {
                   // System.out.println(new Date( ));
                    Thread.sleep(5*60*100);
                    CoreSecond.textfeld.append(", Peter");
                   // System.out.println(new Date( ));
                } catch (Exception e) {
                    System.out.println(e);
                }
            }
*/
           CoreSecond.Errors_Dialog_000001 = frame;
 
 
 
 
 
 
 
 
 
/*
           CoreSecond.textfeld.addCaretListener(new CaretListener() {
               public void caretUpdate(CaretEvent e) {
                   for(int i = 0; i < 1; i++) {
                       try {
                           // System.out.println(new Date( ));
                           Thread.sleep(0);
                                // dot is the caret position
                           System.out.println("Careted");
//                               CoreSecond.textfeld.getCaret().setSelectionVisible(true);
//                               CoreSecond.textfeld.setCaretPosition(CoreSecond.textfeld.getText().length());
                       } catch (Exception oe) {
                           System.out.println(oe);
                       }
                   }
               }
           });
*/
 
 
 
 
 
           for(int i = 0; i <= 1; i++) {
               try {
                   new Aeeays_0001("", "", "", "row", 2);
                   new setTextJTextarea_00001(CoreSecond.textfeld, CoreSecond.Er_0002.get(0)[2], CoreSecond.Er_0002.get(0)[0], CoreSecond.Er_0002.get(0)[1], 0);
               } catch (Exception e) {
                   System.out.println(e);
               }
           }
 
/*
           CoreSecond.textfeld.addFocusListener(new FocusAdapter() {
               @Override
               public void focusGained(FocusEvent e) {
//                   CoreSecond.textfeld.getCaret().setVisible(true); // show the caret anyway
 
System.out.println("oo");
 
              }
           });
*/
 
       }
}
 
 
 
class setTextJTextarea_00001 {
    public setTextJTextarea_00001(JTextArea textArea, String text, String ErID,String ErClass , int delay) {
        for(int i = 0; i < 1; i++) {
            try {
                Thread.sleep(delay);
                //CoreSecond.label.setText("");
                CoreSecond.label.setText("Error Nr.: " + ErID + "   in the Class:: " + ErClass);
                //textArea.setText("");
                // Count lines without blank lines
                int numberLines = text // Text obtained from the getText method of the JTextArea
                        .lines() // Get the text line by line
                        //.filter(line -> !line.isBlank()) // Filter all lines removing empty lines
                        .collect(Collectors.toList()) // Convert the flattened content to a list
                        .size(); // We get the final size being the total number of lines
                System.out.println(numberLines);
                try {
                    textArea.getDocument().insertString(0, text, null);
                } catch (BadLocationException e) {
                    System.out.println(e);
                }
                //textArea.append(text);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }
}
 
 
class Aeeays_0001 {
    public Aeeays_0001(String ErID, String ModuleName, String Excep, String func, int rownr) {
        if(func == "add") {
            CoreSecond._rowList.add(new String[]{ErID, ModuleName, Excep});
        }
        if(func == "row") {
            try {
                if (CoreSecond.Er_0003) {
                    CoreSecond.Er_0002.add(new String[]{CoreSecond._rowList.get(rownr)[0], CoreSecond._rowList.get(rownr)[1], CoreSecond._rowList.get(rownr)[2]});
                    CoreSecond.Er_0003 = false;
                } else {
                    CoreSecond.Er_0002.remove(0);
                    CoreSecond.Er_0002.add(new String[]{CoreSecond._rowList.get(rownr)[0], CoreSecond._rowList.get(rownr)[1], CoreSecond._rowList.get(rownr)[2]});
                }
            } catch (Exception e) {
                try {
                    if (CoreSecond.Er_0004) {
                        CoreSecond.Er_0002.add(new String[]{"end", "end", "end"});
                        CoreSecond.Er_0004 = false;
                    } else {
                        CoreSecond.Er_0002.remove(0);
                        CoreSecond.Er_0002.add(new String[]{"end", "end", "end"});
                    }
                } catch (Exception ee) {
                    System.out.println(ee);
                }
            }
        }
    }
}
 
 
 
class OutEr_0001 {
    public OutEr_0001(String ErID, String ErMSG, String ErClass) {
        new Aeeays_0001(ErID, ErClass, ErMSG, "add", 0);
    }
}
 
 
 
class Icon_0001 {
    public Icon_0001(JPanel panel, String image, String TooltipText, int x, int y, int w, int h, int delay) {
        if (CoreSecond.Testing_in_IDE) {
            //  Only for Trstinh iun the IDE
            for (int i = 0; i < 1; i++) {
                try {
                    Thread.sleep(delay);
                    // add Status Bar and Task Icon
                    try {
                        if (CoreSecond.picLabel != null) {
                            panel.remove(CoreSecond.picLabel);
                        }
                            Image myPicture = Toolkit.getDefaultToolkit().getImage("./src/main/resources/icons/" + image);
                            Image img = myPicture.getScaledInstance(w, h, Image.SCALE_DEFAULT);
                            CoreSecond.picLabel = null;
                            CoreSecond.picLabel = new JLabel(new ImageIcon(img));
                            CoreSecond.picLabel.setBounds(x, y, w, h);
                            panel.add(CoreSecond.picLabel);
                            panel.repaint();
                            new ToolTip_000001(TooltipText, CoreSecond.picLabel);
                            new OnMouseClicked_000001(CoreSecond.picLabel, image);
//                            new OnMouseClicked_000002(CoreSecond.picLabel, image);
//                            new OnMouseOver_000002(CoreSecond.picLabel, image);
                    } catch (Exception eee) {
                        System.out.println(eee);
                    }
                } catch (Exception eeeee) {
                    System.out.println(eeeee);
                }
            }
            //  Only for Trstinh iun the IDE   END
        } else {
            for (int i = 0; i < 1; i++) {
                try {
                    Thread.sleep(delay);
                    // add Status Bar and Task Icon
                    try {
                        if (CoreSecond.picLabel != null) {
                            panel.remove(CoreSecond.picLabel);
                        }
                            URL imgURL = CoreSecond.class.getResource(image);
                            Toolkit tk = Toolkit.getDefaultToolkit();
                            Image icon = tk.getImage(imgURL);
                            Image img = icon.getScaledInstance(w, h, Image.SCALE_DEFAULT);
                            CoreSecond.picLabel = null;
                            CoreSecond.picLabel = new JLabel(new ImageIcon(img));
                            CoreSecond.picLabel.setBounds(x, y, w, h);
                            panel.add(CoreSecond.picLabel);
                            panel.repaint();
                            new ToolTip_000001(TooltipText, CoreSecond.picLabel);
                            new OnMouseClicked_000001(CoreSecond.picLabel, image);
  //                          new OnMouseClicked_000002(CoreSecond.picLabel, image);
  //                          new OnMouseOver_000002(CoreSecond.picLabel, image);
                    } catch (Exception eee) {
                        System.out.println(eee);
                    }
                } catch (Exception eeeee) {
                    System.out.println(eeeee);
                }
            }
        }
    }
}
 
 
 
 
 
class IconSettings_0001 {
    public IconSettings_0001(JPanel panel, String image, String TooltipText, int x, int y, int w, int h, int delay) {
        if (CoreSecond.Testing_in_IDE) {
            //  Only for Trstinh iun the IDE
            for (int i = 0; i < 1; i++) {
                try {
                    Thread.sleep(delay);
                    // add Status Bar and Task Icon
                    try {
                        if (CoreSecond.picLabel_Settings != null) {
                            panel.remove(CoreSecond.picLabel_Settings);
                        }
                        Image myPicture = Toolkit.getDefaultToolkit().getImage("./src/main/resources/icons/" + image);
                        Image img = myPicture.getScaledInstance(w, h, Image.SCALE_DEFAULT);
                        CoreSecond.picLabel_Settings = null;
                        CoreSecond.picLabel_Settings = new JLabel(new ImageIcon(img));
                        CoreSecond.picLabel_Settings.setBounds(x, y, w, h);
                        panel.add(CoreSecond.picLabel_Settings);
                        panel.repaint();
                        new ToolTip_000001(TooltipText, CoreSecond.picLabel_Settings);
                        new OnMouseClicked_000001(CoreSecond.picLabel_Settings, image);
                        //new OnMouseClicked_000002_ToolTip(CoreSecond.picLabel_Settings, image);
                        //new OnMouseOver_000002_ToolTip(CoreSecond.picLabel_Settings, image);
                    } catch (Exception eee) {
                        System.out.println(eee);
                    }
                } catch (Exception eeeee) {
                    System.out.println(eeeee);
                }
            }
            //  Only for Trstinh iun the IDE   END
        } else {
            for (int i = 0; i < 1; i++) {
                try {
                    Thread.sleep(delay);
                    // add Status Bar and Task Icon
                    try {
                        if (CoreSecond.picLabel_Settings != null) {
                            panel.remove(CoreSecond.picLabel_Settings);
                        }
                        URL imgURL = CoreSecond.class.getResource(image);
                        Toolkit tk = Toolkit.getDefaultToolkit();
                        Image icon = tk.getImage(imgURL);
                        Image img = icon.getScaledInstance(w, h, Image.SCALE_DEFAULT);
                        CoreSecond.picLabel_Settings = null;
                        CoreSecond.picLabel_Settings = new JLabel(new ImageIcon(img));
                        CoreSecond.picLabel_Settings.setBounds(x, y, w, h);
                        panel.add(CoreSecond.picLabel_Settings);
                        panel.repaint();
                        new ToolTip_000001(TooltipText, CoreSecond.picLabel_Settings);
                        new ToolTip_000001("Settings", CoreSecond.picLabel_Settings);
                        //new OnMouseClicked_000002_ToolTip(CoreSecond.picLabel_Settings, image);
                        //new OnMouseOver_000002_ToolTip(CoreSecond.picLabel_Settings, image);
                    } catch (Exception eee) {
                        System.out.println(eee);
                    }
                } catch (Exception eeeee) {
                    System.out.println(eeeee);
                }
            }
        }
    }
}
 
 
 
 
class ProgramIcons_JDialog_000001 {
    public ProgramIcons_JDialog_000001(String img16x16, String img32x32, JDialog f) {
        //        CoreSecond.Testing_in_IDE = false;
        if (CoreSecond.Testing_in_IDE) {
            //  Only for Trstinh iun the IDE
            // add Status Bar and Task Icon
            try {
                Image icon16 = Toolkit.getDefaultToolkit().getImage("./src/main/resources/icons/" + img16x16);
                Image icon32 = Toolkit.getDefaultToolkit().getImage("./src/main/resources/icons/" + img32x32);
                //f.setIconImage(icon);
                List<Image> icons = new ArrayList<Image>();
                icons.add(icon16);
                icons.add(icon32);
                f.setIconImages(icons);
            } catch (Exception e) {
                System.out.println(e);
            }
        } else {
            try {
                URL imgURL16 = CoreSecond.class.getResource(img16x16);
                Toolkit tk16 = Toolkit.getDefaultToolkit();
                Image icon16 = tk16.getImage(imgURL16);
                //f.setIconImage(icon);
                URL imgURL32 = CoreSecond.class.getResource(img32x32);
                Toolkit tk32 = Toolkit.getDefaultToolkit();
                Image icon32 = tk32.getImage(imgURL32);
                List<Image> icons = new ArrayList<Image>();
                icons.add(icon16);
                icons.add(icon32);
                f.setIconImages(icons);
/*
                List<Image> icons = new ArrayList<Image>();
                icons.add(icon);
                icons.add(icon);
                f.setIconImages(icons);
 
                List<Image> icons = new ArrayList<Image>();
                icons.add(getImage("someImage16x16.gif"));
                icons.add(getImage("someImage32x32.gif"));
                window.setIconImages(icons);
*/
 
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }
}
 
 
 
 
 
class ProgramIcons_000001 {
    public ProgramIcons_000001(String img16x16, String img32x32, JFrame f) {
//        CoreSecond.Testing_in_IDE = false;
        if (CoreSecond.Testing_in_IDE) {
            //  Only for Trstinh iun the IDE
            // add Status Bar and Task Icon
            try {
                Image icon16 = Toolkit.getDefaultToolkit().getImage("./src/main/resources/icons/" + img16x16);
                Image icon32 = Toolkit.getDefaultToolkit().getImage("./src/main/resources/icons/" + img32x32);
                //f.setIconImage(icon);
                List<Image> icons = new ArrayList<Image>();
                icons.add(icon16);
                icons.add(icon32);
 
                // https://wiki.byte-welt.net/wiki/For_each-Schleife_(Java)
 
              //  icons.get().setBackground( new Color(255, 0, 0, 20) );
 
                f.setIconImages(icons);
            } catch (Exception e) {
                System.out.println(e);
            }
        } else {
            try {
                URL imgURL16 = CoreSecond.class.getResource(img16x16);
                Toolkit tk16 = Toolkit.getDefaultToolkit();
                Image icon16 = tk16.getImage(imgURL16);
                //f.setIconImage(icon);
                URL imgURL32 = CoreSecond.class.getResource(img32x32);
                Toolkit tk32 = Toolkit.getDefaultToolkit();
                Image icon32 = tk32.getImage(imgURL32);
                List<Image> icons = new ArrayList<Image>();
                icons.add(icon16);
                icons.add(icon32);
                f.setIconImages(icons);
/*
                List<Image> icons = new ArrayList<Image>();
                icons.add(icon);
                icons.add(icon);
                f.setIconImages(icons);
 
                List<Image> icons = new ArrayList<Image>();
                icons.add(getImage("someImage16x16.gif"));
                icons.add(getImage("someImage32x32.gif"));
                window.setIconImages(icons);
*/
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }
}
 
 
 
class  OnMouseClicked_000001 {
    public OnMouseClicked_000001(JLabel label, String function) {
        label.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                // you can open a new frame here as
                // i have assumed you have declared "frame" as instance variable
                //  frame = new JFrame("new frame");
                //  frame.setVisible(true);
                System.out.println(function);
                new ToolTip_000001_Close();
            }
        });
    }
}
 
 
 
 
 
class  OnMouseOver_000001_ToolTip {
    public OnMouseOver_000001_ToolTip(JLabel label) {
        label.addMouseListener(new MouseAdapter() {
            public void mouseEntered(MouseEvent e) {
                // you can open a new frame here as
                // i have assumed you have declared "frame" as instance variable
                //  frame = new JFrame("new frame");
                //  frame.setVisible(true);
//                System.out.println(function);
               // new ToolTip_000001_Helper();
            }
        });
 
 
 
        label.addMouseListener(new MouseAdapter() {
            public void mouseExited(MouseEvent e) {
                // you can open a new frame here as
                // i have assumed you have declared "frame" as instance variable
                //  frame = new JFrame("new frame");
                //  frame.setVisible(true);
//                System.out.println(function);
                new ToolTip_000001_Close();
            }
        });
    }
}
 
 
 
class ToolTip_000001 {
    public ToolTip_000001(String ToolTipText, JLabel label) {
        if (CoreSecond.ToolTip_000001 != null) {
            CoreSecond.ToolTip_000001.setVisible(false);
            CoreSecond.ToolTip_000001.dispose();
        }
 
        if (CoreSecond.picLabel_ToolTip != null) {
            CoreSecond.picLabel_ToolTip = CoreSecond.picLabel_ToolTip;
        }
 
 
        label.addMouseListener(new MouseAdapter() {
 
            @Override
            public void mouseEntered(MouseEvent e) {
                new ToolTip_000001_Helper(ToolTipText);
                //System.out.println("inside");
            }
 
            @Override
            public void mouseExited(MouseEvent e) {
                Component c = SwingUtilities.getDeepestComponentAt(
                        e.getComponent(), e.getX(), e.getY());
                // doesn't work if you move your mouse into the combobox popup
                new ToolTip_000001_Close();
                //System.out.println("outside");
            }
        });
    }
 
 
       // new OnMouseClicked_000001_ToolTip(CoreSecond.picLabel_ToolTip);
       // new OnMouseOver_000001_ToolTip(CoreSecond.picLabel_ToolTip);
 
        //new ToolTip_000001_Helper();
}
 
 
 
 
class ToolTip_000001_Helper {
    public ToolTip_000001_Helper(String ToolTipText) {
 
 
        CoreSecond.ToolTip_000001 = new JFrame("");
 
        CoreSecond.ToolTip_000001.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Already there
        //frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
        CoreSecond.ToolTip_000001.setUndecorated(true); // <-- the title bar is removed here
        CoreSecond.ToolTip_000001.getContentPane().setBackground(new Color(1f,0f,0f,.5f ));
        CoreSecond.ToolTip_000001.setBackground(new Color(1f,0f,0f,.5f ));
        CoreSecond.ToolTip_000001.getRootPane().setBackground(new Color(1f,0f,0f,.5f ));
 
        CoreSecond.ToolTip_000001.setAlwaysOnTop(true);
 
                // Text width and height measuring
        Font f = new Font("Ariel", Font.PLAIN, 16);
        Rectangle2D r = f.getStringBounds(ToolTipText, new FontRenderContext(null, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT, RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT));
       // System.out.println("(" + Math.round(r.getWidth()) + ", " + Math.round(r.getHeight()) + ")");
       // System.out.println(ToolTipText);
 
        // 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 = (int)Math.round(r.getWidth());
        int _h = (int)Math.round(r.getHeight());
        int _x = MouseInfo.getPointerInfo().getLocation().x;
        int _y = MouseInfo.getPointerInfo().getLocation().y;
 
        if ((_w+_x+32) >= width) {
            _x = _x - _w - 32;
        }
        if ((_h+_y+32) >= height) {
            _y = _y - _h - 16 -20;
        }
 
        CoreSecond.ToolTip_000001.setLocation((int)Math.round(_x), (int)Math.round(_y+20));
 
 
        //CoreSecond.ToolTip_000001.setLocation(0, 0);
        //        frame.setLocation(0, 20);
        CoreSecond.ToolTip_000001.setSize(_w+32, _h+16);
 
        Timer timer = new Timer(10000, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CoreSecond.ToolTip_000001.setVisible(false);
                CoreSecond.ToolTip_000001.dispose();
            }
        });
        timer.setRepeats(false);
        timer.start();
 
        JPanel panel = new RoundedPanel(4, Color.decode("#5a1f78"));
        JLabel myLabel= new JLabel("");
        myLabel.setBounds(0, 0, _w, _h);
        myLabel.setText(ToolTipText);
        myLabel.setBackground(new Color(1f,0f,0f,.5f ));
        myLabel.setForeground(Color.WHITE);
        myLabel.setFont(new Font("Ariel", Font.PLAIN, 16));
        panel.add(myLabel);
        //  panel.setBounds(10,10,100,60);
        panel.setOpaque(false);
        CoreSecond.ToolTip_000001.add(panel);
 
        CoreSecond.ToolTip_000001.setVisible(true);
    }
}
 
 
 
 
 
class RoundedPanel extends JPanel {
    private Color backgroundColor;
    private int cornerRadius = 15;
 
    public RoundedPanel(LayoutManager layout, int radius) {
        super(layout);
        cornerRadius = radius;
    }
 
    public RoundedPanel(LayoutManager layout, int radius, Color bgColor) {
        super(layout);
        cornerRadius = radius;
        backgroundColor = bgColor;
    }
 
public RoundedPanel(int radius) {
        super();
        cornerRadius = radius;
    }
 
    public RoundedPanel(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
    }
}
 
 
 
class ToolTip_000001_Close {
    public ToolTip_000001_Close() {
        if (CoreSecond.ToolTip_000001 != null) {
            CoreSecond.ToolTip_000001.setVisible(false);
            CoreSecond.ToolTip_000001.dispose();
        }
    }
}
 
 
 
class MyDefaultMetalTheme_000001 extends DefaultMetalTheme {
        public ColorUIResource getWindowTitleInactiveBackground() {
            return new ColorUIResource(Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getWindowTitleBackground() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getPrimaryControlHighlight() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getPrimaryControlDarkShadow() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getPrimaryControl() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getControlHighlight() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getControlDarkShadow() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
 
        public ColorUIResource getControl() {
            return new ColorUIResource(java.awt.Color.decode("#"+ CoreSecond.MyDefaultMetalTheme_000001_WindowColor));
        }
    }
 

Всего записей: 2192 | Зарегистр. 25-02-2013 | Отправлено: 22:29 24-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