Java Code Examples for javax.swing.JTable#addMouseListener()

The following examples show how to use javax.swing.JTable#addMouseListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIOptionCharSetDialog.java    From PacketProxy with Apache License 2.0 6 votes vote down vote up
private JScrollPane tableScrollPane(){
	table_model = new CharSetsTableModel(getTableDataWithAvailableCharsets(), columns);
	JTable table = new JTable(table_model);
	TableColumn col = table.getColumnModel().getColumn(0);
	col.setMinWidth(50);
	col.setMaxWidth(50);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			super.mousePressed(e);
			if(0==table.getSelectedColumn()){
				return;
			}
			table.setValueAt(!(Boolean)table.getValueAt(table.getSelectedRow(), 0), table.getSelectedRow(),0);
		}
	});
	sorter = new TableRowSorter<CharSetsTableModel>(table_model);
	table.setRowSorter(sorter);
	JScrollPane jscrollPane = new JScrollPane(table);

	return jscrollPane;
}
 
Example 2
Source File: TableUtils.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static void setupTable(JTable table, int selectionModel, TableModel model, MouseListener mouseListener,
                              int... colWidth) {
  table.setFillsViewportHeight(true);
  table.setFont(StyleConstants.FONT_MONOSPACE_LARGE);
  table.setRowHeight(StyleConstants.TABLE_ROW_HEIGHT_DEFAULT);
  table.setShowHorizontalLines(true);
  table.setShowVerticalLines(false);
  table.setGridColor(Color.lightGray);
  table.getColumnModel().setColumnMargin(StyleConstants.TABLE_COLUMN_MARGIN_DEFAULT);
  table.setRowMargin(StyleConstants.TABLE_ROW_MARGIN_DEFAULT);
  table.setSelectionMode(selectionModel);
  if (model != null) {
    table.setModel(model);
  } else {
    table.setModel(new DefaultTableModel());
  }
  if (mouseListener != null) {
    table.removeMouseListener(mouseListener);
    table.addMouseListener(mouseListener);
  }
  for (int i = 0; i < colWidth.length; i++) {
    table.getColumnModel().getColumn(i).setMinWidth(colWidth[i]);
    table.getColumnModel().getColumn(i).setMaxWidth(colWidth[i]);
  }
}
 
Example 3
Source File: ListVendorPane.java    From OpERP with MIT License 6 votes vote down vote up
public ListVendorPane() {
	pane = new JPanel();
	pane.setLayout(new MigLayout("fill"));
	table = new JTable(tableModel);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {
				Vendor vendor = tableModel.getRow(table.getSelectedRow());

				vendorController.showDetails(vendor);

			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.add(scrollPane, "grow");
}
 
Example 4
Source File: ListEmployeePane.java    From OpERP with MIT License 6 votes vote down vote up
public ListEmployeePane() {
	pane = new JPanel();
	pane.setLayout(new MigLayout("fill"));
	table = new JTable(tableModel);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (SwingUtilities.isLeftMouseButton(e)
					&& e.getClickCount() == 2
					&& table.getSelectedRow() != -1) {
				Employee employee = tableModel.getRow(table
						.getSelectedRow());

				employeeController.showDetails(employee);

			}
		}
	});

	final JScrollPane scrollPane = new JScrollPane(table,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.add(scrollPane, "grow");
}
 
Example 5
Source File: KeysTableView.java    From pgptool with GNU General Public License v3.0 6 votes vote down vote up
private JScrollPane initTableComponent() {
	table = new JTable();

	// Adjust some visual appearence
	table.setRowHeight(22);
	table.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

	// Add listeners
	selectionModel = new DefaultListSelectionModel();
	selectionModel.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
	selectionModel.addListSelectionListener(rowSelectionListener);
	table.setSelectionModel(selectionModel);
	table.addMouseListener(listMouseListener);
	initTableKeyListener();

	// Envelope in scrollpane
	scrollPane = new JScrollPane();
	scrollPane.addMouseListener(listMouseListener);
	scrollPane.setViewportView(table);
	return scrollPane;
}
 
Example 6
Source File: ButtonColumn.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create the ButtonColumn to be used as a renderer and editor. The renderer and editor will
 * automatically be installed on the TableColumn of the specified column.
 *
 * @param table the table containing the button renderer/editor
 * @param action the Action to be invoked when the button is invoked
 * @param column the column to which the button renderer/editor is added
 */
