The selection cannot be launches ,there are no recent launches
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.MouseAdapter;
//import java.awt.event.MouseListener;
public class Test {
public class JPopMenuDemo extends JFrame{
private static final long serialVersionUID = 1L;
JRadioButtonMenuItem items[];//菜单项
Color[] colors={Color.blue,Color.pink,Color.yellow,Color.red,Color.orange};
//颜色组
JPopupMenu popupMenu;//弹出菜单
public JPopMenuDemo(){
super("右键弹出菜单");//调用父类构造函数
ChangeColorAction action = new ChangeColorAction();//菜单项处理事件
String[] str ={"Blue","Pink","Yellow","Red","Orange"};//菜单项名称
ButtonGroup colorGroup=new ButtonGroup();//实例化按钮组
popupMenu =new JPopupMenu();//实例化弹出菜单
items=new JRadioButtonMenuItem[5];//初始化数组
for(int i=0;i<items.length;i++){
items[i]=new JRadioButtonMenuItem(str[i]);//实例化菜单项
popupMenu.add(items[i]);//增加菜单项到菜单上
colorGroup.add(items[i]);//增加菜单项到按钮
items[i].addActionListener(action);
}
addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent event){
triggerEvent(event);
}
public void mouseReleased(MouseEvent event){
triggerEvent(event);
}
private void triggerEvent(MouseEvent event){
if(event.isPopupTrigger())
popupMenu.show(event.getComponent(),event.getX(),event.getY());
}
});
getContentPane().setBackground(Color.white);//窗口的默认背景色为白色
setSize(230,160);//设置窗口大小
setVisible(true);//设置窗口可视
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//关闭窗口时退出程序
}
class ChangeColorAction implements ActionListener{//菜单项事件处理
public void actionPerformed(ActionEvent event){
for(int i=0;i<items.length;i++)
if(event.getSource()==items[i]){//判断事件来自于哪个菜单项
getContentPane().setBackground(colors[i]);//设置窗口背景
repaint();//重绘窗口
return;
}
}
}
public void main(String[] args) {
new JPopMenuDemo();
}
}
}
相关推荐
Does the selection of human talent need exams
In the modern world, economic ability has become an important part of a country’s successful development. In economic scopes, business is the most important part of the economic developing. But how to make a successful business? How to set up a good company and extend it?
The Application of AHP+LP in the Evaluation and Selection of Suppliers
The Application of AHP+LP in the Evaluation and Selection of Suppliers,BAI He-song,,This paper introduces the Supplier Relationship Management and the evaluation and selection of suppliers. It aims to summarize a method – Analytic Hierarchy Pr
MATLAB Simulations for Radar Systems Design(代码和图).rar
Simulation is integral to the successful design of modern radar systems, and there is arguably no better software for this purpose than MATLAB. But software and the ability to use it does not guarantee success. One must also: Ö Understand radar operations and design philosophy Ö Know how to select the radar parameters to meet the design requirements Ö Be able to perform detailed trade-off analysis in the context of radar sizing, modes of operation, frequency selection, waveforms, and signal processing Ö Develop loss and error budgets associated with the design MATLAB Simulations for Radar Systems Design teaches all of this and provides the M-files and hands-on simulation experience needed to design and analyze radar systems. Part I forms a comprehensive description of radar systems, their analysis, and the design process. The authors' unique approach involves a design case study introduced in Chapter 1 and followed throughout the text. As the treatment progresses, the complexity increases and the case study requirements are adjusted accordingly. Part II presents a series of chapters-some authored by other experts in the field-on specialized radar topics important to a full understanding of radar systems design and analysis. A comprehensive set of MATLAB programs and functions support both parts of the book and are available for download from the CRC Press Web site.
Meta-Learning and the Full Model Selection Problem.pdf
Meta-Learning and the Full Model Selection Problem 这是是 including data preprocessing, outlier detection, feature selection, learning algorithm and evaluation techniques, for a given data project
Project3.rar_diversity matlab_no diversity_selection diversity
No diversity, Selection diveristy and Maxmimum ratio combination case.


Java SE
