/** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
 /** Constructor */
 public ServiceFilterPanel(String text, Vector list) {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   service_box = new JCheckBox(text);
   service_box.addActionListener(this);
   service_data = new Vector();
   if (list != null) {
     service_box.setSelected(true);
     service_data = (Vector) list.clone();
   }
   service_list = new JList(service_data);
   service_list.setBorder(new EtchedBorder());
   service_list.setVisibleRowCount(5);
   service_list.addListSelectionListener(this);
   service_list.setEnabled(service_box.isSelected());
   service_scroll = new JScrollPane(service_list);
   service_scroll.setBorder(new EtchedBorder());
   remove_service_button = new JButton("Remove");
   remove_service_button.addActionListener(this);
   remove_service_button.setEnabled(false);
   remove_service_panel = new JPanel();
   remove_service_panel.setLayout(new FlowLayout());
   remove_service_panel.add(remove_service_button);
   service_area = new JPanel();
   service_area.setLayout(new BorderLayout());
   service_area.add(service_scroll, BorderLayout.CENTER);
   service_area.add(remove_service_panel, BorderLayout.EAST);
   service_area.setBorder(indent_border);
   add_service_field = new JTextField();
   add_service_field.addActionListener(this);
   add_service_field.getDocument().addDocumentListener(this);
   add_service_field.setEnabled(service_box.isSelected());
   add_service_button = new JButton("Add");
   add_service_button.addActionListener(this);
   add_service_button.setEnabled(false);
   add_service_panel = new JPanel();
   add_service_panel.setLayout(new BorderLayout());
   JPanel dummy = new JPanel();
   dummy.setBorder(empty_border);
   add_service_panel.add(dummy, BorderLayout.WEST);
   add_service_panel.add(add_service_button, BorderLayout.EAST);
   add_service_area = new JPanel();
   add_service_area.setLayout(new BorderLayout());
   add_service_area.add(add_service_field, BorderLayout.CENTER);
   add_service_area.add(add_service_panel, BorderLayout.EAST);
   add_service_area.setBorder(indent_border);
   setLayout(new BorderLayout());
   add(service_box, BorderLayout.NORTH);
   add(service_area, BorderLayout.CENTER);
   add(add_service_area, BorderLayout.SOUTH);
   setBorder(empty_border);
 }
예제 #3
0
    ThreadHeaderRenderer(int modelCol) {
      super(modelCol);

      sort = new JPanel(new BorderLayout());
      sort.setBorder(new BevelBorder(BevelBorder.RAISED));
      sort.add(new JLabel(threadSortIcon), BorderLayout.CENTER);

      unsort = new JPanel(new BorderLayout());
      unsort.setBorder(new BevelBorder(BevelBorder.RAISED));
      unsort.add(new JLabel(threadUnSortIcon), BorderLayout.CENTER);

      comp = unsort;
    }
예제 #4
0
  @SuppressWarnings("unchecked")
  private JComponent jRoom() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setBorder(BorderFactory.createTitledBorder(""));
    scrollPane = new JScrollPane();
    jRoom = new JTable();
    tableTitle.add("RoomID");
    tableTitle.add("RoomNumber");
    tableTitle.add("RoomType");
    tableTitle.add("NumBeds");
    tableTitle.add("RoomTypeRate");
    tableTitle.add("RoomStatus");
    tableTitle.add("Description");

    model =
        new DefaultTableModel(tableRecords, tableTitle) {
          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };

    jRoom.setModel(model);
    jRoom.getTableHeader().setReorderingAllowed(false);
    scrollPane.setViewportView(jRoom);
    panel.add(scrollPane);

    return panel;
  }
예제 #5
0
  private JComponent createForm() {
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout());
    titleData = new JPanel();
    titleData.setLayout(new MigLayout("insets 0", "[grow]"));
    titleData.setBorder(BorderFactory.createTitledBorder(""));

    txtRoomNumber = new JTextField();
    txtDescription = new JTextArea();
    boxRoomStatusID = new JComboBox();
    boxRoomTypeID = new JComboBox();

    titleData.add(new JLabel("Room Number"), "right");
    titleData.add(txtRoomNumber, "grow,width max,height 22,span,gap top 4,gap bottom 4");

    titleData.add(new JLabel("RoomType"), "right");
    titleData.add(boxRoomTypeID, "grow,width max,height 22,span,gap top 4,gap bottom 4");

    titleData.add(new JLabel("RoomStatus"), "right");
    titleData.add(boxRoomStatusID, "grow,width max,height 22,span,gap top 4,gap bottom 4");

    titleData.add(new JLabel("Description"), "right");
    titleData.add(txtDescription, "grow,width max,height 150,span,gap top 4,gap bottom 4");

    panel.add(titleData, "span,width max,height 355");
    return panel;
  }
    protected JPanel createForm() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      // Time
      JPanel pT = new JPanel(new FlowLayout());
      pT.setBorder(BorderFactory.createTitledBorder("Start Time"));
      hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myrow.getTime()), 0, 99, 1));
      hh.setEditor(new JSpinner.NumberEditor(hh, "00"));
      pT.add(hh);
      pT.add(new JLabel("h "));
      mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myrow.getTime()), 0, 59, 1));
      mm.setEditor(new JSpinner.NumberEditor(mm, "00"));
      pT.add(mm);
      pT.add(new JLabel("m "));
      ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myrow.getTime()), 0, 59, 1));
      ss.setEditor(new JSpinner.NumberEditor(ss, "00"));
      pT.add(ss);
      pT.add(new JLabel("s"));
      panel.add(pT);
      // Green
      JPanel pG = new JPanel(new BorderLayout());
      pG.setBorder(BorderFactory.createTitledBorder("Green (sec.)"));
      green = new JSpinner(new SpinnerNumberModel(myrow.getGreen() * conversion, 0.0, 99999.99, 1));
      green.setEditor(new JSpinner.NumberEditor(green, "####0.##"));
      pG.add(green);
      panel.add(pG);
      // Red
      JPanel pR = new JPanel(new BorderLayout());
      pR.setBorder(BorderFactory.createTitledBorder("Red (sec.)"));
      red = new JSpinner(new SpinnerNumberModel(myrow.getRed() * conversion, 0.0, 99999.99, 1));
      red.setEditor(new JSpinner.NumberEditor(red, "####0.##"));
      pR.add(red);
      panel.add(pR);

      JPanel bp = new JPanel(new FlowLayout());
      JButton bOK = new JButton("    OK    ");
      bOK.setActionCommand(cmdOK);
      bOK.addActionListener(new ButtonEventsListener());
      JButton bCancel = new JButton("Cancel");
      bCancel.setActionCommand(cmdCancel);
      bCancel.addActionListener(new ButtonEventsListener());
      bp.add(bOK);
      bp.add(bCancel);
      panel.add(bp);
      return panel;
    }
