📄 choisircolonne.java
字号:
package fr.umlv.projet.fenetre;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import fr.umlv.projet.IG.Processuses;
public class ChoisirColonne{
private List<String> list= new ArrayList<String>();
JTextArea question = new JTextArea("Selectionnez les colonnes qui apparaitront dans la page\n"+"Processus du Gestionnaire des taches\n"+" ");
JCheckBox cb11 = new JCheckBox("User Name");
JCheckBox cb12 = new JCheckBox("Name");
JCheckBox cb21 = new JCheckBox("SleepAVG");
JCheckBox cb22 = new JCheckBox("Tgid");
JCheckBox cb31 = new JCheckBox("Pid");
JCheckBox cb32 = new JCheckBox("PPid");
JCheckBox cb41 = new JCheckBox("TracerPid");
JCheckBox cb42 = new JCheckBox("Uid");
JCheckBox cb51 = new JCheckBox("Gid");
JCheckBox cb52 = new JCheckBox("FDSize");
JCheckBox cb61 = new JCheckBox("VmSize(KB)");
JCheckBox cb62 = new JCheckBox("VmLck(KB)");
JCheckBox cb71 = new JCheckBox("VmRSS(KB)");
JCheckBox cb72 = new JCheckBox("VmData(KB)");
JCheckBox cb81 = new JCheckBox("VmStk(KB)");
JCheckBox cb82 = new JCheckBox("VmExe(KB)");
JCheckBox cb91 = new JCheckBox("VmLib(KB)");
JCheckBox cb92 = new JCheckBox("VmPTE(KB)");
JCheckBox cb101 = new JCheckBox("Threads");
JCheckBox cb102 = new JCheckBox("State");
JCheckBox cb111 = new JCheckBox("MEM%");
JCheckBox cb112 = new JCheckBox("CPU%");
JCheckBox cb121 = new JCheckBox("CMD");
final JFrame frame = new JFrame("Selection Colone");
final JCheckBox check[]={cb11,cb12,cb21,cb22,cb31,cb32,cb41,cb42,cb51,cb52,cb61,cb62,cb71,cb72,cb81,cb82,cb91,cb92,cb101,cb111,cb112,cb121};
JPanel p = new JPanel();
public ChoisirColonne()
{
this.list = TabbedPane.getProcTableModel().getColumnName();
init();
choisir(list);
}
private void choisir(List<String> list){
for(String s : list){
for(int i=0;i<check.length;i++){
if(check[i].getText().equals(s)){
check[i].setSelected(true);
continue;
}
}
}
}
private void init()
{
JLabel l1 = new JLabel();
l1.setText(" ");
JLabel l2 = new JLabel();
l2.setText(" ");
question.setEditable(false);
GridBagLayout gb = new GridBagLayout();
GridBagConstraints bc = new GridBagConstraints();
p.setLayout(gb);
//p.add(question);
/***********la zero ligne***************/
bc.gridx=0;
bc.gridy=0;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(question,bc);
p.add(question);
/***********la premiere ligne***************/
bc.gridx=0;
bc.gridy=1;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(check[0],bc);
p.add(check[0]);
bc.gridx=1;
bc.gridy=1;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(check[1],bc);
p.add(check[1]);
/***********la deuxieme ligne***************/
bc.gridx=0;
bc.gridy=2;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(check[2],bc);
p.add(check[2]);
bc.gridx=1;
bc.gridy=2;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb22,bc);
p.add(cb22);
/***********la troisieme ligne***************/
bc.gridx=0;
bc.gridy=3;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb31,bc);
p.add(cb31);
bc.gridx=1;
bc.gridy=3;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb32,bc);
p.add(cb32);
/***********la quatrieme ligne***************/
bc.gridx=0;
bc.gridy=4;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb41,bc);
p.add(cb41);
bc.gridx=1;
bc.gridy=4;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb42,bc);
p.add(cb42);
/***********la cinquieme ligne***************/
bc.gridx=0;
bc.gridy=5;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb51,bc);
p.add(cb51);
bc.gridx=1;
bc.gridy=5;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb52,bc);
p.add(cb52);
/***********la sixieme ligne***************/
bc.gridx=0;
bc.gridy=6;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb61,bc);
p.add(cb61);
bc.gridx=1;
bc.gridy=6;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb62,bc);
p.add(cb62);
/***********la septieme ligne***************/
bc.gridx=0;
bc.gridy=7;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb71,bc);
p.add(cb71);
bc.gridx=1;
bc.gridy=7;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb72,bc);
p.add(cb72);
/***********la huitieme ligne***************/
bc.gridx=0;
bc.gridy=8;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb81,bc);
p.add(cb81);
bc.gridx=1;
bc.gridy=8;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb82,bc);
p.add(cb82);
/***********la neuvieme ligne***************/
bc.gridx=0;
bc.gridy=9;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb91,bc);
p.add(cb91);
bc.gridx=1;
bc.gridy=9;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb92,bc);
p.add(cb92);
/***********la dixieme ligne***************/
bc.gridx=0;
bc.gridy=10;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb101,bc);
p.add(cb101);
bc.gridx=1;
bc.gridy=10;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb102,bc);
p.add(cb102);
/***********la onzieme ligne***************/
bc.gridx=0;
bc.gridy=11;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb111,bc);
p.add(cb111);
bc.gridx=1;
bc.gridy=11;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb112,bc);
p.add(cb112);
/***********la douzieme ligne***************/
bc.gridx=0;
bc.gridy=12;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(cb121,bc);
p.add(cb121);
bc.gridx=1;
bc.gridy=12;
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.WEST;
gb.setConstraints(l2,bc);
p.add(l2);
/***********la toisieme ligne***************/
bc.gridx=0;
bc.gridy=18;
JButton ok = new JButton(" O K ");
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.SOUTHEAST;
gb.setConstraints(ok,bc);
p.add(ok);
ok.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
list.clear();
for(int i=0;i<check.length;i++)
{
if(check[i].isSelected()==true)
{
list.add(check[i].getText());
}
}
TabbedPane.getProcTableModel().setColumnName(list);
TabbedPane.getProcTableModel().setData(ConverData.covert(Processuses.getProcessusList(),TabbedPane.getProcTableModel().getColumnName()));
TabbedPane.getProcTableModel().fireTableStructureChanged();
TabbedPane.getProcTableModel().fireTableDataChanged();
TabbedPane.getJtp().repaint();
frame.dispose();
}
});
bc.gridx=1;
bc.gridy=18;
JButton annuler = new JButton("Cancel");
bc.fill= GridBagConstraints.NONE;
bc.anchor = GridBagConstraints.SOUTHWEST;
gb.setConstraints(annuler,bc);
p.add(annuler);
annuler.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e) {
frame.dispose();
}
});
frame.setContentPane(p);
frame.setSize(450,500);
frame.setResizable(false);
frame.setLocation(300,200);
frame.setTitle("Selection de colonne");
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -