To place a picture in the graphical interface, you need to use the window splitter JSplitPane (belonging to the container class component) to the interface above the imageicon . Split the window into two columns. A column is JList, inside entered some text, a column is jlable, above place the picture. The layout uses the Borderlayout package gui;import java.awt.borderlayout;import javax.swing.jframe;import Javax.swing.jlabel;import Javax.swing.jsplitpane;import javax.swing.jlist;import javax.swing.ImageIcon;/*** Swing Combat Window Split * Created by admin on 2017/7/10.*/public class JSplitPane extends Jframe{private jsplitpane jsplitpane;private Jlabe L jlabel;private JList jlist;public static void Main (string[] args) {JSplitPane JSplitPane = new JSplitPane ();} public JSplitPane () {String [] words = {"Java", "Python", "golang"};jlabel = new JLabel (New ImageIcon ("D:\\image\\qq Image 20150507223217.jpg ")); jList = new JList (words);//JSplitPane splitter pane, vertical split JSplitPane = new JSplitPane ( Jsplitpane.horizontal_split, JList, JLabel); This.add (JSplitPane);//Set JFrame properties This.settitle ("project"); This.setlocation (This.setsize), this.setresizable (false); This.setdefaultcloseoperation ( Jframe.exit_on_close); this.setvisible (True);}}
Placing pictures in the six swing of Java GUI programming (swing)