예제 #7
0
    SortedHeaderRenderer(String name, int modelCol) {
      this.modelCol = modelCol;
      upLabel = new JLabel(sortUpIcon);
      downLabel = new JLabel(sortDownIcon);

      compPanel = new JPanel(new BorderLayout());
      compPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
      compPanel.add(new JLabel(name), BorderLayout.CENTER);
      comp = compPanel;
    }
예제 #8
0
 public void setBorder(JPanel panel, String theme) {
   panel.setBorder(
       BorderFactory.createTitledBorder(
           BorderFactory.createEtchedBorder(),
           theme,
           javax.swing.border.TitledBorder.LEFT,
           javax.swing.border.TitledBorder.DEFAULT_POSITION,
           new Font("Tahoma", Font.PLAIN, 11),
           Color.blue.darker().darker()));
 }
예제 #9
0
 public MainPanel() {
   super(new BorderLayout());
   table.setAutoCreateRowSorter(true);
   JPanel p = new JPanel(new GridLayout(2, 1, 5, 5));
   p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
   p.add(componentChoices);
   p.add(
       new JButton(
           new AbstractAction("show") {
             @Override
             public void actionPerformed(ActionEvent e) {
               model.setRowCount(0);
               JComponent c = ((JComponentType) componentChoices.getSelectedItem()).component;
               for (Integer f : focusType) {
                 loadBindingMap(f, c.getInputMap(f), c.getActionMap());
               }
             }
           }));
   add(p, BorderLayout.NORTH);
   add(new JScrollPane(table));
   setPreferredSize(new Dimension(320, 240));
 }
