Esempio n. 1
0
public class AttributesPanel extends JComponent {
  private boolean settingcollection = false;
  private Box box = Box.createVerticalBox();

  Vector tobeduplicated = new Vector();

  public AttributesPanel() {
    this.setLayout(new BorderLayout());
    super.add(box, BorderLayout.CENTER);
  }

  public void setEntity(java.lang.Object ent) {
    Method[] methods = ent.getClass().getDeclaredMethods();
    box.removeAll();
    for (Method m : methods) {
      if (m.getName().toLowerCase().startsWith("get")) {
        String attName = m.getName().substring(3);
        Object result;
        try {
          result = m.invoke(ent, new Object[] {});
          String value = "null";
          if (result != null) value = result.toString();
          JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
          attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value));
          box.add(attPane);
        } catch (IllegalArgumentException e) {

          e.printStackTrace();
        } catch (IllegalAccessException e) {

          e.printStackTrace();
        } catch (InvocationTargetException e) {

          e.printStackTrace();
        }
      }
    }
  }

  public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {

    JFrame jf = new JFrame();

    AttributesPanel colpal = new AttributesPanel();
    colpal.setEntity(new FrameFact("hola"));
    colpal.setEntity(new FrameFact("hola"));
    jf.getContentPane().add(colpal);
    jf.pack();
    jf.show();
    jf.pack();
  }
}
Esempio n. 2
0
  private JPanel getParamsPanel() {
    JPanel paramsPanel = new JPanel();

    Box b2 = Box.createVerticalBox();

    JComponent indTestParamBox = getIndTestParamBox();
    if (indTestParamBox != null) {
      b2.add(indTestParamBox);
    }

    paramsPanel.add(b2);
    paramsPanel.setBorder(new TitledBorder("Parameters"));
    return paramsPanel;
  }
  public java.awt.Container createControlPanel() {
    java.awt.Container panel2 = Box.createVerticalBox();
    panel2 = super.createControlPanel();

    brainPlay = new JCheckBox("Brain Play", false);
    if (testMode) brainPlay.setSelected(true);
    panel2.add(brainPlay);

    JPanel row2 = new JPanel();

    // ADVERSARY slider
    row2.add(Box.createVerticalStrut(12));
    row2.add(new JLabel("Adversary:"));

    adversary = new JSlider(0, 100, 0); // min, max, current
    adversary.setPreferredSize(new Dimension(100, 15));
    row2.add(adversary);

    JPanel text = new JPanel();
    text.add(adStat = new JLabel(adversaryOff));
    panel2.add(text);

    panel2.add(row2);

    JPanel row3 = new JPanel();

    // Mr. Happy slider
    row3.add(Box.createVerticalStrut(12));
    row3.add(new JLabel("CELAB"));

    happy = new JSlider(0, 100, 0); // min, max, current
    happy.setPreferredSize(new Dimension(100, 15));
    row3.add(happy);

    JPanel text2 = new JPanel();
    text2.add(adHappy = new JLabel(happyOff));
    panel2.add(text2);

    panel2.add(row3);

    return (panel2);
  }
Esempio n. 4
0
  public MainPanel() {
    super(new BorderLayout());
    l1.setToolTipText("Test1");
    l2.setToolTipText("Test2");
    l3.setToolTipText("<html><img src='" + url + "'>Test3</html>");

    JPanel p1 = new JPanel(new BorderLayout());
    p1.setBorder(BorderFactory.createTitledBorder("javax.swing.Timer"));
    p1.add(l1);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(BorderFactory.createTitledBorder("Animated Gif"));
    p2.add(l2, BorderLayout.NORTH);
    p2.add(l3, BorderLayout.SOUTH);

    Box box = Box.createVerticalBox();
    box.add(p1);
    box.add(Box.createVerticalStrut(20));
    box.add(p2);
    box.add(Box.createVerticalGlue());
    add(box);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
  }
