zoukankan      html  css  js  c++  java
  • java入门

    Java界面制作的组件添加组合,向容器中添加组件,对象式的编程方式??

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class JLJB {
    	public static void main (String[] args) {
    		JFrame frame = new JFrame("JLabelJButton 使用");
    		Container contentPane = frame.getContentPane();
    		Icon icon1 = new ImageIcon("E:\TGP\Data\cf_skin\100.png");
    		JPanel panel = new JPanel();
    		JLabel label = new JLabel("Hello world!",icon1,JLabel.RIGHT);
    		JButton button = new JButton("click",icon1);
    		label.setHorizontalTextPosition(JLabel.CENTER);
    		label.setBackground(Color.red);
    		label.setForeground(Color.green);
    		button.setHorizontalTextPosition(JButton.RIGHT);
    		button.setBackground(Color.yellow);
    		button.setForeground(Color.blue);
    		contentPane.add(panel);
    		panel.add(label);
    		panel.add(button);
    		frame.pack();
    		frame.setVisible(true);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.addWindowListener(new WindowAdapter() {
    			public void windowClosing(WindowEvent e) {System.exit(0);}
    		});
    	}
    }
    
  • 相关阅读:
    CF1070F Debate
    P3502 [POI2010]CHO-Hamsters
    CF1421A XORwice
    P2073 送花
    树链剖分边权转化为点权
    球——数学分析,模型构建
    数位dp的模版
    不要62
    智慧题——规律题
    CF551C GukiZ hates Boxes——模拟加二分
  • 原文地址:https://www.cnblogs.com/gride-glory/p/7499489.html
Copyright © 2011-2022 走看看