예제 #10
0
  JPanel criteriaPanel() {
    int height = getHeightPanel(m_field);

    m_table = new SearchTable(m_field);
    m_statusComboBox = new JComboBox(new Object[] {"Active", "Retired", "All"});
    m_andRadioBt = new JRadioButton("and");
    m_andRadioBt.setSelected(true);
    m_orRadioBt = new JRadioButton("or");

    m_containsRadioBt = new JRadioButton("Text Contains Criteria");
    m_containsRadioBt.setSelected(true);
    m_matchRadioBt = new JRadioButton("Match Case");
    m_wholeRadioBt = new JRadioButton("Find Whole Words only");
    m_findBt = new JButton("Find");
    m_findBt.addActionListener(this);
    m_closeBt = new JButton("Close");
    m_closeBt.addActionListener(this);
    m_clearBt = new JButton("Clear");
    m_clearBt.addActionListener(this);

    ButtonGroup bg = new ButtonGroup();
    bg.add(m_andRadioBt);
    bg.add(m_orRadioBt);

    ButtonGroup bg2 = new ButtonGroup();
    bg2.add(m_containsRadioBt);
    bg2.add(m_matchRadioBt);
    bg2.add(m_wholeRadioBt);

    JPanel centerPanel = new JPanel();
    JPanel criteriaPanel = new JPanel();
    JPanel buttonPanel = new JPanel();
    JPanel operatorPanel = new JPanel();
    JPanel optionPanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gridBagConstraints;

    scrollPane.setPreferredSize(new Dimension(100, height));
    scrollPane.getViewport().add(m_table);

    operatorPanel.setLayout(new GridLayout(2, 1));
    operatorPanel.add(m_andRadioBt);
    operatorPanel.add(m_orRadioBt);
    setBorder(operatorPanel, "Search Operator");

    optionPanel.setLayout(new GridLayout(3, 1));
    optionPanel.add(m_containsRadioBt);
    optionPanel.add(m_matchRadioBt);
    optionPanel.add(m_wholeRadioBt);
    setBorder(optionPanel, "Option");

    criteriaPanel.setLayout(new GridBagLayout());
    gridBagConstraints = new GridBagConstraints();

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagConstraints.insets = new Insets(1, 0, 2, 0);
    gridBagConstraints.weightx = 1.0;
    // criteriaPanel.add(new JLabel("Search Criterion"), gridBagConstraints);
    setBorder(criteriaPanel, "Search Criterion");

    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new Insets(1, 0, 5, 0);
    criteriaPanel.add(scrollPane, gridBagConstraints);

    gridBagConstraints.gridy = 2;
    gridBagConstraints.insets = new Insets(1, 0, 2, 0);
    // criteriaPanel.add(new JLabel("Search Operator"), gridBagConstraints);

    gridBagConstraints.gridy = 3;
    gridBagConstraints.insets = new Insets(1, 0, 5, 0);
    criteriaPanel.add(operatorPanel, gridBagConstraints);

    gridBagConstraints.gridy = 4;
    gridBagConstraints.insets = new Insets(1, 0, 2, 0);

    gridBagConstraints.gridy = 5;
    criteriaPanel.add(optionPanel, gridBagConstraints);

    gridBagConstraints.gridy = 6;
    criteriaPanel.add(buttonPanel, gridBagConstraints);

    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.add(m_findBt);
    buttonPanel.add(m_closeBt);
    buttonPanel.add(m_clearBt);

    centerPanel.setLayout(new BorderLayout());
    centerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    centerPanel.add(criteriaPanel, BorderLayout.NORTH);
    // centerPanel.add(buttonPanel, BorderLayout.SOUTH);

    return centerPanel;
  }
  /** Constructor. Sets up and shows the GUI */
  public TextToolsSortDialog(View view, JEditTextArea textArea) {
    super(view, jEdit.getProperty("text-tools.sortadvanced.label"), false);

    this.view = view;
    this.textArea = textArea;
    //		this.data = data;
    //		this.selection = selection;

    view.showWaitCursor();

    sortTableModel = new SortTableModel();

    // preset sortTable if there is a rect selection
    boolean rectSel = false;
    int[] selRows = TextToolsSorting.getRectSelectionRows(textArea);
    if (selRows != null) {
      // we have rectangular selection: assign values to 1st row of table
      sortTableModel.setValueAt(new Integer(selRows[0] + 1), 0, 0);
      sortTableModel.setValueAt(new Integer(selRows[1] + 1), 0, 1);
      rectSel = true;
    }

    sortTable = new JTable(sortTableModel);
    TableColumnModel cMod = sortTable.getColumnModel();
    sortTable.setTableHeader((new SortTableHeader(cMod)));
    sortTable.setRowHeight(25);

    sortTable.setPreferredScrollableViewportSize(new Dimension(430, 200));

    JScrollPane scroll = new JScrollPane(sortTable);

    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(new EmptyBorder(5, 8, 8, 8));
    content.setLayout(new BorderLayout());
    setContentPane(content);
    content.add(scroll, BorderLayout.CENTER);

    JPanel buttons = new JPanel();
    buttons.setBorder(new EmptyBorder(12, 0, 0, 0));
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(this);
    buttons.add(ok);
    buttons.add(Box.createHorizontalStrut(6));
    getRootPane().setDefaultButton(ok);

    cancel = new JButton(jEdit.getProperty("common.cancel"));
    cancel.addActionListener(this);
    buttons.add(cancel);
    buttons.add(Box.createHorizontalStrut(6));

    clear = new JButton("Clear");
    clear.addActionListener(this);
    buttons.add(clear);
    buttons.add(Box.createHorizontalStrut(6));

    help = new JButton("Help");
    help.addActionListener(this);
    buttons.add(help);
    buttons.add(Box.createHorizontalStrut(6));

    buttons.add(Box.createGlue());

    content.add(buttons, BorderLayout.SOUTH);

    delDupsCheckBox =
        new JCheckBox(jEdit.getProperty("text-tools.sortadvanced.delete-identic-lines"));
    onlySelectionCheckBox =
        new JCheckBox(jEdit.getProperty("text-tools.sortadvanced.sort-only-selection"));

    /*
    dontSortCheckBox = new JCheckBox(
    	jEdit.getProperty("text-tools.sortadvanced.dont-sort"));
    delDupsCheckBox.addActionListener(new java.awt.event.ActionListener() {
    	public void actionPerformed(ActionEvent e) {
    		dontSortCheckBox.setEnabled(delDupsCheckBox.isSelected());
    		dontSortCheckBox.setSelected(false);
    	}
    });
    dontSortCheckBox.setEnabled(false);
    */
    JPanel checkBoxes = new JPanel();
    if (rectSel) checkBoxes.add(onlySelectionCheckBox);
    checkBoxes.add(delDupsCheckBox);
    // checkBoxes.add(dontSortCheckBox);  not used, this is an extra action
    content.add(checkBoxes, BorderLayout.NORTH);
    view.hideWaitCursor();
    pack();
    GUIUtilities.loadGeometry(this, "texttools-sort-control");
    setLocationRelativeTo(view);
    setVisible(true);
  } // }}}
  /** Generates Configuration tab. */
  private void fillConfigurationPanel() {
    JPanel desc = new JPanel(new GridLayout(2, 0));
    desc.setBorder(BorderFactory.createTitledBorder("Description"));
    desc.add(
        new JLabel("<html><font color=\"blue\">" + myMonitor.getDescription() + "</font></html>"));
    desc.add(cbEnabled);
    cbEnabled.setSelected(enabled);
    cbEnabled.addChangeListener(this);
    confPanel.add(desc);
    JPanel mlpanel = new JPanel(new GridLayout(1, 0));
    mlpanel.setBorder(BorderFactory.createTitledBorder("Monitored Network Elements"));
    montable = new JTable(montablemodel);
    montable.setPreferredScrollableViewportSize(new Dimension(200, 100));
    montable.getColumnModel().getColumn(0).setPreferredWidth(140);
    montable.getColumnModel().getColumn(1).setPreferredWidth(60);
    montable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              int row = montable.rowAtPoint(new Point(e.getX(), e.getY()));
              AbstractNetworkElement ne = null;
              if ((row >= 0) && (row < myMonitor.getPredecessors().size()))
                ne = myMonitor.getPredecessors().get(row);
              else return;
              treePane.actionSelected(ne, true);
            }
            return;
          }
        });
    mlpanel.add(new JScrollPane(montable));
    confPanel.add(mlpanel);
    JPanel cpanel = new JPanel(new GridLayout(1, 0));
    cpanel.setBorder(BorderFactory.createTitledBorder("Controlleded Network Elements"));
    ctrltable = new JTable(ctrltablemodel);
    ctrltable.setPreferredScrollableViewportSize(new Dimension(200, 100));
    ctrltable.getColumnModel().getColumn(0).setPreferredWidth(140);
    ctrltable.getColumnModel().getColumn(1).setPreferredWidth(60);
    ctrltable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              int row = ctrltable.rowAtPoint(new Point(e.getX(), e.getY()));
              AbstractNetworkElement ne = null;
              if ((row >= 0) && (row < myMonitor.getSuccessors().size()))
                ne = myMonitor.getSuccessors().get(row);
              else return;
              treePane.actionSelected(ne, true);
            }
            return;
          }
        });
    cpanel.add(new JScrollPane(ctrltable));
    confPanel.add(cpanel);
    JPanel pcl = new JPanel(new FlowLayout());
    // controller list
    buttonProp.setEnabled(false);
    buttonProp.setActionCommand(cmdCtrlProp);
    buttonProp.addActionListener(this);
    pcl.setBorder(BorderFactory.createTitledBorder("Complex Controller"));
    buttonProp.setEnabled(false);
    listCControllers = new JComboBox();
    listCControllers.addItem("None");
    String[] ctrlClasses = myMonitor.getComplexControllerClasses();
    for (int i = 0; i < ctrlClasses.length; i++) {
      if ((myController != null)
          && (myController.getClass().getName().compareTo(ctrlClasses[i]) == 0)) {
        listCControllers.addItem(myController);
        listCControllers.setSelectedIndex(i + 1);
        buttonProp.setEnabled(true);
      } else {
        try {
          Class cl = Class.forName(ctrlClasses[i]);
          AbstractControllerComplex cc = (AbstractControllerComplex) cl.newInstance();
          cc.setMyMonitor(myMonitor);
          cc.initialize();
          listCControllers.addItem(cc);
        } catch (Exception e) {
        }
      }
    }
    listCControllers.setActionCommand(cmdCtrlList);
    listCControllers.addActionListener(this);
    pcl.add(listCControllers);
    pcl.add(buttonProp);
    confPanel.add(pcl);

    return;
  }