private ButtonColumn(final JTable table, final int column, final Action action) {
  this.table = table;
  this.action = action;

  renderButton = new JButton();
  editButton = new JButton();
  editButton.setFocusPainted(false);
  editButton.addActionListener(this);
  originalBorder = editButton.getBorder();
  setFocusBorder(new LineBorder(Color.BLUE));

  final TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
}
 
Example 7
Source File: UITools.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public static <V> void initCardToolTipTable(final JTable table, final int cardPos, Callable<V> dblClick) {
	final JPopupMenu popUp = new JPopupMenu();
	table.addMouseListener(new MouseAdapter() {
		
		@Override
		public void mouseClicked(MouseEvent e) 
		{
				e.consume();
				if(e.getClickCount()==2 && dblClick!=null)
				{
				
					ThreadManager.getInstance().submitCallable(dblClick,"initTooltip");
				}
				else 
				{
					
					int row = table.rowAtPoint(e.getPoint());
					MagicCardDetailPanel pane = new MagicCardDetailPanel();
					pane.enableThumbnail(true);
					table.setRowSelectionInterval(row, row);
					
					try {
							MagicCard mc = UITools.getTableSelection(table,cardPos);
							pane.setMagicCard(mc);
							
							popUp.setBorder(new LineBorder(Color.black));
							popUp.setVisible(false);
							popUp.removeAll();
							popUp.setLayout(new BorderLayout());
							popUp.add(pane, BorderLayout.CENTER);
							popUp.show(table, e.getX()+5, e.getY()+5);
							popUp.setVisible(true);
	
						} catch (IndexOutOfBoundsException ex) {
							logger.error(ex);
						} 
			}
		}
	});
}
 
Example 8
Source File: TreesPanel.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TreesPanel(MainFrame frame, PartitionDataList dataList) {

		this.frame = frame;
		this.dataList = dataList;

		treesTable = new JTable();
		treesTable.getTableHeader().setReorderingAllowed(false);
		treesTable.addMouseListener(new JTableButtonMouseListener(treesTable));

		treesTableModel = new TreesTableModel(this.dataList, this.frame);
		treesTable.setModel(treesTableModel);

		setLayout(new BorderLayout());

		scrollPane = new JScrollPane(treesTable,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
				JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		RowNumberTable rowNumberTable = new RowNumberTable(treesTable);
		scrollPane.setRowHeaderView(rowNumberTable);
		scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,
				rowNumberTable.getTableHeader());
		scrollPane.getViewport().setOpaque(false);
		add(scrollPane, BorderLayout.CENTER);

		setTreesColumn(this.dataList);
		setTaxaSetColumn(this.dataList);

		column = treesTable.getColumnModel().getColumn(
				TreesTableModel.TAXA_COUNT_INDEX);
		column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
				new Insets(0, 2, 0, 2)));

		ActionPanel actionPanel = new ActionPanel(false);
		actionPanel.setAddAction(addTreeAction);
		actionPanel.setRemoveAction(removeTreeAction);
		add(actionPanel, BorderLayout.SOUTH);

		setTrees();

	}
 
Example 9
Source File: SimpleTableDemo.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public SimpleTableDemo() {
    super(new GridLayout(1, 0));

    String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    Object[][] data = { { "Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false) },
            { "John", "Doe", "Rowing", new Integer(3), new Boolean(true) },
            { "Sue", "Black", "Knitting", new Integer(2), new Boolean(false) },
            { "Jane", "White", "Speed reading", new Integer(20), new Boolean(true) },
            { "Joe", "Brown", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

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

    // Add the scroll pane to this panel.
    add(scrollPane);
}
 
Example 10
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JScrollPane createVariablesTable(final String labelName) {
    variablesTable = new JTable();
    variablesTable.setName(labelName);
    variablesTable.setRowSelectionAllowed(true);
    bindingCtx.bind("variables", new VariablesTableAdapter(variablesTable));
    bindingCtx.bindEnabledState("variables", false, "updateMode", true);
    variablesTable.addMouseListener(createExpressionEditorMouseListener(variablesTable, false));

    final JTableHeader tableHeader = variablesTable.getTableHeader();
    tableHeader.setName(labelName);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(true);

    final TableColumnModel columnModel = variablesTable.getColumnModel();
    columnModel.setColumnSelectionAllowed(false);

    final TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(100);
    nameColumn.setCellRenderer(new TCR());

    final TableColumn expressionColumn = columnModel.getColumn(1);
    expressionColumn.setPreferredWidth(400);
    expressionColumn.setCellRenderer(new TCR());
    final ExprEditor exprEditor = new ExprEditor(false);
    expressionColumn.setCellEditor(exprEditor);
    bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final boolean enabled = Boolean.FALSE.equals(evt.getNewValue());
            exprEditor.button.setEnabled(enabled);
        }
    });

    final JScrollPane scrollPane = new JScrollPane(variablesTable);
    scrollPane.setName(labelName);
    scrollPane.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, 150));

    return scrollPane;
}
 
