Пример #1
0
  private Component table() {
    String[] titles = {
      "Year",
      "Starting Balance",
      "Starting Principal",
      "Withdrawals",
      "Appreciation",
      "Deposits",
      "Ending Balance"
    };
    tableModel = new DefaultTableModel(titles, 0);
    for (int i = 0; i < 12800; i++) {
      tableModel.addRow(
          new Integer[] {1900 + i, 10000 + i, 8000 + i, 50 + i, 905 + i, 2000 + i, 12000 + i});
    }

    JTable table = new CustomTable(tableModel);

    int preferredWidth = 0;
    for (int i = 0; i < table.getColumnCount(); i++) {
      int width = packColumn(table, i, 2);
      preferredWidth += width;
    }
    Dimension preferredSize = new Dimension(preferredWidth, 400);
    table.setPreferredScrollableViewportSize(preferredSize);
    this.setMinimumSize(preferredSize);

    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
  }
Пример #2
0
 private Component getTable() {
   if (tableView == null) {
     JTable table = new JTable(getTableModel(), getTableColumnModel());
     JScrollPane scrollPane = new JScrollPane(table);
     table.setPreferredScrollableViewportSize(new Dimension(500, 70));
     tableView = scrollPane;
   }
   return tableView;
 }
Пример #3
0
  // Panel que muestra la tabla
  private Container tabla() {
    JPanel pnl = new JPanel(new GridLayout(2, 0));
    String[] columnNames = {
      "Marca",
      "Modelo",
      "Color",
      "Precio",
      "Clave",
      "Procesador",
      "RAM",
      "HDD",
      "Tarjeta de video",
      "Tarjeta de audio"
    };

    final JTable table = new JTable(getModeloDatos(), columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(470, 340));
    table.setFillsViewportHeight(true);

    JScrollPane scrollPane = new JScrollPane(table);
    pnl.add(scrollPane);
    // Se añaden los botones al panel
    regresar = new JButton("Regresar");
    comprar = new JButton("Comprar");
    buscar = new JButton("Buscar");
    add(regresar);
    add(comprar);
    add(buscar);
    // Event-handles para los botones de Regresar, Comprar y Buscar
    regresar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sistema.mostrarPanel(PanelBase.PANEL_INICIO);
          }
        });
    comprar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            comprar(table);
          }
        });
    buscar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            buscarComputadora(table);
          }
        });
    return pnl;
  }
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      e.printStackTrace();
    }

    Action action = new GloballyContextSensitiveAction("selectAll", "selectAll", "selectAll");
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("Actions");
    menu.add(action);
    menubar.add(menu);

    JToolBar toolbar = new JToolBar();
    toolbar.setRollover(true);
    toolbar.setFloatable(true);
    toolbar.add(action);

    JPanel contents = new JPanel();

    String[] listData = new String[] {"item1", "item2", "item3", "item4", "item5            "};
    JList list = new JList(listData);
    contents.add(new JScrollPane(list));

    JTree tree = new JTree();
    tree.setVisibleRowCount(10);
    contents.add(new JScrollPane(tree));

    JTable table = new JTable(new DefaultTableModel(new String[] {"Name", "Type", "Modified"}, 10));
    table.setPreferredScrollableViewportSize(new Dimension(100, 5 * table.getRowHeight()));
    contents.add(new JScrollPane(table));
    contents.add(new JPanel());

    JFrame frame = new JFrame("Globally Context Sensitive Actions - [email protected]");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menubar);
    frame.getContentPane().add(contents);
    frame.getContentPane().add(toolbar, BorderLayout.NORTH);

    frame.pack();
    frame.show();
  }
Пример #5
0
  /**
   * Return the scroll pane
   *
   * @return JScrollPane
   */
  protected JScrollPane getScrollPane() {
    if (scrollPane == null) {
      scrollPane = new JScrollPane();
      scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      scrollPane.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE);
      scrollPane.setViewportView(getTable());
      scrollPane.setColumnHeaderView(table.getTableHeader());
      scrollPane.addComponentListener(eventHandler);

      tableSize =
          new Dimension(
              getTable().getColumnModel().getTotalColumnWidth(),
              getTable().getModel().getRowCount() * (getTable().getRowHeight()));
      table.setPreferredScrollableViewportSize(tableSize);
      table.setPreferredSize(tableSize);
      table.setMinimumSize(tableSize);
    }
    return scrollPane;
  }
