首页 > 应用开发 > IT综合 > 在Swing组件中使用HTML
Swing组件支持显示HTML,例如:
import javax.swing.JFrame; import javax.swing.JButton; import java.awt.GridLayout; public class HTMLButtons extends JFrame{ HTMLButtons(){ setSize(400,200); getContentPane().setLayout(new GridLayout(1,4)); getContentPane().add(new JButton( "1st")); getContentPane().add(new JButton( "2nd")); getContentPane().add(new JButton( "3rd")); getContentPane().add(new JButton( "4th")); } public static void main(String[] args) { new HTMLButtons().setVisible(true); } }
1st
2nd
3rd
4th