예제 #13
0
 /** Fills the panel with SWARM specific fields. */
 public void fillPanel() {
   // Zone initialization
   ControllerSWARM z = (ControllerSWARM) controller;
   Vector<Zone> cz = z.zones;
   for (int i = 0; i < cz.size(); i++) zones.add(cz.get(i).clone());
   // Parameter initialization
   density_sample_size = z.P.SWARM_DENSITY_SAMPLE_SIZE;
   epsilon = z.P.epsilon;
   forecast_lead_time = z.P.SWARM_FORECAST_LEAD_TIME;
   input_var_lane = z.P.input_var_lane;
   meas_var_lane = z.P.meas_var_lane;
   phi = z.P.swarm_phi;
   psi = z.P.swarm_psi;
   sat_den_multiplier = z.P.SWARM_SAT_DEN_NUMBER;
   sat_smoother = z.P.sat_smoother;
   slope_sample_size = z.P.SWARM_SLOPE_SAMPLE_SIZE;
   // Components
   JPanel comp = new JPanel(new FlowLayout());
   comp.setBorder(BorderFactory.createTitledBorder("Components"));
   cbsw1.setSelected(z.P.SWARM1);
   comp.add(cbsw1);
   comp.add(new JLabel("  "));
   cbsw2a.setSelected(z.P.SWARM2A);
   comp.add(cbsw2a);
   comp.add(new JLabel("  "));
   cbsw2b.setSelected(z.P.SWARM2B);
   comp.add(cbsw2b);
   comp.add(new JLabel("  "));
   cbdynbott.setEnabled(false);
   comp.add(cbdynbott);
   add(comp);
   // Zones
   JPanel zone = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   zone.setBorder(BorderFactory.createTitledBorder("Zones"));
   zonetab.setPreferredScrollableViewportSize(new Dimension(400, 30));
   setUpBottleneckColumn();
   setUpFromOnrampColumn();
   setUpToOnrampColumn();
   c.fill = GridBagConstraints.HORIZONTAL;
   c.ipady = 45;
   c.weightx = 0.5;
   c.gridwidth = 3;
   c.gridx = 0;
   c.gridy = 0;
   zone.add(new JScrollPane(zonetab), c);
   c.ipady = 0;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridx = 0;
   zone.add(buttonAdd, c);
   c.gridx = 1;
   zone.add(buttonDelete, c);
   // configure buttons
   buttonAdd.setEnabled(true);
   buttonAdd.setActionCommand(cmdAdd);
   buttonAdd.addActionListener(this);
   buttonDelete.setEnabled(true);
   buttonDelete.setActionCommand(cmdDelete);
   buttonDelete.addActionListener(this);
   add(zone);
   // Parameters
   JPanel param = new JPanel(new GridLayout(1, 0));
   param.setBorder(BorderFactory.createTitledBorder("Parameters"));
   final JTable paramtab = new JTable(paramTM);
   paramtab.setPreferredScrollableViewportSize(new Dimension(500, 160));
   param.add(new JScrollPane(paramtab));
   add(param);
   return;
 }