Пример #6
0
  private void loadView() {
    // main views
    mTableModel = new SpreadsheetTableModel();

    mTableView = new JTable(mTableModel);
    mTableView.setRowSelectionAllowed(false);
    mTableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    mTableView.setFillsViewportHeight(true);
    mTableView.setDefaultRenderer(String.class, new ColorCellRenderer(TABLE_CELL_COLOR));
    mTableView.setDefaultEditor(
        String.class, new SpreadsheetCellEditor(mTableView.getDefaultEditor(String.class)));
    mTableView.getSelectionModel().addListSelectionListener(new SpreadsheetSelectionListener());
    mTableView
        .getColumnModel()
        .getSelectionModel()
        .addListSelectionListener(new SpreadsheetSelectionListener());

    JTable rowHeaderTable = new JTable(new RowHeaderTableModel());
    rowHeaderTable.setCellSelectionEnabled(false);
    rowHeaderTable.setPreferredScrollableViewportSize(new Dimension(50, Integer.MAX_VALUE));
    rowHeaderTable.setDefaultRenderer(Object.class, new ColorCellRenderer(ROW_HEADER_COLOR));

    mFormulaTextField = new BindableTextField();
    mFormulaTextField.setEditable(false);
    mFormulaTextField.setFocusable(false);

    JScrollPane scrollView = new JScrollPane(mTableView);
    scrollView.setRowHeaderView(rowHeaderTable);

    add(mFormulaTextField, BorderLayout.BEFORE_FIRST_LINE);
    add(scrollView, BorderLayout.CENTER);

    // helpers

    mFileChooser = new SingleExtensionFileChooser();
    String extension = SpreadsheetPersistenceManager.SPREADSHEET_FILE_EXTENSION;
    mFileChooser.setFileExtension(extension, "Spreadsheets file (." + extension + ")");
  }
  public JComponent createContestantList() {
    JPanel contListPanel = new JPanel();

    MyTableModel contTable = new MyTableModel();

    JTable table = new JTable(contTable);

    table.setPreferredScrollableViewportSize(new Dimension(WIDTH, HEIGHT));
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(true);
    table.setRowHeight(77);

    table.setFont(new Font("Viner Hand ITC", Font.PLAIN, 18));
    table.setForeground(Color.BLUE);
    table.setSelectionForeground(Color.RED);
    table.setSelectionBackground(
        new Color(0, 0, 0, 64)); // When a cell is selected, this entire row is highlighted.

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    contListPanel.add(scrollPane);

    return contListPanel;
  }