Example 11
Source File: Main_CustomersFrame.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
public Main_CustomersFrame() {

        this.setAutoscrolls(true);
        this.setMinimumSize(new Dimension(800, 600));
        /*make it default size of frame maximized */
        this.setMaximumSize(new Dimension(1000, 900));
        this.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
        setLayout(new BorderLayout(0, 0));

        bean = LocaleBean.getInstance();
        loggingEngine = LoggingEngine.getInstance();
        componentOrientation = new ChangeComponentOrientation();
        componentOrientation.setThePanel(this);

        searchPanel.setDoubleBuffered(false);
        searchPanel.setAutoscrolls(true);
        add(searchPanel, BorderLayout.NORTH);
        searchPanel.setPreferredSize(new Dimension(10, 30));

        lblTableFilter = new JLabel("Type to search : ");
        lblTableFilter.setForeground(new Color(178, 34, 34));
        lblTableFilter.setSize(new Dimension(130, 25));
        lblTableFilter.setPreferredSize(new Dimension(130, 22));
        lblTableFilter.setHorizontalTextPosition(SwingConstants.CENTER);
        lblTableFilter.setAutoscrolls(true);
        lblTableFilter.setHorizontalAlignment(SwingConstants.LEFT);
        lblTableFilter.setFont(new Font("Dialog", Font.BOLD, 15));

        searchFilterField = new JTextField();
        searchFilterField.setDragEnabled(true);
        searchFilterField.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(0, 191, 255), null, null, null));
        searchFilterField.setPreferredSize(new Dimension(200, 22));
        searchFilterField.setIgnoreRepaint(true);
        searchFilterField.setColumns(10);
        searchFilterField.setFont(new Font("Dialog", Font.BOLD, 13));
        searchFilterField.setHorizontalAlignment(SwingConstants.LEFT);
        GroupLayout gl_searchPanel = new GroupLayout(searchPanel);
        gl_searchPanel.setHorizontalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(ComponentPlacement.RELATED)
                                .addComponent(searchFilterField, GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                                .addGap(118))
        );
        gl_searchPanel.setVerticalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addGap(5)
                                .addGroup(gl_searchPanel.createParallelGroup(Alignment.BASELINE)
                                        .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(searchFilterField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                .addContainerGap())
        );
        searchPanel.setLayout(gl_searchPanel);

        searchFilterField.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {

                final String searchedWord = searchFilterField.getText();
                filter(searchedWord);

            }
        });

        scrollPane = new JScrollPane();
        add(scrollPane);

        //populate main table model with custom method
        populateMainTable(model);

        customerTable = new JTable(model);
        customerTable.setFillsViewportHeight(true);
        customerTable.setRowSelectionAllowed(true);

        THR.setHorizontalAlignment(SwingConstants.CENTER);

        customerTable.setDefaultRenderer(Object.class, renderer);
        customerTable.getTableHeader().setDefaultRenderer(THR);
        customerTable.setFont(new Font("Dialog", Font.PLAIN, 14));
        customerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        customerTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        customerTable.setBackground(new Color(245, 245, 245));
        customerTable.addMouseListener(openCustomerListener());
        scrollPane.setViewportView(customerTable);

        //change component orientation with locale.
        if (bean.getLocale().toString().equals("ar_IQ")) {
            componentOrientation.changeOrientationOfJPanelToRight();
        } else {
            componentOrientation.changeOrientationOfJPanelToLeft();
        }
        //inject action event to Customers detail window to save all changes
        custWindow.setActionListener(saveChanges());
        this.setVisible(true);
    }
 
