小编Air*_*ris的帖子

在Swing中显示HTML

我正在开发一个类似的项目来从服务器加载HTML文件并以摆动方式显示它们.

import java.io.*;
import java.net.*;
import java.util.regex.*;
import javax.swing.*;


public class webloader {
    public static void loadcode(){
        URL url = null;
        try {
            url = new URL("web"+File.separator+web.url+File.separator+"index.html");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        URLConnection con = null;
        try {
            con = url.openConnection();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Pattern p = Pattern.compile("text/html;\\s+charset=([^\\s]+)\\s*");
        Matcher m = p.matcher(con.getContentType());
        String charset = m.matches() ? m.group(1) : "ISO-8859-1";
        Reader r = null;
        try {
            r = new InputStreamReader(con.getInputStream(), charset);
        } catch (UnsupportedEncodingException …
Run Code Online (Sandbox Code Playgroud)

html java swing

5
推荐指数
1
解决办法
6452
查看次数

隐形GUI?(Java)(Swing)

我正在研究这个程序,使用swing.每次导出程序并运行它时,我都会尝试设置的GUI.JFrame可以,但不是内部组件.提前谢谢〜艾利斯

码:

import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.*;

public class Login {
    public static void login_Interface(){

        //Start GUI style//
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        } catch (InstantiationException e1) {
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (UnsupportedLookAndFeelException e1) {
            e1.printStackTrace();
        }
        //      End     //

        JFrame login_Frame = new JFrame("Login - LetsMeet");
        login_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        login_Frame.setSize(750, 650);
        login_Frame.setResizable(true);

        JPanel panel_Title = new JPanel();                            //PANEL Title …
Run Code Online (Sandbox Code Playgroud)

java user-interface swing

3
推荐指数
1
解决办法
546
查看次数

标签 统计

java ×2

swing ×2

html ×1

user-interface ×1