Esempio n. 5
0
  public storiconoleggio() {

    storico = new JFrame("Storico cliente:");
    storico.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    storico.setVisible(true);

    operazioni = new JPanel();
    operazioni.setLayout(new BoxLayout(operazioni, BoxLayout.Y_AXIS));

    sotto = new JPanel();

    gruppo = Box.createVerticalBox();

    indietro = new JButton("Indietro");

    ascoltatore = new listenernolcli();

    Object righe[][] = {
      {"# Noleggio", "ID Bagnino", "# Ombrellone", "Data Noleggio", "Num. Lettini", "ID Cliente"}
    };
    Object colonne[] = {"", "", "", "", "", ""};
    JTable tabella = new JTable(righe, colonne);

    try {
      String url = "jdbc:mysql://127.0.0.1:3306/lido";
      String userid = "root";
      String paswordd = "root";
      con = DriverManager.getConnection(url, userid, paswordd);
      requete = con.createStatement();
      rs =
          requete.executeQuery(
              "SELECT * FROM lido.bagnino_noleggia_ombrellone WHERE cliente_idcliente ="
                  + login.getNomeUtente());
      ResultSetMetaData md = rs.getMetaData();
      int columnCount = md.getColumnCount();

      Vector columns = new Vector(columnCount);

      for (int i = 1; i <= columnCount; i++) columns.add(md.getColumnName(i));
      Vector data = new Vector();
      Vector row;

      while (rs.next()) {
        row = new Vector(columnCount);
        for (int i = 1; i <= columnCount; i++) {
          row.add(rs.getString(i));
        }
        data.add(row);
      }
      table = new JTable(data, columns);
      table.setPreferredScrollableViewportSize(new Dimension(500, 70));
      table.setFillsViewportHeight(true);
      table.setVisible(true);
      table.validate();

    } catch (SQLException sqle) {

      System.out.println(sqle);
      sqle.printStackTrace();
    }

    indietro.addActionListener(ascoltatore);

    operazioni.add(tabella);
    operazioni.add(table);

    sotto.add(indietro);

    gruppo.add(operazioni);
    gruppo.add(sotto);
    storico.add(gruppo);
    storico.pack();
  }