Example 12
Source File: MapDemo.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public SimpleTableDemo(LazyReplicatedMap<String,StringBuilder> map) {
    super();
    this.map = map;

    this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    //final JTable table = new JTable(data, columnNames);
    table = new JTable(dataModel);

    table.setPreferredScrollableViewportSize(new Dimension(WIDTH, 150));
    for ( int i=0; i<table.getColumnCount(); i++ ) {
        TableColumn tm = table.getColumnModel().getColumn(i);
        tm.setCellRenderer(new ColorRenderer());
    }


    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //setLayout(new GridLayout(5, 0));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

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

    //Add the scroll pane to this panel.
    add(scrollPane);

    //create a add value button
    JPanel addpanel = new JPanel();
    addpanel.setPreferredSize(new Dimension(WIDTH,30));
    addpanel.add(createButton("Add","add"));
    addpanel.add(txtAddKey);
    addpanel.add(txtAddValue);
    addpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(addpanel);

    //create a remove value button
    JPanel removepanel = new JPanel( );
    removepanel.setPreferredSize(new Dimension(WIDTH,30));
    removepanel.add(createButton("Remove","remove"));
    removepanel.add(txtRemoveKey);
    removepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(removepanel);

    //create a change value button
    JPanel changepanel = new JPanel( );
    changepanel.add(createButton("Change","change"));
    changepanel.add(txtChangeKey);
    changepanel.add(txtChangeValue);
    changepanel.setPreferredSize(new Dimension(WIDTH,30));
    changepanel.setMaximumSize(new Dimension(WIDTH,30));
    add(changepanel);


    //create sync button
    JPanel syncpanel = new JPanel( );
    syncpanel.add(createButton("Synchronize","sync"));
    syncpanel.add(createButton("Replicate","replicate"));
    syncpanel.add(createButton("Random","random"));
    syncpanel.setPreferredSize(new Dimension(WIDTH,30));
    syncpanel.setMaximumSize(new Dimension(WIDTH,30));
    add(syncpanel);


}
 
Example 13
Source File: PlacemarkManagerTopComponent.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {
    setLayout(new BorderLayout());
    placemarkTable = new JTable(placemarkTableModel);
    placemarkTable.setRowSorter(new TableRowSorter<>(placemarkTableModel));
    placemarkTable.setName("placemarkTable");
    placemarkTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    placemarkTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    placemarkTable.setRowSelectionAllowed(true);
    // IMPORTANT: We set ReorderingAllowed=false, because we export the
    // table model AS IS to a flat text file.
    placemarkTable.getTableHeader().setReorderingAllowed(false);

    ToolTipSetter toolTipSetter = new ToolTipSetter();
    placemarkTable.addMouseMotionListener(toolTipSetter);
    placemarkTable.addMouseListener(toolTipSetter);
    placemarkTable.addMouseListener(new PopupListener());
    placemarkTable.getSelectionModel().addListSelectionListener(new PlacemarkTableSelectionHandler());
    updateTableModel();

    final TableColumnModel columnModel = placemarkTable.getColumnModel();
    columnModel.addColumnModelListener(new ColumnModelListener());

    JScrollPane tableScrollPane = new JScrollPane(placemarkTable);
    JPanel mainPane = new JPanel(new BorderLayout(4, 4));
    mainPane.add(tableScrollPane, BorderLayout.CENTER);

    buttonPane = new PlacemarkManagerButtons(this);

    JPanel content = new JPanel(new BorderLayout(4, 4));
    content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    content.add(BorderLayout.CENTER, mainPane);
    content.add(BorderLayout.EAST, buttonPane);
    Component southExtension = getSouthExtension();
    if (southExtension != null) {
        content.add(BorderLayout.SOUTH, southExtension);
    }
    content.setPreferredSize(new Dimension(420, 200));

    setCurrentView(snapApp.getSelectedProductSceneView());
    setProduct(snapApp.getSelectedProduct(VIEW));
    snapApp.getSelectionSupport(ProductSceneView.class).addHandler(new ProductSceneViewSelectionChangeHandler());
    snapApp.getProductManager().addListener(new ProductRemovedListener());
    updateUIState();
    add(content, BorderLayout.CENTER);
}
 
Example 14
Source File: BotCWTableModel.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * Configure a column model.
 * 
 * @param table Table for which the column model should be configured.
 */
