JscrollPane如何使用
importjavax.swing.JLabel;importjavax.swing.JScrollPane;importjavax.swing.JFrame;impor...
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import java.awt.Container;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.BorderLayout;
public class lll
{
public static void main(String[]args)
{
JFrame myFrame=new JFrame();
Container con= myFrame.getContentPane();
JPanel myPanel=new JPanel();
JLabel label1=new JLabel("东1");
JLabel label2=new JLabel("南2");
JLabel label3=new JLabel("西3");
JLabel label4=new JLabel("北4");
myPanel.setLayout(new BorderLayout());
myPanel.add(label1,BorderLayout.EAST);
myPanel.add(label2,BorderLayout.SOUTH);
myPanel.add(label3,BorderLayout.WEST);
myPanel.add(label4,BorderLayout.NORTH);
JScrollPane myScrollPane=new JScrollPane();
myScrollPane.setPreferredSize(new Dimension(500,500));
myScrollPane.add(myPanel);
myPanel.setSize(400,400);
myFrame.add(myScrollPane);
myFrame.setSize(600,600);
myPanel.setVisible(true);
myScrollPane.setVisible(true);
myFrame.setVisible(true);
}
}
//为什么调用不成功 展开
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import java.awt.Container;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.BorderLayout;
public class lll
{
public static void main(String[]args)
{
JFrame myFrame=new JFrame();
Container con= myFrame.getContentPane();
JPanel myPanel=new JPanel();
JLabel label1=new JLabel("东1");
JLabel label2=new JLabel("南2");
JLabel label3=new JLabel("西3");
JLabel label4=new JLabel("北4");
myPanel.setLayout(new BorderLayout());
myPanel.add(label1,BorderLayout.EAST);
myPanel.add(label2,BorderLayout.SOUTH);
myPanel.add(label3,BorderLayout.WEST);
myPanel.add(label4,BorderLayout.NORTH);
JScrollPane myScrollPane=new JScrollPane();
myScrollPane.setPreferredSize(new Dimension(500,500));
myScrollPane.add(myPanel);
myPanel.setSize(400,400);
myFrame.add(myScrollPane);
myFrame.setSize(600,600);
myPanel.setVisible(true);
myScrollPane.setVisible(true);
myFrame.setVisible(true);
}
}
//为什么调用不成功 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询