java题目要求我们按left排布就按从做向右排布,按center排布就按从中间排布,按right就按从右向左排布!
来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/05/17 14:56:58
java题目要求我们按left排布就按从做向右排布,按center排布就按从中间排布,按right就按从右向左排布!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MyFlowLayout extends JFrame implements ActionListener
{
private JButton leftButton;
private JButton centerButton;
private JButton rightButton;
JPanel contentPane=(JPanel) this.getContentPane();
public MyFlowLayout(){
leftButton=new JButton("left");
centerButton=new JButton("center");
rightButton=new JButton("right");
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane.add(leftButton);
contentPane.add(centerButton);
contentPane.add(rightButton);
setSize(500,100);
setVisible(true);
show();
leftButton.addActionListener(this);
centerButton.addActionListener(this);
rightButton.addActionListener(this);
}
public static void main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable(){public void run(){
MyFlowLayout frame=new MyFlowLayout();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
}
public void actionPerformed(ActionEvent e){
String command=e.getActionCommand();
if(command.equals("left")){
contentPane.setLayout(new FlowLayout(FlowLayout.LEFT));
}
if(command.equals("center")){
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));
}
if(command.equals("right")){
contentPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
}
super.repaint();
}
}
这是我写的代码,运行后如果按left只有最大化才能重新排布.再按right和第一次按一样只有最小化才能重新排布,这是为什么!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MyFlowLayout extends JFrame implements ActionListener
{
private JButton leftButton;
private JButton centerButton;
private JButton rightButton;
JPanel contentPane=(JPanel) this.getContentPane();
public MyFlowLayout(){
leftButton=new JButton("left");
centerButton=new JButton("center");
rightButton=new JButton("right");
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));
contentPane.add(leftButton);
contentPane.add(centerButton);
contentPane.add(rightButton);
setSize(500,100);
setVisible(true);
show();
leftButton.addActionListener(this);
centerButton.addActionListener(this);
rightButton.addActionListener(this);
}
public static void main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable(){public void run(){
MyFlowLayout frame=new MyFlowLayout();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
}
public void actionPerformed(ActionEvent e){
String command=e.getActionCommand();
if(command.equals("left")){
contentPane.setLayout(new FlowLayout(FlowLayout.LEFT));
}
if(command.equals("center")){
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));
}
if(command.equals("right")){
contentPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
}
super.repaint();
}
}
这是我写的代码,运行后如果按left只有最大化才能重新排布.再按right和第一次按一样只有最小化才能重新排布,这是为什么!
这个知识点你还没有学到!
java题目要求我们按left排布就按从做向右排布,按center排布就按从中间排布,按right就按从右向左排布!
电子排布 特殊有一些元素的排布不仅仅按三个原理退出来就对的,如Cu,Gd好像共有十个
核外电子是按能量高低的不同( )排布的.
电子的排布问题在原子结构示意图中,电子按2、8、8、18排布 而电子排布式告诉我们1S2 2s2 2p6等 ,可是电子有
核外电子排布
原子排布
电子排布
按管线综合布置的一般原则,从建筑到道路的方向由浅至深布置以下管线排布的顺序正确的是
化学电子轨道排布一般规律按那个连珠图像但为什么41号元素铌,44钌45铑46钯,电子排布规律反常呢?
按核外电子排布规律,核电荷数为19的原子核外电子层排布正确的是 A.2.8.7.2 B.2.8.9 C.10.8.1 D
关于电子层能量排布电子层的排布按能量的多少,这里的能量是指什么能量?为什么中间的电子数量多但能量却小于最外层.还有,表示
化学能级排布,核外电子排布的顺序