public void configureColumnModel(JTable table) {
  if (table == null) {
    return;
  }
  TableColumnModel model = table.getColumnModel();
  TableColumn column = null;

  column = model.getColumn(COLUMN_BOT);
  column.setMinWidth(20);
  column.setPreferredWidth(20);
  column.setMaxWidth(20);
  column.setCellRenderer(
      new BooleanIconCellRenderer("commons-approve-icon.png", null));
  column.setHeaderRenderer(
      new IconCellRenderer("commons-nuvola-apps-kcmsystem.png"));

  column = model.getColumn(COLUMN_DESCRIPTION);
  column.setMinWidth(100);

  column = model.getColumn(COLUMN_FIX);
  column.setMinWidth(20);
  column.setPreferredWidth(20);
  column.setMaxWidth(20);
  column.setHeaderRenderer(
      new IconCellRenderer("commons-nuvola-apps-kcmsystem.png"));

  column = model.getColumn(COLUMN_LIST);
  column.setMinWidth(20);
  column.setPreferredWidth(20);
  column.setMaxWidth(20);
  column.setHeaderRenderer(
      new IconCellRenderer("gnome-logviewer.png"));

  column = model.getColumn(COLUMN_NUMBER);
  column.setMinWidth(40);
  column.setPreferredWidth(40);
  column.setMaxWidth(40);

  table.addMouseListener(EventHandler.create(
      MouseListener.class, this, "mouseClicked", "", "mouseClicked"));
}
 
Example 15
Source File: CGraphSelectionDialog.java    From binnavi with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the GUI of the dialog.
 *
 * @param views The views to be shown in the table.
 */
private void createGui(final List<INaviView> views) {
  setLayout(new BorderLayout());

  final JTextArea field = new JTextArea(
      "The debugger stopped at an instruction that does not belong to any open graphs.\nPlease select a graph from the list to continue debugging.");

  field.setEditable(false);

  add(field, BorderLayout.NORTH);

  m_table = new JTable(new CGraphSelectionTableModel(views));

  m_table.addMouseListener(m_listener);

  add(new JScrollPane(m_table), BorderLayout.CENTER);

  final CPanelTwoButtons panel = new CPanelTwoButtons(m_listener, "OK", "Cancel");

  add(panel, BorderLayout.SOUTH);

  setSize(500, 300);
}
 
Example 16
Source File: ReqTabPanel.java    From rest-client with Apache License 2.0 4 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param  name
* @return void 
* @throws
 */
private void init(String name)
{
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, 0));

    List<String> colNames = new ArrayList<String>();
    colNames.add(name);
    colNames.add(RESTConst.VALUE);

    tabMdl = new TabModel(colNames);
    tab = new JTable(tabMdl);
    tab.setFillsViewportHeight(true);
    tab.setAutoCreateRowSorter(false);
    tab.getTableHeader().setReorderingAllowed(false);
    tab.addMouseListener(ma);
    tab.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    miRmSel = new JMenuItem(RESTConst.RM_SEL);
    miRmSel.setName(RESTConst.RM_SEL);
    miRmSel.addActionListener(this);

    miRmAll = new JMenuItem(RESTConst.RM_ALL);
    miRmAll.setName(RESTConst.RM_ALL);
    miRmAll.addActionListener(this);

    pm = new JPopupMenu();
    pm.add(miRmSel);
    pm.add(miRmAll);
    
    txtFldKey = new JTextField(RESTConst.FIELD_SIZE);
    txtFldVal = new JTextField(RESTConst.FIELD_SIZE);

    lblKey = new JLabel(RESTConst.KEY + ":");
    lblVal = new JLabel(RESTConst.VALUE + ":");

    iconAdd = UIUtil.getIcon(RESTConst.ICON_ADD);
    iconDel = UIUtil.getIcon(RESTConst.ICON_DEL);

    btnAdd = new JButton(iconAdd);
    btnAdd.setName(RESTConst.ADD);
    btnAdd.setToolTipText(RESTConst.ADD + " " + name);
    btnAdd.addActionListener(this);

    btnDel = new JButton(iconDel);
    btnDel.setName(RESTConst.DELETE);
    btnDel.setToolTipText(RESTConst.DELETE + " " + name);
    btnDel.addActionListener(this);

    JPanel pnlNorth = new JPanel();
    pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
    pnlNorth.add(lblKey);
    pnlNorth.add(txtFldKey);
    pnlNorth.add(lblVal);
    pnlNorth.add(txtFldVal);
    pnlNorth.add(btnAdd);
    pnlNorth.add(btnDel);

    this.add(pnlNorth, BorderLayout.NORTH);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new GridLayout(1, 1));
    JScrollPane spHdr = new JScrollPane(tab);
    pnlCenter.add(spHdr);

    this.add(pnlCenter, BorderLayout.CENTER);
}
 
