codice:
private void initialize() {
this.setSize(new Dimension(860, 486));
getContentPane().setLayout(new BorderLayout());
setTitle("Open Configuration File");
final JPanel panelDettails = new JPanel();
panelDettails.setLayout(new BorderLayout());
panelDettails.setBorder(new TitledBorder(null, "Dettails Parameter", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
panelDettails.setPreferredSize(new Dimension(280, 0));
getContentPane().add(panelDettails, BorderLayout.EAST);
panelParameterName = new JPanel();
panelParameterName.setBorder(new TitledBorder(null, "Name", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
panelParameterName.setPreferredSize(new Dimension(0, 100));
panelParameterName.setLayout(null);
panelDettails.add(panelParameterName, BorderLayout.NORTH);
jTextFieldType = new JTextField();
jTextFieldType.setToolTipText("Tipo del parametro");
jTextFieldType.setBounds(135, 54, 105, 20);
panelParameterName.add(jTextFieldType);
jTextFieldName = new JTextField();
jTextFieldName.setBounds(135, 28, 105, 20);
panelParameterName.add(jTextFieldName);
labelName = DefaultComponentFactory.getInstance().createLabel("Name");
labelName.setBounds(40, 28, 91, 20);
panelParameterName.add(labelName);
labelType = DefaultComponentFactory.getInstance().createLabel("Type");
labelType.setBounds(40, 54, 91, 20);
panelParameterName.add(labelType);
panelDettails_1 = new JPanel();
panelDettails_1.setBorder(new TitledBorder(null, "Constraint", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
panelDettails_1.setLayout(null);
panelDettails.add(panelDettails_1, BorderLayout.CENTER);
jTextFieldMin = new JTextField();
jTextFieldMin.setToolTipText("Tipo del parametro");
jTextFieldMin.setBounds(134, 44, 105, 20);
panelDettails_1.add(jTextFieldMin);
labelMin = DefaultComponentFactory.getInstance().createLabel("Min");
labelMin.setBounds(37, 44, 91, 20);
panelDettails_1.add(labelMin);
jTextFieldMax = new JTextField();
jTextFieldMax.setToolTipText("Tipo del parametro");
jTextFieldMax.setBounds(134, 70, 105, 20);
panelDettails_1.add(jTextFieldMax);
labelMax = DefaultComponentFactory.getInstance().createLabel("Max");
labelMax.setBounds(37, 70, 91, 20);
panelDettails_1.add(labelMax);
jTextFieldStep = new JTextField();
jTextFieldStep.setToolTipText("Tipo del parametro");
jTextFieldStep.setBounds(134, 96, 105, 20);
panelDettails_1.add(jTextFieldStep);
labelStep = DefaultComponentFactory.getInstance().createLabel("Step");
labelStep.setBounds(37, 96, 91, 20);
panelDettails_1.add(labelStep);
JPanel panelButton = new JPanel();
panelButton.setLayout(new FlowLayout());
panelButton.setPreferredSize(new Dimension(0, 50));
getContentPane().add(panelButton, BorderLayout.SOUTH);
JButton buttonOk = new JButton();
buttonOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
}
});
buttonOk.setText("OK");
panelButton.add(buttonOk);
JButton buttonCancel = new JButton();
buttonCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
}
});
buttonCancel.setText("Cancel");
panelButton.add(buttonCancel);
JPanel panelTable = new JPanel();
panelTable.setBorder(new TitledBorder(null, "Configuration File", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
panelTable.setLayout(new BorderLayout());
getContentPane().add(panelTable, BorderLayout.CENTER);
scrollPaneConfiguration = new JScrollPane();
scrollPaneConfiguration.setPreferredSize(new Dimension(0, 200));
panelTable.add(scrollPaneConfiguration, BorderLayout.NORTH);
scrollPaneMapping = new JScrollPane();
scrollPaneMapping.setPreferredSize(new Dimension(0, 170));
panelTable.add(scrollPaneMapping);
//initJTableConfigurationFile(tableSystemConfiguration);
//per popolare la tabella della system configuration ne metodo mi da' errore
String[][] rowData = { {"Sys_Conf1","0.1","03/10/2008"}, {"Sys_Conf2","0.2","03/10/2008"}, {"Sys_Conf3","0.3","03/10/2008"}, {"Sys_Conf4","0.4","03/10/2008"}, {"Sys_Conf5","0.5","03/10/2008"}};
String[] columnNames = { "Name" , "Version", "Date"};
if (tableSystemConfiguration == null) {
tableSystemConfiguration = new JTable(rowData, columnNames);
tableSystemConfiguration.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel listSelModel = tableSystemConfiguration.getSelectionModel();
tableSystemConfiguration.setRowHeight(25);
listSelModel.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int riga = tableSystemConfiguration.getSelectedRow();
if (riga!= -1){
initJTableConfigurationMapping(tableSystemConfiguration.getValueAt(riga, 0));
}
}
});
}
scrollPaneConfiguration.setViewportView(tableSystemConfiguration);
}
/**
* @param tableSystemConfiguration
*//*
private void initJTableConfigurationFile(JTable tableSystemConfiguration)
{
String[][] rowData = { {"Sys_Conf1","0.1","03/10/2008"}, {"Sys_Conf2","0.2","03/10/2008"}, {"Sys_Conf3","0.3","03/10/2008"}, {"Sys_Conf4","0.4","03/10/2008"}, {"Sys_Conf5","0.5","03/10/2008"}};
String[] columnNames = { "Name" , "Version", "Date"
};
if (tableSystemConfiguration == null) {
tableSystemConfiguration = new JTable(rowData, columnNames);
tableSystemConfiguration.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel listSelModel = tableSystemConfiguration.getSelectionModel();
tableSystemConfiguration.setRowHeight(25);
listSelModel.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int riga = tableSystemConfiguration.getSelectedRow();
if (riga!= -1){
initJTableConfigurationMapping(tableSystemConfigurationMapping, tableSystemConfiguration.getValueAt(riga, 0));
}
}
});
}
}
*/
/**
* @param tableSystemConfigurationMapping2
* @param object
*/
protected void initJTableConfigurationMapping(Object object)
{
JTable tableSystemConfigurationMapping = null;
tableModelMapping tMM = null;
ArrayList<String> row = new ArrayList<String>();
//if (arrayRow == null && arrayColon == null){
//arrayColon = new Vector<String>();
//arrayRow = new Vector<Vector<String>>();
//}
//else {
//arrayRow.clear();
// arrayColon.clear();
//}
if(tableSystemConfigurationMapping == null) {
tMM = new tableModelMapping();
tableSystemConfigurationMapping = new JTable(tMM);
}
if (tableSystemConfigurationMapping != null) {
if (((String)object).equals("Sys_Conf1")){
System.out.println("1");
tMM.addConfigurationFile("Parameter");
tMM.addConfigurationFile("Conf_File_1");
tMM.addConfigurationFile("Conf_File_2");
tMM.addConfigurationFile("Conf_File_3");
tMM.addConfigurationFile("Conf_File_4");
row.add("Param_1");
row.add("Param_1_Conf1");
row.add("Param_1_Conf2");
row.add("Param_1_Conf3");
row.add("Param_1_Conf4");
tMM.addParameter(row);
}
if (((String)object).equals("Sys_Conf2")){
tMM.addConfigurationFile("Parameter");
tMM.addConfigurationFile("Conf_File_1");
tMM.addConfigurationFile("Conf_File_2");
tMM.addConfigurationFile("Conf_File_3");
row.add("Param_1");
row.add("Param_1_Conf1");
row.add("Param_1_Conf2");
row.add("Param_1_Conf3");
tMM.addParameter(row);
}
if (((String)object).equals("Sys_Conf3")){
System.out.println("3");
tMM.addConfigurationFile("Parameter");
tMM.addConfigurationFile("Conf_File_1");
tMM.addConfigurationFile("Conf_File_2");
row.add("Param_1");
row.add("Param_1_Conf1");
row.add("Param_1_Conf2");
tMM.addParameter(row);
}
}
scrollPaneMapping.setViewportView(tableSystemConfigurationMapping);
scrollPaneMapping.validate();
}
}