Esempio n. 6
0
  /** Install the Rotate-Button into the toolbar */
  private void installRotateButton() {
    URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/rotate.gif");
    ImageIcon rotateIcon = new ImageIcon(imgURL);
    rotate = new JButton(rotateIcon);
    rotate.setEnabled(false);
    rotatePanel = new JToolBar();
    rotatePanel.setOrientation(1);
    rotatePanel.setLayout(new BorderLayout(0, 1));
    rotateSlider = new JSlider();
    rotateSlider.setMaximum(359);
    rotateSlider.setMinimum(0);
    rotateSlider.setMaximumSize(new Dimension(100, 100));
    rotateSlider.setOrientation(1);
    Box box = Box.createVerticalBox();

    sliderValue.setPreferredSize(new Dimension(30, 20));

    rotateSlider.setAlignmentY(Component.TOP_ALIGNMENT);
    box.add(sliderValue);
    box.add(rotateSlider);
    sliderValue.setAlignmentY(Component.TOP_ALIGNMENT);
    rotatePanel.add(box, BorderLayout.NORTH);

    sliderValue.addFocusListener(
        new FocusListener() {

          private int oldValue = 0;

          public void focusGained(FocusEvent arg0) {
            oldValue = Integer.parseInt(sliderValue.getText());
          }

          public void focusLost(FocusEvent arg0) {
            int newValue = 0;
            try {
              newValue = Integer.parseInt(sliderValue.getText());
            } catch (Exception ex) {
              sliderValue.setText(Integer.toString(oldValue));
            }
            if (newValue >= 0 && newValue <= 359) {

              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rotateSlider.setValue(newValue);
            } else {
              sliderValue.setText(Integer.toString(oldValue));
            }
          }
        });

    rotateSlider.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent arg0) {

            if (board.getSelectionCount() == 1
                && board.getSelectionCells()[0] instanceof ShapeItem) {
              sliderValue.setText(Integer.toString(rotateSlider.getValue()));
              ShapeItem s = (ShapeItem) board.getSelectionCells()[0];
              board.removeItem(new ItemComponent[] {s});
              s.setRotation(rotateSlider.getValue());
              board.addItem(s);
            }
          }
        });
    rotateSlider.addMouseListener(
        new MouseAdapter() {

          private int value;

          public void mousePressed(MouseEvent e) {
            value = rotateSlider.getValue();
          }

          public void mouseReleased(MouseEvent e) {
            if (value != rotateSlider.getValue()) {
              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rc.setRotation(value);
            }
          }
        });

    rotate.setToolTipText(workingViewLabels.getString("rotate"));

    rotate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (board.getSelectionCount() == 1
                && board.getSelectedItems()[0] instanceof ShapeItem) {
              rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation());
            }
            rotatePanel.setVisible(!rotatePanel.isVisible());
            showRotate = !showRotate;
          }
        });

    rotate.setContentAreaFilled(false);
    rotate.setBorderPainted(false);
    toolbar.add(rotate);
    rotatePanel.setVisible(false);
    this.add(rotatePanel, BorderLayout.EAST);
  }
  /** Initializes all GUI components */
  private void initComponents() {

    mainPanel = new JPanel();
    editPanel = new JPanel();
    editPanelLeft = new JPanel();
    editPanelCenter = new JPanel();
    editPanelRight = new JPanel();
    tablePanel = new JPanel();

    companyIdTextField = new JTextField();
    companyIdTextField.setEditable(false);
    companyNameTextField = new JTextField();
    urlTextField = new JTextField();
    insuranceTypesTextField = new JTextField();
    telephoneTextField = new JTextField();
    percentageTextField = new JTextField();
    percentageTextField.setToolTipText("<html>Only <b>numerical</b> values allowed</html>");
    searchTextField = new JTextField();
    searchTextField.setToolTipText(
        "<html>Use either <b>AND</b> or <b>OR</b> for combined search queries<br>You can also use <b>spaces</b> instead of <b>OR</b></html>");
    generalDescriptionTextField = new JTextField();

    companyIdLabel = new InsuranceCompanyLabel("ID");
    companyNameLabel = new InsuranceCompanyLabel("Company");
    urlLabel = new InsuranceCompanyLabel("Website");
    insuranceTypesLabel = new InsuranceCompanyLabel("Insurance Types");
    telephoneLabel = new InsuranceCompanyLabel("Telephone");
    percentageLabel = new InsuranceCompanyLabel("Broker Percentage");
    searchLabel = new InsuranceCompanyLabel("Search Insurance Types");
    generalDescriptionLabel = new InsuranceCompanyLabel("General Description");
    sortLabel = new InsuranceCompanyLabel("Sorting");

    addInsuranceCompanyButton = new InsuranceCompanyButton("New Insurance Company", 190, 45);
    addInsuranceCompanyButton.setToolTipText(
        "<html>Create a new <b>empty</b> Insurance Company</html>");
    saveInsuranceCompanyButton = new InsuranceCompanyButton("Save Insurance Company", 190, 45);
    saveInsuranceCompanyButton.setToolTipText(
        "<html>Save the <b>selected</b> Insurance Company<br>Hint: Press <b>Enter</b> to quickly save an entry</html>");
    saveInsuranceCompanyButton.setDefaultCapable(true);
    getRootPane()
        .setDefaultButton(
            saveInsuranceCompanyButton); // Set the save button as default button, so quicker
                                         // editing by pressing Enter is possible
    deleteInsuranceCompanyButton = new InsuranceCompanyButton("Delete Insurance Company", 190, 45);
    deleteInsuranceCompanyButton.setToolTipText(
        "<html>Delete the <b>selected</b> Insurance Company</html>");
    clearSearchButton = new InsuranceCompanyButton("x", 40, 35);
    clearSearchButton.setToolTipText("<html>Click to <b>clear</b> the search field</html>");

    String[] sortStrategies = {"ID", "Company Name", "Percentage"};
    sortComboBox = new JComboBox(sortStrategies);

    tableData = new InsuranceCompanyTableModel(model.getInsuranceCompanies());
    insuranceCompaniesTable = new JTable();

    insuranceCompanyScrollPane = new JScrollPane(insuranceCompaniesTable);

    // Set layout and add components to panels
    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(editPanel, BorderLayout.NORTH);
    editPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    editPanel.setLayout(new BorderLayout());
    editPanel.add(editPanelLeft, BorderLayout.CENTER);
    editPanelLeft.setBorder(new EmptyBorder(0, 0, 5, 15));
    editPanelLeft.setLayout(new GridLayout(4, 4, 5, 0));
    editPanelLeft.add(companyIdLabel);
    editPanelLeft.add(companyNameLabel);
    editPanelLeft.add(urlLabel);
    editPanelLeft.add(telephoneLabel);
    editPanelLeft.add(companyIdTextField);
    editPanelLeft.add(companyNameTextField);
    editPanelLeft.add(urlTextField);
    editPanelLeft.add(telephoneTextField);
    editPanelLeft.add(percentageLabel);
    editPanelLeft.add(searchLabel);
    editPanelLeft.add(new JLabel());
    editPanelLeft.add(sortLabel);
    editPanelLeft.add(percentageTextField);
    editPanelLeft.add(searchTextField);
    Container searchBox = Box.createVerticalBox();
    searchBox.add(clearSearchButton);
    editPanelLeft.add(searchBox);
    editPanelLeft.add(sortComboBox);
    editPanel.add(editPanelRight, BorderLayout.EAST);
    Container box = Box.createVerticalBox();
    box.add(saveInsuranceCompanyButton);
    box.add(Box.createVerticalStrut(5));
    box.add(addInsuranceCompanyButton);
    box.add(Box.createVerticalStrut(5));
    box.add(deleteInsuranceCompanyButton);
    editPanelRight.add(box);
    editPanel.add(editPanelCenter, BorderLayout.SOUTH);
    editPanelCenter.setLayout(new GridLayout(4, 1));
    editPanelCenter.add(insuranceTypesLabel);
    editPanelCenter.add(insuranceTypesTextField);
    editPanelCenter.add(generalDescriptionLabel);
    editPanelCenter.add(generalDescriptionTextField);
    mainPanel.add(tablePanel, BorderLayout.CENTER);
    tablePanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10), "Insurance Companies Overview"));
    tablePanel.setLayout(new BorderLayout());
    tablePanel.add(insuranceCompanyScrollPane, BorderLayout.CENTER);

    setMinimumSize(new Dimension(800, 600));
    setPreferredSize(new Dimension(900, 600));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
  }