Example 17
Source File: HeaderlessColumnResizer.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public HeaderlessColumnResizer(JTable table) {
  this.table = table;
  table.addMouseListener(this);
  table.addMouseMotionListener(this);
}
 
Example 18
Source File: HistView.java    From rest-client with Apache License 2.0 4 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param  name
* @return void 
* @throws
 */
private void init()
{
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));
    this.setBorder(BorderFactory.createEmptyBorder(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));

    List<String> colNames = new ArrayList<String>();
    colNames.add(RESTConst.ID);
    colNames.add(RESTConst.REQUEST);
    colNames.add(RESTConst.RESPONSE);
    colNames.add(RESTConst.DATE);
    colNames.add(RESTConst.TIME);
    colNames.add(RESTConst.DESCR);

    tabMdl = new TabModel(colNames);
    tabMdl.setCellEditable(false);
    tab = new JTable(tabMdl);
    tab.setFillsViewportHeight(true);
    tab.setAutoCreateRowSorter(false);
    tab.getTableHeader().setReorderingAllowed(false);
    tab.addMouseListener(ma);
    tab.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tab.getSelectionModel().addListSelectionListener(this);
    UIUtil.setHistTabWidth(tab);

    miRmSel = new JMenuItem(RESTConst.RM_SEL);
    miRmSel.setName(RESTConst.RM_SEL);
    miRmSel.addActionListener(this);

    miRmAll = new JMenuItem(RESTConst.RM_ALL);
    miRmAll.setName(RESTConst.RM_ALL);
    miRmAll.addActionListener(this);

    miMvUp = new JMenuItem(RESTConst.MOVE_UP);
    miMvUp.setName(RESTConst.MOVE_UP);
    miMvUp.addActionListener(this);

    miMvDown = new JMenuItem(RESTConst.MOVE_DOWN);
    miMvDown.setName(RESTConst.MOVE_DOWN);
    miMvDown.addActionListener(this);

    miEdit = new JMenuItem(RESTConst.EDIT);
    miEdit.setName(RESTConst.EDIT);
    miEdit.addActionListener(this);

    miRefresh = new JMenuItem(RESTConst.REFRESH);
    miRefresh.setName(RESTConst.REFRESH);
    miRefresh.addActionListener(this);

    histFrame = new HistFrame();
    
    pm = new JPopupMenu();
    pm.add(miRefresh);
    pm.add(miEdit);
    pm.addSeparator();
    pm.add(miMvUp);
    pm.add(miMvDown);
    pm.addSeparator();
    pm.add(miRmSel);
    pm.add(miRmAll);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new GridLayout(1, 1));
    JScrollPane sp = new JScrollPane(tab);
    pnlCenter.add(sp);

    this.add(pnlCenter, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createTitledBorder(null, RESTConst.HTTP_HISTORY, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION));
}
 
