JAVA程序如何插入图片
图片名字是img1.JPG,你放到本程序的目录下面就好了。import java.awt.*;import java.awt.event.*;import java.awt.image.*;import java.io.*;import javax.imageio.*;import javax.swing.*;public class TestMenu1 extends JFrame{private JTextArea textArea=new JTextArea();private JMenuBar menuBar=new JMenuBar();private JMenu fileMenu=new JMenu("文件");private JMenu viewMenu=new JMenu("视图");private JMenu toolMenu=new JMenu("工具栏");private JMenuItem[] fileItem={new JMenuItem("新建"),new JMenuItem("打开"),new JMenuItem("保存"),new JMenuItem("退出")};private JMenuItem[] viewItem={new JMenuItem("普通"),new JMenuItem("页面")};private JCheckBoxMenuItem[] toolItem={new JCheckBoxMenuItem("常用"),new JCheckBoxMenuItem("绘图"),new JCheckBoxMenuItem("符号栏")};private JPanel jPanel1;private JLabel jLabel;private Imageimage;private ImageIcon imageIcon ;public TestMenu1(String title){super(title);jPanel1=new JPanel();image = Toolkit.getDefaultToolkit().getImage("img1.JPG");jLabel = new JLabel();imageIcon = new ImageIcon(image);jLabel.setIcon(imageIcon);add(jLabel, BorderLayout.NORTH);add(jPanel1, BorderLayout.SOUTH);setVisible(true);setSize(600, 600);ActionListener actListener=new ActionListener(){public void actionPerformed(ActionEvent e){if(((JMenuItem)e.getSource()).getText()=="退出"){System.exit(0);}else{textArea.setText(((JMenuItem)e.getSource()).getText());ItemListener itemListener=new ItemListener(){public void itemStateChanged(ItemEvent e){String str=new String("");for(int i=0;i
一个关于JAVA编程添加图片的问题
\n: 换行符。结束光标当前所在行,光标进入下一行。\t: 制表符。代表四个字符。比如:system.out.print("abc\n") = system.out.println("abc")打印出来时就是两行,第二行是空行: 1. abc 2.system.out.print("abc\t") = system.out.print("abc ")打印出来就是一行,但abc后来还有四个空白字符:1. abc第二个问题:如果你要输出居中没有别的办法只能打空格或加制表符,如: system.out.print("*********"); system.out.print(" abc"); system.out.print("*********");
求编程高手,告诉我怎么在vc++6.0中加载图片,请给出完整的代码,如果给出相关书籍,可加分。
{ typedef int (WINAPI ICEPUB_DISPIMG)(HWND hWnd,char *strImgFilename,int x,int y); ICEPUB_DISPIMG *icePub_dispImg = 0; HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll"); if(hDLLDrv) {icePub_dispImg = (ICEPUB_DISPIMG *)GetProcAddress(hDLLDrv, "icePub_dispImg"); } if(icePub_dispImg !