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

📄 show image.java

📁 Show image on label in its full size
💻 JAVA
字号:
import java.awt.Container;
import java.awt.FlowLayout;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

public class Temp extends JFrame{
	private JLabel label2;
	Temp(){
		super("Test");
		Container cont=getContentPane();
		//new GridLayout(0, 1)
		cont.setLayout(new FlowLayout());
		
		Icon aqua=new ImageIcon("cara1.JPG");
		label2 = new JLabel();
		/** OR
		*label2 = new JLabel(aqua);
		*and remove line 25
		*/
				//label2.setText( "Label with icon and text at bottom" );
		label2.setIcon( aqua );
				//label2.setHorizontalTextPosition( SwingConstants.CENTER );
				//label2.setVerticalTextPosition( SwingConstants.BOTTOM );
				//label2.setToolTipText( "This is label2" );
		cont.add( label2 );
		
		//setSize( 500,511 );
		setSize( 945,511 );
		setVisible(true);
	}
	public static void main(String[] args) {
		Temp m=new Temp();
		m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
	}

}

⌨️ 快捷键说明

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