Example 19
Source File: MutualAuthenticationSettingsPanel.java    From Spark with Apache License 2.0 4 votes vote down vote up
public MutualAuthenticationSettingsPanel(LocalPreferences localPreferences, JDialog optionsDialog) {
    setLayout(new GridBagLayout());

    idControll = new IdentityController(localPreferences);
    idTable = new JTable(idControll.getTableModel());
    idTable.addMouseListener(this);
    idTable.setPreferredSize(new Dimension(50, 50));
    idTable.setPreferredScrollableViewportSize(idTable.getPreferredSize());
    idTable.setFillsViewportHeight(true);
    scrollPane = new JScrollPane(idTable);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    ResourceUtils.resButton(addCertButton, Res.getString("label.choose.file"));

    ResourceUtils.resButton(selfSignedCertificate,      Res.getString("cert.self.signed"));
    ResourceUtils.resButton(certificateSigningRequest,  Res.getString("cert.sign.request"));
    ResourceUtils.resButton(saveCertToFile,             Res.getString("cert.self.signed.save.to.file"));
    
    ResourceUtils.resLabel( commonNameLabel,        commonNameField,        Res.getString("cert.common.name"));
    ResourceUtils.resLabel( organizationUnitLabel,  organizationUnitField,  Res.getString("cert.organization.unit"));
    ResourceUtils.resLabel( organizationLabel,      organizationField,      Res.getString("cert.organization"));
    ResourceUtils.resLabel( countryLabel,           countryField,           Res.getString("cert.country"));
    ResourceUtils.resLabel( cityLabel,              cityField,              Res.getString("cert.city"));

    ResourceUtils.resButton(createButton, Res.getString("create"));
    ResourceUtils.resButton(showCert, Res.getString("button.show.certificate"));


    uploadCertificatePanel.setLayout(new GridBagLayout());
    uploadCertificatePanel.setBorder(BorderFactory.createTitledBorder(Res.getString("label.certificate.add.certificate.to.identitystore")));
    uploadCertificatePanel.add(addCertButton,    new GridBagConstraints(0, 0, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));

    radioGroup.add(selfSignedCertificate);
    radioGroup.add(certificateSigningRequest);
    
    selfSignedCertificate.addActionListener(this);
    certificateSigningRequest.addActionListener(this);
    
    certificateSigningRequest.setSelected(true);
    saveCertToFile.setEnabled(false);

    creationPanel.setLayout(new GridBagLayout());

    creationPanel.add(certificateSigningRequest, new GridBagConstraints(0, 0, 1, 1, 0.3, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(selfSignedCertificate,     new GridBagConstraints(1, 0, 1, 1, 0.3, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(saveCertToFile,            new GridBagConstraints(2, 0, 1, 1, 0.4, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 200, 0));
    
    creationPanel.add(commonNameLabel,           new GridBagConstraints(0, 1, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(organizationUnitLabel,     new GridBagConstraints(0, 2, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(organizationLabel,         new GridBagConstraints(0, 3, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(countryLabel,              new GridBagConstraints(0, 4, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(cityLabel,                 new GridBagConstraints(0, 5, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(createButton,              new GridBagConstraints(0, 6, 1, 1, 0.05, 0.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));

    creationPanel.add(commonNameField,           new GridBagConstraints(1, 1, 2, 1, 0.95, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(organizationUnitField,     new GridBagConstraints(1, 2, 2, 1, 0.95, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(organizationField,         new GridBagConstraints(1, 3, 2, 1, 0.95, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(countryField,              new GridBagConstraints(1, 4, 2, 1, 0.95, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));
    creationPanel.add(cityField,                 new GridBagConstraints(1, 5, 2, 1, 0.95, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0));


    add(scrollPane,             new GridBagConstraints(0, 0, 1, 1, 1.0, 0.3, WEST, GridBagConstraints.BOTH, DEFAULT_INSETS, 0, 0));
    add(uploadCertificatePanel, new GridBagConstraints(0, 1, 1, 1, 0.2, 0.2, WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 400), 0, 0));
    add(showCert,               new GridBagConstraints(0, 2, 1, 1, 0.2, 0.2, WEST, HORIZONTAL, new Insets(5, 5, 5, 400), 0, 0));
    add(creationPanel,          new GridBagConstraints(0, 3, 1, 6, 1.0, 0.5, WEST, GridBagConstraints.BOTH, DEFAULT_INSETS, 0, 0));

    showCert.setEnabled(false);
    showCert.addActionListener(this);
    addCertButton.addActionListener(this);
    createButton.addActionListener(this);
}
 
Example 20
Source File: CViewSearcherDialog.java    From binnavi with Apache License 2.0 2 votes vote down vote up
/**
 * Creates the GUI of the dialog.
 */
private void createGui() {
  setLayout(new BorderLayout());

  final JPanel panel = new JPanel(new BorderLayout());

  final JLabel lbl = new JLabel("Address" + ":");

  lbl.setBorder(new EmptyBorder(5, 5, 5, 5));

  panel.add(lbl, BorderLayout.WEST);

  m_offsetField.setSize(400, 20);

  final ActionListener listener = new ActionListener() {

    @Override
    public void actionPerformed(final ActionEvent e) {
      search();
    }
  };

  m_offsetField.addActionListener(listener);

  panel.add(m_offsetField, BorderLayout.CENTER);

  panel.add(new JButton(CActionProxy.proxy(new SearchAction(this))), BorderLayout.EAST);

  add(panel, BorderLayout.NORTH);

  m_table = new JTable(tableModel);

  m_table.addMouseListener(m_listener);

  add(new JScrollPane(m_table), BorderLayout.CENTER);

  add(new CPanelTwoButtons(CActionProxy.proxy(new InternalActionListener()), "OK", "Cancel"),
      BorderLayout.SOUTH);

  setSize(500, 300);
}