Пример #8
0
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
  /** 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;
  }
Пример #10
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;
 }
 /** 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);
 }
Пример #12
0
  public JunctionLinkDataFrame(final JunctionLink jl) {
    super(
        jl.getCurrName() + " properties",
        false, // resizable
        false, // closable
        false, // maximizable
        true); // iconifiable
    // PSRender.onHold();
    super.setBackground(back_color);
    super.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameActivated(InternalFrameEvent e) {
            reload();
            SelectedObject.setSelectedObject(jl);
          }
        });
    PSRender.moveToTop(jl.getBound(), 0.5);
    ml = jl;
    setLocation(50, 50);
    dataModelMain = new HeadTable(jl);
    tableMain = new JTable(dataModelMain);
    tableMain.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    tableMain.setPreferredScrollableViewportSize(new Dimension(500, 20));
    //        tableMain.setBackground(back_color);

    // code
    TableColumn column_code = tableMain.getColumn("Code");
    DefaultTableCellRenderer rendererCode = new DefaultTableCellRenderer();
    rendererCode.setToolTipText("Enter new code for this path");
    column_code.setCellRenderer(rendererCode);
    column_code.setCellEditor(new TextFieldEditor());
    // name
    TableColumn column_name = tableMain.getColumn("Name");
    LanguageButtonRender render_name = new LanguageButtonRender();
    render_name.setToolTipText("Path name. Press for change name");
    column_name.setCellRenderer(render_name);
    LanguageButtonEditor editor_name = new LanguageButtonEditor(new JCheckBox());
    column_name.setCellEditor(editor_name);
    // junction 1
    TableColumn column_junc_1 = tableMain.getColumn("Junction 1");
    MLButtonRenderer rendererJunc_1 = new MLButtonRenderer();
    rendererJunc_1.setToolTipText("Code of first Junction, click for open properties");
    column_junc_1.setCellRenderer(rendererJunc_1);
    MLButtonEditor editorJunc = new MLButtonEditor(new JCheckBox());
    column_junc_1.setCellEditor(editorJunc);
    // junction 2
    TableColumn column_junc_2 = tableMain.getColumn("Junction 2");
    MLButtonRenderer rendererJunc_2 = new MLButtonRenderer();
    rendererJunc_2.setToolTipText("Code of second Junction, click for open properties");
    column_junc_2.setCellRenderer(rendererJunc_2);
    column_junc_2.setCellEditor(editorJunc);
    // type
    JComboBox comboBoxType = new JComboBox();
    String roadNames[] = jl.getTypeNames();
    for (int i = 0, len = roadNames.length; i < len; i++) {
      comboBoxType.addItem(roadNames[i]);
    }
    TableColumn column_type = tableMain.getColumn("Type");
    DefaultTableCellRenderer rendererType = new DefaultTableCellRenderer();
    rendererType.setToolTipText("To change road type click for combo box");
    column_type.setCellRenderer(rendererType);
    column_type.setCellEditor(new DefaultCellEditor(comboBoxType));
    // legth
    TableColumn column_length = tableMain.getColumn("Length");
    DefaultTableCellRenderer rendererLen = new DefaultTableCellRenderer();
    rendererLen.setToolTipText("The path length in meters");
    column_length.setCellRenderer(rendererLen);

    scrollpaneMain = new JScrollPane(tableMain);
    scrollpaneMain.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollpaneMain.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    scrollpaneMain.setPreferredSize(new Dimension(500, 50));

    Container contentPane = super.getContentPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    contentPane.setLayout(gridbag);

    c.ipady = 0; // make this component tall
    c.weightx = 0.5;
    c.gridwidth = 4;
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(scrollpaneMain, c);
    //        scrollpaneMain.setBackground(back_color);
    //        scrollpaneMain.setForeground(back_color);
    contentPane.add(scrollpaneMain);

    TableModel dataModelPoints = new PointTableModel(jl);
    tablePoints = new JTable(dataModelPoints);
    tablePoints.setPreferredScrollableViewportSize(
        new Dimension(200, dataModelPoints.getRowCount() * tablePoints.getRowHeight()));
    ListModel lm =
        new AbstractListModel() {
          public int getSize() {
            return 1000;
          }

          public Object getElementAt(int index) {
            return "" + index;
          }
        };
    JList rowHeader = new JList(lm);
    rowHeader.setFixedCellWidth(20);

    rowHeader.setFixedCellHeight(tablePoints.getRowHeight());
    // + tablePoints.getRowMargin());

    rowHeader.setCellRenderer(new RowHeaderRenderer(tablePoints));

    scrollPanePoints = new JScrollPane(tablePoints);
    scrollPanePoints.setWheelScrollingEnabled(true);
    scrollPanePoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPanePoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    int mh;
    if (dataModelPoints.getRowCount() * tablePoints.getRowHeight() > 100) {
      mh = 100;
    } else {
      mh = dataModelPoints.getRowCount() * tablePoints.getRowHeight();
    }
    scrollPanePoints.setPreferredSize(new Dimension(200, mh));
    scrollPanePoints.setRowHeaderView(rowHeader);

    c.ipadx = 200;
    c.weightx = 0.5;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(scrollPanePoints, c);
    //        scrollPanePoints.setBackground(back_color);
    contentPane.add(scrollPanePoints);

    button_ok = new JButton("Ok");
    button_ok.addActionListener(this);
    JPanel buttonPane = new JPanel(null);
    buttonPane.setPreferredSize(new Dimension(500, 100));
    button_ok.setBounds(205, 40, 90, 40);
    buttonPane.add(button_ok);
    c.ipady = 10; // make this component tall
    c.ipadx = 10;
    c.weightx = 0.5;
    c.gridwidth = 4;
    c.gridx = 2;
    c.gridy = 2;
    gridbag.setConstraints(buttonPane, c);
    buttonPane.setBackground(back_color);
    contentPane.add(buttonPane);

    super.pack();
    super.setVisible(true);

    // MapApplication.getDesktop().setSelectedFrame(this);

  }
  public ItensVendidos() {
    super("Itens Vendidos");
    JButton imprimir;

    final DefaultTableModel modelo = new DefaultTableModel();

    // constrói a tabela
    JTable tabela = new JTable(modelo);

    // Cria duas colunas
    modelo.addColumn("Código");
    modelo.addColumn("Vendedor");
    modelo.addColumn("Produto");
    modelo.addColumn("Quantidade");

    imprimir = new JButton("Imprimir");
    imprimir.setBounds(100, 450, 30, 24);

    // exibe os dados da tabela MySQL
    // Conexao banco = new Conexao();
    String retorno = "erro";
    try {
      // Connection ExConn = (Connection) banco.abrirBDconn();
      Class.forName("com.mysql.jdbc.Driver");
      Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/banco", "root", "");
      Statement stmt = conexao.createStatement();

      // procedimentos para obter os dados de uma tabela

      String query = "SELECT * FROM venda2";
      ResultSet rs = stmt.executeQuery(query);

      while (rs.next()) {
        int id = rs.getInt("idVendedor");
        String nome = rs.getString("nomeVendedor");
        String produto = rs.getString("produto");
        int qtd = rs.getInt("qtd");
        modelo.addRow(new Object[] {new Integer(id), nome, produto, new Integer(qtd)});
      }

      // fim procedimento para obter os dados
    } catch (SQLException ex) {
      System.out.println("SQLException: " + ex.getMessage());
      System.out.println("SQLState: " + ex.getSQLState());
      System.out.println("VendorError: " + ex.getErrorCode());
    } catch (Exception e) {
      System.out.println("Problemas ao tentar conectar com o banco de dados");
    }
    // fim MySQL

    tabela.setPreferredScrollableViewportSize(new Dimension(350, 50));

    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    JScrollPane scrollPane = new JScrollPane(tabela);
    c.add(scrollPane);
    c.add(imprimir);

    setSize(400, 300);
    setVisible(true);
  }
 /** 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;
 }
Пример #15
0
  SwingTableDemo() {

    // Create a new JFrame container.
    JFrame jfrm = new JFrame("JTable Demo");

    // Specify FlowLayout for the layout manager.
    jfrm.setLayout(new FlowLayout());

    // Give the frame an initial size.
    jfrm.setSize(460, 180);

    // Terminate the program when the user closes the application.
    jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create a table that displays order data.
    jtabOrders = new JTable(data, headings);

    // Wrap the table in a scroll pane.
    JScrollPane jscrlp = new JScrollPane(jtabOrders);

    // Set the scrollable viewport size.
    jtabOrders.setPreferredScrollableViewportSize(new Dimension(420, 62));

    // Create the radio buttons that determine
    // what type of selections are allowed.
    jrbRows = new JRadioButton("Select Rows", true);
    jrbColumns = new JRadioButton("Select Columns");
    jrbCells = new JRadioButton("Select Cells");

    // Add the radio buttons to a group.
    ButtonGroup bg = new ButtonGroup();
    bg.add(jrbRows);
    bg.add(jrbColumns);
    bg.add(jrbCells);

    // Radio button events are handled in common by the
    // actionPerformed() method implemented by TableDemo.
    jrbRows.addActionListener(this);
    jrbColumns.addActionListener(this);
    jrbCells.addActionListener(this);

    // Create the Single Selection Mode check box.
    // When checked, only single selections are allowed.
    jcbSingle = new JCheckBox("Single Selection Mode");

    // Add item listener for jcbSingle.
    jcbSingle.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent ie) {
            if (jcbSingle.isSelected())
              // Allow single selections.
              jtabOrders.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            else
              // Allow multiple selections.
              jtabOrders.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
          }
        });

    // Add the components to the content pane.
    jfrm.add(jscrlp);
    jfrm.add(jrbRows);
    jfrm.add(jrbColumns);
    jfrm.add(jrbCells);
    jfrm.add(jcbSingle);

    // Display the frame.
    jfrm.setVisible(true);
  }
  public AutoFocusator() {
    super(new BorderLayout());

    taskList = new TaskList();
    Task task0 = new Task("Use right click to change the states of the tasks.");
    taskList.add(task0);
    Task task1 = new Task("Just play araound with this small app.");
    taskList.add(task1);
    Task task2 = new Task("Check http://sourceforge.net/projects/autofocusator/");
    taskList.add(task2);

    // task1.setState(State.crossed);
    // task0.setState(State.dismissed);

    table = new JTable(taskList);
    table.setPreferredScrollableViewportSize(new Dimension(500, 700));
    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(0).setPreferredWidth(300);
    table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(true);

    table.getColumnModel().getColumn(0).setCellRenderer(new TaskRenderer());
    // TableCellRenderer renderer = table.getColumnModel().getColumn(0).getCellRenderer();
    // double height = ((TaskRenderer)renderer).getRendererHeight();

    // @todo: The height should be set dependent on the content
    table.setRowHeight(28);

    table.getModel().addTableModelListener(this);

    toolBar = new JToolBar("Autofocusator - Toolbar");

    JButton buttonAddTask = new JButton("Add a Task", new ImageIcon(loadPics("res/list-add.png")));
    buttonAddTask.setActionCommand("addTask");
    buttonAddTask.addActionListener(this);
    toolBar.add(buttonAddTask);

    JButton buttonDeleteTask =
        new JButton("Delete a Task", new ImageIcon(loadPics("res/list-remove.png")));
    buttonDeleteTask.setActionCommand("deleteTask");
    buttonDeleteTask.addActionListener(this);
    toolBar.add(buttonDeleteTask);

    JButton buttonSave = new JButton("Save", new ImageIcon(loadPics("res/document-save-as.png")));
    buttonSave.setActionCommand("save");
    buttonSave.addActionListener(this);
    toolBar.add(buttonSave);

    JButton buttonOpen = new JButton("open", new ImageIcon(loadPics("res/document-open.png")));
    buttonOpen.setActionCommand("open");
    buttonOpen.addActionListener(this);
    toolBar.add(buttonOpen);

    add(toolBar, BorderLayout.NORTH);

    contextMenu = new JPopupMenu();
    JMenuItem contextMenuItem;
    contextMenuItem = new JMenuItem("delete Task");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("deleteTask");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("add Task");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("addTask");
    contextMenu.add(contextMenuItem);

    contextMenu.addSeparator();

    contextMenuItem = new JMenuItem("cross");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("cross");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("dismiss");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("dismiss");
    contextMenu.add(contextMenuItem);

    contextMenuItem = new JMenuItem("worked on");
    contextMenuItem.addActionListener(this);
    contextMenuItem.setActionCommand("workedOn");
    contextMenu.add(contextMenuItem);

    fileChooser = new JFileChooser();
    FileFilter filter = new FileNameExtensionFilter("XML File", "xml");
    fileChooser.addChoosableFileFilter(filter);

    table.addMouseListener(this);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane, BorderLayout.CENTER);
  }
Пример #17
0
  public UReservacion(String i, String n, String a, String c) {
    this.Identificacion = i;
    this.Nombre = n;
    this.Apellido = a;
    this.Correo = c;
    setTitle("Sistema de Registro");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    esquema = new BorderLayout();
    panelnorte = new JPanel();
    panelcentro = new JPanel(new BorderLayout());
    panelBusqueda = new JPanel(new FlowLayout());
    panelsur = new JPanel();

    dtmesa = mesa.listarMesa("");
    String[] columNames = {"Numero", "Capacidad", "Fumador", "Estado"};
    dtmMesa = new DefaultTableModel(dtmesa, columNames);
    jtbMesa = new JTable(dtmMesa);
    jtbMesa.setEnabled(false);
    jtbMesa.setPreferredScrollableViewportSize(new Dimension(700, 120));
    jtbMesa.setAutoCreateRowSorter(true);
    spMesa = new JScrollPane(jtbMesa);
    lbltitulo = new JLabel("Mesas disponibles");
    lbltitulo.setFont(new Font("Verdana", Font.BOLD, 14));

    lblnomproducto = new JLabel("Ingrese numero de mesa:");
    txtNumMesa = new JTextField(5);
    btnRegistrar = new JButton("Registrar");

    panelBusqueda.add(lblnomproducto);
    panelBusqueda.add(txtNumMesa);

    lblAcompaantes = new JLabel("Personas:");
    panelBusqueda.add(lblAcompaantes);

    textCompa = new JTextField();
    panelBusqueda.add(textCompa);
    textCompa.setColumns(5);

    lblNewLabel_1 = new JLabel("Fecha");
    panelBusqueda.add(lblNewLabel_1);

    txtAaaammdd = new JTextField();
    txtAaaammdd.setText("AAAA-MM-DD");
    txtAaaammdd.setToolTipText("");
    panelBusqueda.add(txtAaaammdd);
    txtAaaammdd.setColumns(10);

    lblHora = new JLabel("Hora");
    panelBusqueda.add(lblHora);

    txtHhmmss = new JTextField();
    txtHhmmss.setText("HH-MM-SS");
    panelBusqueda.add(txtHhmmss);
    txtHhmmss.setColumns(10);

    lblNewLabel = new JLabel("¿Vista al mar?");
    panelBusqueda.add(lblNewLabel);

    checkBox = new JCheckBox("");
    checkBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            checkBox.setEnabled(false);
          }
        });
    panelBusqueda.add(checkBox);
    panelBusqueda.add(btnRegistrar);

    getContentPane().setLayout(esquema);

    panelnorte.add(lbltitulo);
    panelcentro.add(panelBusqueda, BorderLayout.NORTH);
    panelcentro.add(spMesa, BorderLayout.CENTER);

    getContentPane().add(panelnorte, BorderLayout.NORTH);
    getContentPane().add(panelcentro, BorderLayout.CENTER);
    getContentPane().add(panelsur, BorderLayout.SOUTH);

    this.pack();
    setResizable(false);
    setLocationRelativeTo(this.getParent());
    setVisible(true);
    mostrarProductos("Libre");
  }