Esempio n. 8
0
  /** Construct the toolbar panel. */
  protected JPanel getToolbar() {
    JPanel toolbar = new JPanel();

    getExecuteButton().setText("Execute*");
    getExecuteButton()
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                removeStatsTabs();
                execute();
              }
            });

    JButton statsButton = new JButton("Calc Stats");
    statsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Window owner = (Window) getTopLevelAncestor();

            new WatchedProcess(owner) {
              public void watch() {
                calcStats();
              }
            };
          }
        });

    Box b1 = Box.createVerticalBox();
    b1.add(getParamsPanel());
    b1.add(Box.createVerticalStrut(10));

    Box b2 = Box.createHorizontalBox();
    b2.add(Box.createGlue());
    b2.add(getExecuteButton());
    b1.add(b2);
    b1.add(Box.createVerticalStrut(10));

    if (getAlgorithmRunner().getDataModel() instanceof DataSet) {
      Box b3 = Box.createHorizontalBox();
      b3.add(Box.createGlue());
      b3.add(statsButton);
      b1.add(b3);
    }

    //        if (getAlgorithmRunner().getParams() instanceof MeekSearchParams) {
    //            MeekSearchParams params = (MeekSearchParams) getAlgorithmRunner().getParams();
    //            JCheckBox preventCycles = new JCheckBox("Aggressively Prevent Cycles");
    //            preventCycles.setHorizontalTextPosition(AbstractButton.RIGHT);
    //            preventCycles.setSelected(params.isAggressivelyPreventCycles());
    //
    //            preventCycles.addActionListener(new ActionListener() {
    //                public void actionPerformed(ActionEvent e) {
    //                    JCheckBox box = (JCheckBox) e.getSource();
    //                    MeekSearchParams params = (MeekSearchParams)
    // getAlgorithmRunner().getParams();
    //                    params.setAggressivelyPreventCycles(box.isSelected());
    //                }
    //            });
    //
    //            b1.add(Box.createVerticalStrut(5));
    //            Box hBox = Box.createHorizontalBox();
    //            hBox.add(Box.createHorizontalGlue());
    //            hBox.add(preventCycles);
    //            b1.add(hBox);
    //            b1.add(Box.createVerticalStrut(5));
    //        }

    Box b4 = Box.createHorizontalBox();
    JLabel label =
        new JLabel(
            "<html>"
                + "*Please note that some"
                + "<br>searches may take a"
                + "<br>long time to complete."
                + "</html>");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setVerticalAlignment(SwingConstants.CENTER);
    label.setBorder(new TitledBorder(""));
    b4.add(label);

    b1.add(Box.createVerticalStrut(10));
    b1.add(b4);

    toolbar.add(b1);
    return toolbar;
  }