예제 #14
0
  QueryPanel(ControlHandler c) {
    // initialize the important stuff
    control = c;
    control.setQueryPanel(this);

    // make a few buttons and fields
    JButton queryButton = new JButton("Query");
    queryField = new JTextField("", 30); // query
    socketField = new JTextField("0", 3);
    JButton downloadButton = new JButton("Download");

    // add actions
    queryButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            sendQuery();
          }
        });
    downloadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            startDownload();
          }
        });

    // initialize the query table
    queryModel = new QueryTableModel(3, control.getQueryVector());
    queryTable = new JTable(queryModel);
    queryTable.addMouseListener(new TableListener());
    // TableColumnModel columnModel = new TableColumn();
    //    columnModel.getColumn(0).setWidth(350);

    JScrollPane scrollPane = new JScrollPane(queryTable);
    scrollPane.setPreferredSize(new Dimension(625, 150));
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());

    // Create a panel to hold the query search
    JPanel commandPanel = new JPanel();
    commandPanel.add(queryButton);
    commandPanel.add(queryField);
    commandPanel.add(downloadButton);
    add(commandPanel);

    // Create a panel to hold the download button
    JPanel query = new JPanel();
    query.setBorder(BorderFactory.createTitledBorder("Queries"));
    query.add(scrollPane);
    add(query);

    // ---------------------------------------------------------------------

    // Download Table
    downloadModel = new DownloadTableModel(3, control.getDownloadVector());
    downloadTable = new JTable(downloadModel);
    downloadTable.addMouseListener(new TableListener());
    JScrollPane downloadPane = new JScrollPane(downloadTable);
    downloadPane.setPreferredSize(new Dimension(625, 80));
    downloadPane.setBorder(BorderFactory.createLoweredBevelBorder());

    // Buttons
    JButton cancelDownload = new JButton("Cancel Selected");
    JButton cancelAllDownload = new JButton("Cancel All");
    JButton clearDownloadButton = new JButton("Clear completed");

    cancelDownload.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            control.removeDownloadAt(downloadRow);
          }
        });
    clearDownloadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            control.removeCompletedDownloads();
          }
        });

    // A panel for the buttons and things
    JPanel downloadCommand = new JPanel();
    downloadCommand.add(cancelDownload);
    downloadCommand.add(cancelAllDownload);
    downloadCommand.add(clearDownloadButton);
    JPanel down = new JPanel();
    down.setBorder(BorderFactory.createTitledBorder("Downloads"));
    down.add(downloadPane);
    add(down);
    add(downloadCommand);
  }
 /** Constructor (create and layout page) */
 public SOAPMonitorPage(String host_name) {
   host = host_name;
   // Set up default filter (show all messages)
   filter = new SOAPMonitorFilter();
   // Use borders to help improve appearance
   etched_border = new EtchedBorder();
   // Build top portion of split (list panel)
   model = new SOAPMonitorTableModel();
   table = new JTable(model);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   table.setRowSelectionInterval(0, 0);
   table.setPreferredScrollableViewportSize(new Dimension(600, 96));
   table.getSelectionModel().addListSelectionListener(this);
   scroll = new JScrollPane(table);
   remove_button = new JButton("Remove");
   remove_button.addActionListener(this);
   remove_button.setEnabled(false);
   remove_all_button = new JButton("Remove All");
   remove_all_button.addActionListener(this);
   filter_button = new JButton("Filter ...");
   filter_button.addActionListener(this);
   list_buttons = new JPanel();
   list_buttons.setLayout(new FlowLayout());
   list_buttons.add(remove_button);
   list_buttons.add(remove_all_button);
   list_buttons.add(filter_button);
   list_panel = new JPanel();
   list_panel.setLayout(new BorderLayout());
   list_panel.add(scroll, BorderLayout.CENTER);
   list_panel.add(list_buttons, BorderLayout.SOUTH);
   list_panel.setBorder(empty_border);
   // Build bottom portion of split (message details)
   details_time = new JLabel("Time: ", SwingConstants.RIGHT);
   details_target = new JLabel("Target Service: ", SwingConstants.RIGHT);
   details_status = new JLabel("Status: ", SwingConstants.RIGHT);
   details_time_value = new JLabel();
   details_target_value = new JLabel();
   details_status_value = new JLabel();
   Dimension preferred_size = details_time.getPreferredSize();
   preferred_size.width = 1;
   details_time.setPreferredSize(preferred_size);
   details_target.setPreferredSize(preferred_size);
   details_status.setPreferredSize(preferred_size);
   details_time_value.setPreferredSize(preferred_size);
   details_target_value.setPreferredSize(preferred_size);
   details_status_value.setPreferredSize(preferred_size);
   details_header = new JPanel();
   details_header_layout = new GridBagLayout();
   details_header.setLayout(details_header_layout);
   details_header_constraints = new GridBagConstraints();
   details_header_constraints.fill = GridBagConstraints.BOTH;
   details_header_constraints.weightx = 0.5;
   details_header_layout.setConstraints(details_time, details_header_constraints);
   details_header.add(details_time);
   details_header_layout.setConstraints(details_time_value, details_header_constraints);
   details_header.add(details_time_value);
   details_header_layout.setConstraints(details_target, details_header_constraints);
   details_header.add(details_target);
   details_header_constraints.weightx = 1.0;
   details_header_layout.setConstraints(details_target_value, details_header_constraints);
   details_header.add(details_target_value);
   details_header_constraints.weightx = .5;
   details_header_layout.setConstraints(details_status, details_header_constraints);
   details_header.add(details_status);
   details_header_layout.setConstraints(details_status_value, details_header_constraints);
   details_header.add(details_status_value);
   details_header.setBorder(etched_border);
   request_label = new JLabel("SOAP Request", SwingConstants.CENTER);
   request_text = new SOAPMonitorTextArea();
   request_text.setEditable(false);
   request_scroll = new JScrollPane(request_text);
   request_panel = new JPanel();
   request_panel.setLayout(new BorderLayout());
   request_panel.add(request_label, BorderLayout.NORTH);
   request_panel.add(request_scroll, BorderLayout.CENTER);
   response_label = new JLabel("SOAP Response", SwingConstants.CENTER);
   response_text = new SOAPMonitorTextArea();
   response_text.setEditable(false);
   response_scroll = new JScrollPane(response_text);
   response_panel = new JPanel();
   response_panel.setLayout(new BorderLayout());
   response_panel.add(response_label, BorderLayout.NORTH);
   response_panel.add(response_scroll, BorderLayout.CENTER);
   details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
   details_soap.setTopComponent(request_panel);
   details_soap.setRightComponent(response_panel);
   details_soap.setResizeWeight(.5);
   details_panel = new JPanel();
   layout_button = new JButton("Switch Layout");
   layout_button.addActionListener(this);
   reflow_xml = new JCheckBox("Reflow XML text");
   reflow_xml.addActionListener(this);
   details_buttons = new JPanel();
   details_buttons.setLayout(new FlowLayout());
   details_buttons.add(reflow_xml);
   details_buttons.add(layout_button);
   details_panel.setLayout(new BorderLayout());
   details_panel.add(details_header, BorderLayout.NORTH);
   details_panel.add(details_soap, BorderLayout.CENTER);
   details_panel.add(details_buttons, BorderLayout.SOUTH);
   details_panel.setBorder(empty_border);
   // Add the two parts to the age split pane
   split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
   split.setTopComponent(list_panel);
   split.setRightComponent(details_panel);
   // Build status area
   start_button = new JButton("Start");
   start_button.addActionListener(this);
   stop_button = new JButton("Stop");
   stop_button.addActionListener(this);
   status_buttons = new JPanel();
   status_buttons.setLayout(new FlowLayout());
   status_buttons.add(start_button);
   status_buttons.add(stop_button);
   status_text = new JLabel();
   status_text.setBorder(new BevelBorder(BevelBorder.LOWERED));
   status_text_panel = new JPanel();
   status_text_panel.setLayout(new BorderLayout());
   status_text_panel.add(status_text, BorderLayout.CENTER);
   status_text_panel.setBorder(empty_border);
   status_area = new JPanel();
   status_area.setLayout(new BorderLayout());
   status_area.add(status_buttons, BorderLayout.WEST);
   status_area.add(status_text_panel, BorderLayout.CENTER);
   status_area.setBorder(etched_border);
   // Add the split and status area to page
   setLayout(new BorderLayout());
   add(split, BorderLayout.CENTER);
   add(status_area, BorderLayout.SOUTH);
 }
  public AncestralStatesPanel(BeautiFrame parent) {

    super();

    this.frame = parent;

    partitionTableModel = new PartitionTableModel();
    partitionTable = new JTable(partitionTableModel);

    partitionTable.getTableHeader().setReorderingAllowed(false);
    partitionTable.getTableHeader().setResizingAllowed(false);
    //        modelTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    final TableColumnModel model = partitionTable.getColumnModel();
    final TableColumn tableColumn0 = model.getColumn(0);

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(partitionTable);

    partitionTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    partitionTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    JScrollPane scrollPane =
        new JScrollPane(
            partitionTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setOpaque(false);

    JPanel panel = new JPanel(new BorderLayout(0, 0));
    panel.setOpaque(false);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, 0));

    optionsPanelParent = new JPanel(new FlowLayout(FlowLayout.CENTER));
    optionsPanelParent.setOpaque(false);
    optionsBorder = new TitledBorder("Ancestral state options:");
    optionsPanelParent.setBorder(optionsBorder);

    setCurrentPartition(null);

    JScrollPane scrollPane2 =
        new JScrollPane(
            optionsPanelParent,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane2.setOpaque(false);
    scrollPane2.setBorder(null);
    scrollPane2.getViewport().setOpaque(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, scrollPane2);
    splitPane.setDividerLocation(MINIMUM_TABLE_WIDTH);
    splitPane.setContinuousLayout(true);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOpaque(false);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(splitPane, BorderLayout.CENTER);
  }
예제 #17
0
 @SuppressWarnings("serial")
 private void initGUI() {
   try {
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     getContentPane().setLayout(null);
     this.setTitle("Overzicht");
     this.setVisible(true);
     {
       lStart = new JLabel();
       getContentPane().add(lStart);
       lStart.setText("Overzicht");
       lStart.setHorizontalAlignment(SwingConstants.CENTER);
       lStart.setBackground(new java.awt.Color(54, 190, 54));
       lStart.setFont(new java.awt.Font("Arial", 1, 36));
       lStart.setForeground(new java.awt.Color(0, 128, 64));
       lStart.setOpaque(true);
       lStart.setBounds(0, 0, 336, 49);
     }
     {
       pInzet = new JPanel();
       getContentPane().add(pInzet);
       pInzet.setBorder(
           BorderFactory.createTitledBorder(
               null,
               "Selectie",
               TitledBorder.LEADING,
               TitledBorder.DEFAULT_POSITION,
               new java.awt.Font("Tahoma", 1, 11)));
       pInzet.setLayout(null);
       pInzet.setBounds(14, 63, 308, 105);
       pInzet.setFont(new java.awt.Font("Tahoma", 1, 12));
       {
         lMin = new JLabel();
         pInzet.add(lMin);
         lMin.setText("Speler");
         lMin.setFont(new java.awt.Font("Arial", 0, 12));
         lMin.setBounds(17, 59, 62, 27);
       }
       {
         lMax = new JLabel();
         pInzet.add(lMax);
         lMax.setText("Spelronde");
         lMax.setFont(new java.awt.Font("Arial", 0, 12));
         lMax.setBounds(17, 26, 62, 25);
       }
       // Combo voor Spelrondes. Deze wordt eerst geladen. Na selectie
       // wordt de speler gevuld.
       {
         oc = new OverzichtController(this);
         String[] rondes = oc.GeefSpelrondes();
         ComboBoxModel cbSpelRondeModel = new DefaultComboBoxModel(rondes);
         cbSpelRonde = new JComboBox();
         pInzet.add(cbSpelRonde);
         cbSpelRonde.setModel(cbSpelRondeModel);
         cbSpelRonde.setBounds(91, 29, 156, 21);
         cbSpelRonde.setToolTipText("Maak een keuze uit de gespeelde speelronden.");
       }
       {
         bStart = new JButton();
         getContentPane().add(bStart);
         bStart.setText("Sluiten");
         bStart.setFont(new java.awt.Font("Arial", 0, 12));
         bStart.setBounds(196, 303, 75, 23);
         bStart.addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                 bStartActionPerformed(evt);
               }
             });
       }
     }
     pack();
     this.setSize(352, 364);
   } catch (Exception e) {
     e.printStackTrace();
   }
 } // private void initGUI()
  /** 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();
  }
 /** Fills the panel with simple signal specific fields. */
 protected void fillPanel() {
   if (controller != null) {
     Vector<CycleDataRow> cd = ((ControllerSimpleSignal) controller).getCycleTable();
     for (int i = 0; i < cd.size(); i++) {
       CycleDataRow cdr =
           ((ControllerSimpleSignal) controller)
           .new CycleDataRow(cd.get(i).getTime(), cd.get(i).getGreen(), cd.get(i).getRed());
       cycledata.add(cdr);
     }
   }
   // offset
   JPanel pO = new JPanel(new BorderLayout());
   pO.setBorder(BorderFactory.createTitledBorder("Offset (sec.)"));
   offset =
       new JSpinner(
           new SpinnerNumberModel(
               ((ControllerSimpleSignal) controller).getOffset() * conversion, 0.0, 99999.99, 10));
   offset.setEditor(new JSpinner.NumberEditor(offset, "####0.##"));
   pO.add(offset);
   add(pO);
   // table
   JPanel tabpanel = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   tabpanel.setBorder(BorderFactory.createTitledBorder("Cycle Schedule"));
   cycletable = new JTable(cycletablemodel);
   cycletable.setPreferredScrollableViewportSize(new Dimension(200, 50));
   cycletable.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             int row = cycletable.rowAtPoint(new Point(e.getX(), e.getY()));
             if ((row > cycledata.size() - 1) || (row < 0)) return;
             try {
               WindowEdit winEdit = new WindowEdit(null, cycledata.get(row));
               winEdit.setVisible(true);
               cycletablemodel.deleterow(row);
               cycletablemodel.addrow(winEdit.getMyRow());
             } catch (Exception excp) {
             }
           }
         }
       });
   c.fill = GridBagConstraints.HORIZONTAL;
   c.ipady = 100;
   c.weightx = 0.5;
   c.gridwidth = 3;
   c.gridx = 0;
   c.gridy = 0;
   tabpanel.add(new JScrollPane(cycletable), c);
   c.ipady = 0;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridx = 0;
   tabpanel.add(buttonAdd, c);
   c.gridx = 1;
   tabpanel.add(buttonDelete, c);
   add(tabpanel);
   // configure buttons
   buttonAdd.setEnabled(true);
   buttonAdd.addActionListener(new ButtonAddListener());
   buttonDelete.setEnabled(true);
   buttonDelete.addActionListener(new ButtonDeleteListener());
   return;
 }
  public ListSelectionDemo() {
    super(new BorderLayout());

    String[] listData = {"one", "two", "three", "four", "five", "six", "seven"};
    String[] columnNames = {"French", "Spanish", "Italian"};
    list = new JList(listData);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    JScrollPane listPane = new JScrollPane(list);

    JPanel controlPane = new JPanel();
    String[] modes = {
      "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION"
    };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);
    comboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
              listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
              listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
              listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
          }
        });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    // Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane =
        new JScrollPane(
            output,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);

    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    // topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(100, 50));
    topHalf.setPreferredSize(new Dimension(100, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    // XXX: next line needed if bottomHalf is a scroll pane:
    // bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
  }
예제 #21
0
  private <T extends Enum<T>> void createControls(JPanel panel, ZrtpConfigureTableModel<T> model) {
    ResourceManagementService resources = NeomediaActivator.getResources();

    final JButton upButton = new JButton(resources.getI18NString("impl.media.configform.UP"));
    upButton.setOpaque(false);

    final JButton downButton = new JButton(resources.getI18NString("impl.media.configform.DOWN"));
    downButton.setOpaque(false);

    Container buttonBar = new TransparentPanel(new GridLayout(0, 1));
    buttonBar.add(upButton);
    buttonBar.add(downButton);

    panel.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));
    panel.setLayout(new GridBagLayout());

    final JTable table = new JTable(model.getRowCount(), 2);
    table.setShowGrid(false);
    table.setTableHeader(null);
    table.setModel(model);
    // table.setFillsViewportHeight(true); // Since 1.6 only - nicer view

    /*
     * The first column contains the check boxes which enable/disable their
     * associated encodings and it doesn't make sense to make it wider than
     * the check boxes.
     */
    TableColumnModel tableColumnModel = table.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth() + 5);
    table.doLayout();

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    panel.add(new JScrollPane(table), constraints);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridwidth = 1;
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    panel.add(buttonBar, constraints);

    ListSelectionListener tableSelectionListener =
        new ListSelectionListener() {
          @SuppressWarnings("unchecked")
          public void valueChanged(ListSelectionEvent event) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getSelectionModel().addListSelectionListener(tableSelectionListener);

    TableModelListener tableListener =
        new TableModelListener() {
          @SuppressWarnings("unchecked")
          public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getModel().addTableModelListener(tableListener);

    tableSelectionListener.valueChanged(null);

    ActionListener buttonListener =
        new ActionListener() {
          @SuppressWarnings("unchecked")
          public void actionPerformed(ActionEvent event) {
            Object source = event.getSource();
            boolean up;
            if (source == upButton) up = true;
            else if (source == downButton) up = false;
            else return;

            int index =
                ((ZrtpConfigureTableModel<T>) table.getModel())
                    .move(table.getSelectedRow(), up, up);
            table.getSelectionModel().setSelectionInterval(index, index);
          }
        };
    upButton.addActionListener(buttonListener);
    downButton.addActionListener(buttonListener);
  }
예제 #22
0
    public DocumentPanel() {
      super(new BorderLayout());

      JLabel lblDocument = new JLabel("Document: " + document.getTitle());
      lblDocument.setBorder(new EtchedBorder());

      textPane = new JTextPane(document);
      textPane.setEditable(false);
      textPane.setMargin(new Insets(5, 20, 5, 5));
      textPane.setMaximumSize(new Dimension(364, 1000000000));
      textPane.setPreferredSize(new Dimension(364, 400));
      textPane.setMinimumSize(new Dimension(364, 10));
      textPane.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              int length = document.getLength();
              int offset = e.getDot();

              if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1);

              Paragraph p = lockManager.getParFromOffset(offset);
              int pOffset = p.getOffset();

              lblCursor.setText(
                  "Document Length="
                      + String.valueOf(length)
                      + ", CaretOffset="
                      + String.valueOf(offset)
                      + ", Paragraph="
                      + p.toString()
                      + ", Offset in Paragraph="
                      + String.valueOf(offset - p.getOffset()));
            }
          });
      Box box = new Box(BoxLayout.X_AXIS);
      box.add(textPane);
      box.add(Box.createGlue());
      box.setBackground(Color.WHITE);
      box.setOpaque(true);
      box.setPreferredSize(new Dimension(600, 10000));

      lblCursor = new JLabel("Cursor");
      lblCursor.setBorder(new EtchedBorder());

      JPanel boxText = new JPanel(new BorderLayout());
      boxText.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxText.add(lblDocument, BorderLayout.NORTH);
      boxText.add(new JScrollPane(box), BorderLayout.CENTER);
      boxText.add(lblCursor, BorderLayout.SOUTH);

      JLabel lblPars = new JLabel("Paragraphs: ");
      lblPars.setBorder(new EtchedBorder());

      parList = new JList();
      parList.setPreferredSize(new Dimension(100, 300));
      parList.setEnabled(false);

      JPanel boxPars = new JPanel(new BorderLayout());
      boxPars.setBorder(new EmptyBorder(5, 5, 5, 5));
      boxPars.add(lblPars, BorderLayout.NORTH);
      boxPars.add(new JScrollPane(parList), BorderLayout.CENTER);

      add(boxText, BorderLayout.CENTER);
      add(boxPars, BorderLayout.EAST);
    }