⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ptool.java

📁 该系统是B/S结构的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                Panel panel1 = new Panel(new FlowLayout(1, 1, 1));
                Button button = new Button(s2);
                panel1.add(button);
                add(panel1, 3);
                choice.addItemListener(this);
                bo_san.addActionListener(this);
                button.addActionListener(this);
                edit.addActionListener(this);
            }
            }

            SDL sdl = new SDL(s, s1, s2, s3, s4, s5, flag);
            getDefComponents(sdl);
            sdl.pack();
            moveCenter(sdl);
            sdl.addNotify();
            sdl.show();
            return sdl.res;
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
        return "";
    }

    public static boolean isJapanese()
    {
        if(ja == null)
            ja = new Boolean(Locale.getDefault().getLanguage().equalsIgnoreCase("ja"));
        return ja.booleanValue();
    }

    public static boolean isWindows()
    {
        try
        {
            String s = System.getProperty("os.name");
            return Character.toLowerCase(s.charAt(0)) == 'w';
        }
        catch(RuntimeException _ex)
        {
            return false;
        }
    }

    public static String[] listLoad(File file, String s)
    {
        String as[] = null;
        try
        {
            if(!file.isFile())
                return null;
            Vector vector = new Vector();
            BufferedReader bufferedreader = new BufferedReader(new FileReader(file));
            String s1;
            while((s1 = bufferedreader.readLine()) != null) 
                if(s1.equals(s))
                    break;
            while((s1 = bufferedreader.readLine()) != null) 
            {
                if(s1.equals(""))
                    break;
                vector.addElement(s1);
            }
            bufferedreader.close();
            if(vector.size() > 0)
            {
                as = new String[vector.size()];
                vector.copyInto(as);
            }
        }
        catch(Exception _ex) { }
        return as;
    }

    public static void listSave(File file, String s, String as[], String s1)
    {
        try
        {
            if(s == null || s.length() <= 0 || s1 == null || s1.length() <= 0)
                return;
            StringWriter stringwriter = new StringWriter();
            PrintWriter printwriter = new PrintWriter(stringwriter);
            printwriter.println(s);
            if(s1 != null)
                printwriter.println(s1);
            if(as != null)
            {
                for(int i = 0; i < as.length; i++)
                    if(as[i].equals(s1))
                        as[i] = null;

                int j = Math.min(as.length, 256);
                for(int k = 0; k < j; k++)
                    if(as[k] != null)
                        printwriter.println(as[k]);

            }
            printwriter.println();
            if(file.canRead())
            {
                BufferedReader bufferedreader = new BufferedReader(new FileReader(file));
                String s2;
                while((s2 = bufferedreader.readLine()) != null) 
                {
                    if(s2.equals(s))
                        break;
                    printwriter.println(s2);
                }
                while((s2 = bufferedreader.readLine()) != null) 
                    if(s2.equals(""))
                        break;
                if(s2 != null)
                    while((s2 = bufferedreader.readLine()) != null) 
                        printwriter.println(s2);
                bufferedreader.close();
            }
            printwriter.flush();
            printwriter.close();
            stringwriter.flush();
            stringwriter.close();
            printwriter = new PrintWriter(new FileWriter(file));
            printwriter.write(stringwriter.getBuffer().toString());
            printwriter.flush();
            printwriter.close();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    public static Image loadImageNow(Component component, String s)
    {
        Image image = null;
        try
        {
            image = component.getToolkit().getImage(s);
            MediaTracker mediatracker = new MediaTracker(component);
            mediatracker.addImage(image, 0);
            mediatracker.waitForID(0, 10000L);
            mediatracker.removeImage(image);
            mediatracker = null;
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        return image;
    }

    public static void messageBox(String s, String s1)
    {
        messageBox(s, s1, false);
    }

    private static boolean messageBox(String s, String s1, boolean flag)
    {
        boolean flag1 = false;
        try
        {
            if(s1 == null)
                s1 = "";
            if(me_d == null)
                me_d = new Me_d(getPFrame());
            me_d.setOkCancel(flag);
            me_d.setMessage(s);
            me_d.setTitle(s1);
            me_d.pack();
            moveCenter(me_d);
            me_d.addNotify();
            me_d.show();
            flag1 = me_d.bool;
        }
        catch(Throwable throwable)
        {
            System.out.println("message" + throwable);
        }
        return flag1;
    }

    public static boolean messageBoxEx(String s, String s1)
    {
        return messageBox(s, s1, true);
    }

    public static void moveCenter(Window window)
    {
        Dimension dimension = window.getToolkit().getScreenSize();
        Dimension dimension1 = window.getSize();
        window.setLocation(dimension.width / 2 - dimension1.width / 2, dimension.height / 2 - dimension1.height / 2);
    }

    public static void pack(Container container)
    {
        Component acomponent[] = container.getComponents();
        if(acomponent != null)
        {
            for(int i = 0; i < acomponent.length; i++)
                if(acomponent[i] instanceof Container)
                    pack((Container)acomponent[i]);
                else
                if(!acomponent[i].isValid())
                    acomponent[i].validate();

        }
        if(!container.isValid())
            container.validate();
    }

    public static String replaceText(String s, char c, char c1)
    {
        StringBuffer stringbuffer = new StringBuffer(s);
        int i = stringbuffer.length();
        for(int j = 0; j < i; j++)
            if(stringbuffer.charAt(j) == c1)
                stringbuffer.setCharAt(j, c);

        return stringbuffer.toString();
    }

    public static String replaceText(String s, String s1, String s2)
    {
        StringBuffer stringbuffer = new StringBuffer();
        try
        {
            char ac[] = s2.toCharArray();
            if(ac.length <= 0)
                return s;
            int i = 0;
            int j = 0;
            int k = s.length();
            for(int l = 0; l < k; l++)
            {
                char c;
                if((c = s.charAt(l)) == ac[j])
                {
                    if(j == 0)
                        i = l;
                    if(++j >= ac.length)
                    {
                        j = 0;
                        stringbuffer.append(s1);
                    }
                } else
                {
                    if(j > 0)
                    {
                        for(int i1 = 0; i1 < j; i1++)
                            stringbuffer.append(s.charAt(i + i1));

                        j = 0;
                    }
                    stringbuffer.append(c);
                }
            }

        }
        catch(RuntimeException runtimeexception)
        {
            System.out.println("replace" + runtimeexception);
        }
        return stringbuffer.toString();
    }

    public static boolean showDocument(String s, PProperties pproperties)
    {
        Runtime runtime = Runtime.getRuntime();
        try
        {
            File file;
            if(s.startsWith("http://"))
            {
                file = new File(getCurrent(), "cnf/dummy.html");
                FileOutputStream fileoutputstream = new FileOutputStream(file);
                fileoutputstream.write(("<html><head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=" + s + "\"></head></html>").getBytes());
                fileoutputstream.flush();
                fileoutputstream.close();
            } else
            {
                file = new File(s);
            }
            String s1 = file.getCanonicalPath();
            String s2 = "browser";
            if(isWindows())
                try
                {
                    runtime.exec(new String[] {
                        pproperties.getString(s2, "explorer"), s1
                    });
                    return true;
                }
                catch(IOException _ex) { }
            String s3 = (String)pproperties.get(s2);
            if(s3 == null)
                if(messageBoxEx(isJapanese() ? "ロビーページを開く為にブラウザを指定する必要があります。\nこのシステムを必要としますか?\ncancelで今後このシステムが今後施行される事はなくなります。" : "you need jump to web page sysytem?", "確認"))
                    s3 = fileDialog(getPFrame(), "", false).getCanonicalPath();
                else
                    pproperties.put(s2, "f");
            if(s3 == null || s3.length() <= 0 || s3.charAt(0) == 'f')
                return false;
            runtime.exec(new String[] {
                s3, s1
            });
        }
        catch(Throwable throwable)
        {
            System.out.println(throwable);
        }
        return false;
    }

    public static String trimString(String s, String s1, String s2)
    {
        if(s == null || s.length() <= 0 || s1 == null || s2 == null)
            return "";
        try
        {
            int i;
            if((i = s.indexOf(s1)) == -1)
                return "";
            int j;
            if((j = s.indexOf(s2, i + s1.length())) == -1)
                j = s.length() - 1;
            return s.substring(i + s1.length(), j);
        }
        catch(RuntimeException runtimeexception)
        {
            System.out.println("t_trimString:" + runtimeexception.toString());
        }
        return "";
    }

    public PTool()
    {
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -