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

📄 windowlistenapp1.java

📁 This is an application based program which creates a text pad in which you can write anythng & that
💻 JAVA
字号:
import javax.swing.JTextPane;import javax.swing.JFrame;import javax.swing.text.StyledDocument;import javax.swing.text.StyleConstants;import javax.swing.text.MutableAttributeSet;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import java.awt.event.WindowAdapter;import java.awt.Color;import java.awt.Font;import java.awt.BorderLayout;/*<APPLETCODE=windowlistenapp1.classWIDTH=500HEIGHT=200 ></APPLET>*/public class windowlistenapp1 extends WindowAdapter {    public windowlistenapp1() {        JFrame frm = new JFrame("Second JTextPane Example");        frm.getContentPane().setLayout(new BorderLayout());        JTextPane jtextpane = new JTextPane();        Font fnt = new Font("Serif", Font.ITALIC, 20);        setJTextPaneFont(jtextpane, fnt, Color.blue);        frm.getContentPane().add(jtextpane, BorderLayout.CENTER);        frm.addWindowListener(this);        frm.setSize(400, 400);        frm.show();    }    public static void setJTextPaneFont(JTextPane jtp, Font font, Color c) {        MutableAttributeSet attrs = jtp.getInputAttributes();        StyleConstants.setFontFamily(attrs, font.getFamily());        StyleConstants.setFontSize(attrs, font.getSize());        StyleConstants.setItalic(attrs, (font.getStyle() & Font.ITALIC) != 0);        StyleConstants.setBold(attrs, (font.getStyle() & Font.BOLD) != 0);               StyleConstants.setForeground(attrs, c);        StyledDocument doc = jtp.getStyledDocument();        doc.setCharacterAttributes(0, doc.getLength() + 1, attrs, false);    }    public void windowClosing(WindowEvent evt) {        System.exit(0);    }    public static void main(String[] args) {        windowlistenapp1 instance = new windowlistenapp1();    }}

⌨️ 快捷键说明

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