6. 下列哪个属于容器的组件? [swing容器及组件] A)JFrame B)JButton C)JPanel D)JDiaglog 给点答案谢谢
3个回答
展开全部
B,其余的三个是容器不是容器组件
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
class Mange extends JFrame //窗口主界面
{
static JButton jbutton1=new JButton("借书");
static JButton jbutton2=new JButton("还书");
static JButton jbutton3=new JButton("查询");
static JButton jbutton4=new JButton("添加图书");
static JButton jbutton5=new JButton("删除图书");
static JButton jbutton6=new JButton("图书管理");
static Box box1=Box.createVerticalBox();
static Box box2=Box.createHorizontalBox();
static JScrollPane jscrollpane;
Mange()
{
Toolkit tk=Toolkit.getDefaultToolkit();
Dimension screenSize=tk.getScreenSize();
setBounds(screenSize.width/4,screenSize.width/4,screenSize.width/2,screenSize.height/2);
//setTitle(s);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
box2.add(jbutton1);
box2.add(jbutton2);
box2.add(jbutton3);
box2.add(jbutton4);
box2.add(jbutton5);
box2.add(jbutton6);
box1.add(box2);
jscrollpane=new JScrollPane(box1);
getContentPane().add(jscrollpane);
setVisible(true);
setResizable(true);
}
}
class Foubook implements ItemListener
{
JLabel jlabel=new JLabel("书 所 属 类 别");
String[] s=;
JPanel jpanel=new JPanel();
JComboBox jcombobox=new JComboBox(s);
Box box1=Box.createHorizontalBox();
Box box2=Box.createHorizontalBox();
public void callFoundbook()
{
jpanel.add(jlabel);
// jpanel.add(Box.createHorizontalStrut(20));
jpanel.add(jcombobox);
box1.add(jpanel);
Mange.box1.add(box1);
Mange.box1.revalidate();
jcombobox.addItemListener(this);
}
public void moveFoundbook()
{
Mange.box1.removeAll();
Mange.box1.add(Mange.box2);
Mange.box1.repaint();
}
public void itemStateChanged(ItemEvent e)
{
moveFoundbook();
callFoundbook();
}
}
public class hello
{
public static void main(String[] args)
{
Mange manage1=new Mange();
Foubook foun=new Foubook();
foun.callFoundbook();
}
}
把你那句创建一个不可见的Box取消就可以了
还有希望程序规范一点~
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
class Mange extends JFrame //窗口主界面
{
static JButton jbutton1=new JButton("借书");
static JButton jbutton2=new JButton("还书");
static JButton jbutton3=new JButton("查询");
static JButton jbutton4=new JButton("添加图书");
static JButton jbutton5=new JButton("删除图书");
static JButton jbutton6=new JButton("图书管理");
static Box box1=Box.createVerticalBox();
static Box box2=Box.createHorizontalBox();
static JScrollPane jscrollpane;
Mange()
{
Toolkit tk=Toolkit.getDefaultToolkit();
Dimension screenSize=tk.getScreenSize();
setBounds(screenSize.width/4,screenSize.width/4,screenSize.width/2,screenSize.height/2);
//setTitle(s);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
box2.add(jbutton1);
box2.add(jbutton2);
box2.add(jbutton3);
box2.add(jbutton4);
box2.add(jbutton5);
box2.add(jbutton6);
box1.add(box2);
jscrollpane=new JScrollPane(box1);
getContentPane().add(jscrollpane);
setVisible(true);
setResizable(true);
}
}
class Foubook implements ItemListener
{
JLabel jlabel=new JLabel("书 所 属 类 别");
String[] s=;
JPanel jpanel=new JPanel();
JComboBox jcombobox=new JComboBox(s);
Box box1=Box.createHorizontalBox();
Box box2=Box.createHorizontalBox();
public void callFoundbook()
{
jpanel.add(jlabel);
// jpanel.add(Box.createHorizontalStrut(20));
jpanel.add(jcombobox);
box1.add(jpanel);
Mange.box1.add(box1);
Mange.box1.revalidate();
jcombobox.addItemListener(this);
}
public void moveFoundbook()
{
Mange.box1.removeAll();
Mange.box1.add(Mange.box2);
Mange.box1.repaint();
}
public void itemStateChanged(ItemEvent e)
{
moveFoundbook();
callFoundbook();
}
}
public class hello
{
public static void main(String[] args)
{
Mange manage1=new Mange();
Foubook foun=new Foubook();
foun.callFoundbook();
}
}
把你那句创建一个不可见的Box取消就可以了
还有希望程序规范一点~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询