📄 selectsavedia.java
字号:
package util4;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import util2.*;import util3.*;import util5.*;public class SelectSaveDia extends JDialog { JPanel jPanel1 = new JPanel(); JScrollPane scroPan = new JScrollPane(); BorderLayout borderLayout1 = new BorderLayout(); JPanel topPan = new JPanel(new FlowLayout(0,20,10)); JLabel jLabel1 = new JLabel(); JPanel centerPan = new JPanel(); GridLayout gridLayout1 = new GridLayout(); JPanel eastPan = new JPanel(); JButton okBut = new JButton(); JButton cancelBut = new JButton(); GridLayout gridLayout2 = new GridLayout(5,1,4,10); int compIndex=-1; Vector vec=new Vector(); YorNListener ynl=null; public SelectSaveDia(Frame frame,String title,boolean modal) { super(frame,title,modal); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jPanel1.setLayout(borderLayout1); jLabel1.setFont(new java.awt.Font("Serif", 1, 14)); jLabel1.setText("Will you save them ?"); centerPan.setLayout(gridLayout1); scroPan.getViewport().setBackground(SystemColor.scrollbar); scroPan.setBorder(BorderFactory.createLoweredBevelBorder()); eastPan.setLayout(gridLayout2); okBut.setActionCommand("okBut"); okBut.setText("OK"); cancelBut.setActionCommand("cancelBut"); cancelBut.setText("Cancel"); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(scroPan, BorderLayout.CENTER); scroPan.getViewport().add(centerPan, null); jPanel1.add(topPan, BorderLayout.NORTH); topPan.add(jLabel1, null); jPanel1.add(eastPan, BorderLayout.EAST); eastPan.add(okBut, null); eastPan.add(cancelBut, null); setBounds(250,180,300,270); this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { SelectSaveDia.this.setVisible(false); SelectSaveDia.this.ynl.gotYes(YorNListener.cancel); } }); okBut.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ SelectSaveDia.this.setVisible(false); SelectSaveDia.this.ynl.gotYes(YorNListener.yes); } }); cancelBut.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ SelectSaveDia.this.setVisible(false); SelectSaveDia.this.ynl.gotYes(YorNListener.no); } }); } public void addQues(ContainEdi edi){ //this.centerPan.add( // new JCheckBox(" "+edi.getFile().getAbsolutePath()),++compIndex); JCheckBox jcb=new JCheckBox(" "+edi.getFile().getAbsolutePath()); jcb.setBackground(Color.white); jcb.setSelected(true); this.centerPan.add(jcb,++compIndex); this.vec.addElement(edi); } public ContainEdi[] returnResult(){ Component[] com=this.centerPan.getComponents(); Vector v=new Vector(); for(int i=0;i<com.length;i++){ JCheckBox jcb=(JCheckBox)(com[i]); if(jcb.isSelected()){v.addElement((ContainEdi)(this.vec.get(i)));} } //return (ContainEdi[])(v.toArray()); //here may couse some error. ContainEdi[] edi=new ContainEdi[v.size()]; for(int j=0;j<v.size();j++){ edi[j]=(ContainEdi)(v.elementAt(j)); } return edi; } public void addYorNListener(YorNListener l){ this.ynl=l; this.centerPan.setLayout(new GridLayout((this.compIndex+1),1,2,5)); centerPan.doLayout(); this.setVisible(true); } public void resetAll(){ this.vec=new Vector(); this.ynl=null; this.centerPan.removeAll(); this.compIndex=-1; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -