第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JTextField 在各種 LAF 實例中是什么樣的?

JTextField 在各種 LAF 實例中是什么樣的?

紫衣仙女 2022-06-30 17:57:35
在各種可插入外觀實現(xiàn)中可編輯、不可編輯和禁用時,Swing 文本字段會是什么樣子?以下是在 Windows 和 Apple OS X 上看到的 PLAF 的答案。我也非常感謝看到其他 PLAF 上的外觀(例如 *nix 上的 GTK)。
查看完整描述

1 回答

?
人到中年有點甜

TA貢獻1895條經(jīng)驗 獲得超7個贊

他們說一張圖片描繪了一千個單詞,所以這里有一個 6K 單詞的答案。

http://img1.sycdn.imooc.com//62bd73ca0001e21306220504.jpg

請注意,在 Nimbus & Motif PLAF 中,不可編輯文本字段的背景看起來與可編輯文本字段相同,而在其他三個中,它看起來不同。


禁用的文本字段與所有 PLAF 中的可編輯或不可編輯字段不同。


代碼

使用此代碼在您的系統(tǒng)/JRE 上進行測試。


import java.awt.GridLayout;

import java.awt.image.BufferedImage;

import javax.swing.*;

import javax.swing.border.*;

import javax.imageio.ImageIO;

import java.io.*;


public class TextFieldPLAF {


    TextFieldPLAF() {

        initUI();

    }


    public final void initUI() {

        UIManager.LookAndFeelInfo[] lafInfos = UIManager.getInstalledLookAndFeels();

        try {

            for (UIManager.LookAndFeelInfo lAFI : lafInfos) {

                saveImageOfLookAndFeel(lAFI);

            }

        } catch (IOException ex) {

            ex.printStackTrace();

        }

    }


    private void saveImageOfLookAndFeel(UIManager.LookAndFeelInfo lafi) throws IOException {

        String classname = lafi.getClassName();

        try {

            UIManager.setLookAndFeel(classname);

        } catch (Exception ex) {

            ex.printStackTrace();

        }

        JComponent ui = new JPanel(new GridLayout(1, 0));

        ui.setBorder(new TitledBorder(classname));

        int cols = 13;

        JTextField tf;

        tf = new JTextField("Editable & Enabled", cols);

        ui.add(tf);

        tf = new JTextField("Not Editable", cols);

        tf.setEditable(false);

        ui.add(tf);

        tf = new JTextField("Not Enabled", cols);

        tf.setEnabled(false);

        ui.add(tf);

        JOptionPane.showMessageDialog(null, ui);

        BufferedImage bi = new BufferedImage(

                ui.getWidth(), ui.getHeight(), BufferedImage.TYPE_INT_RGB);

        ui.paint(bi.getGraphics());

        File dir = new File(System.getProperty("user.home"));

        File f = new File(dir, String.format("PLAF-%1s.png", classname));

        ImageIO.write(bi, "png", f);

    }


    public static void main(String[] args) {

        Runnable r = () -> {

            new TextFieldPLAF();

        };

        SwingUtilities.invokeLater(r);

    }

}


查看完整回答
反對 回復(fù) 2022-06-30
  • 1 回答
  • 0 關(guān)注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號