Search in sources :

Example 96 with Component

use of java.awt.Component in project adempiere by adempiere.

the class WFContentPanel method removeAll.

//	setWorkflow
/**
	 * 	Remove All and their listeners
	 */
public void removeAll() {
    m_nodes.clear();
    m_lines.clear();
    Component[] components = getComponents();
    for (int i = 0; i < components.length; i++) {
        Component component = components[i];
        component.removeMouseListener(this);
        component.removeMouseMotionListener(this);
    }
    super.removeAll();
}
Also used : Component(java.awt.Component) Point(java.awt.Point)

Example 97 with Component

use of java.awt.Component in project adempiere by adempiere.

the class CompiereTabbedPaneUI method paintContentBorder.

//  paintTabBackground
/**************************************************************************
	 *  Paint Content Border (overwriting BasicTabbedPanelUI)
	 *  Uses Color from actual Tab (not from TabbedPane)
	 *  @param g graphics
	 *  @param tabPlacement tab placement
	 *  @param selectedIndex index
	 */
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
    //	System.out.println("TabContentBorder " );
    int width = tabPane.getWidth();
    int height = tabPane.getHeight();
    Insets insets = tabPane.getInsets();
    int x = insets.left;
    int y = insets.top;
    int w = width - insets.right - insets.left;
    int h = height - insets.top - insets.bottom;
    switch(tabPlacement) {
        case LEFT:
            x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
            w -= (x - insets.left);
            break;
        case RIGHT:
            w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
            break;
        case BOTTOM:
            h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
            break;
        case TOP:
        default:
            y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
            h -= (y - insets.top);
    }
    //  Fill region behind content area - basically a border
    Component comp = null;
    if (selectedIndex != -1)
        comp = tabPane.getComponentAt(selectedIndex);
    if (comp != null && comp instanceof JComponent) {
        JComponent jc = (JComponent) comp;
        CompiereColor bg = null;
        try {
            if (jc != null)
                bg = (CompiereColor) jc.getClientProperty(CompiereLookAndFeel.BACKGROUND);
        } catch (Exception e) {
            System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage());
        }
        if (bg == null) {
            bg = new CompiereColor(jc.getBackground());
            jc.putClientProperty(CompiereLookAndFeel.BACKGROUND, bg);
        }
        bg.paintRect(g, jc, x, y, w, h);
    } else //  Not a JComponent - paint flat
    if (comp != null) {
        g.setColor(comp.getBackground());
        g.fillRect(x, y, w, h);
    }
    paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h);
    paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h);
    paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h);
    paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h);
}
Also used : Insets(java.awt.Insets) JComponent(javax.swing.JComponent) JComponent(javax.swing.JComponent) Component(java.awt.Component) GradientPaint(java.awt.GradientPaint)

Example 98 with Component

use of java.awt.Component in project adempiere by adempiere.

the class CTable method packColumn.

//	autoSize
public void packColumn(TableColumn column) {
    int width = 0;
    //	Header
    TableCellRenderer renderer = column.getHeaderRenderer();
    if (renderer == null)
        renderer = new DefaultTableCellRenderer();
    Component comp = null;
    if (renderer != null)
        comp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, 0, 0);
    //
    if (comp != null) {
        width = comp.getPreferredSize().width;
        width = Math.max(width, comp.getWidth());
        //	Cells
        int col = column.getModelIndex();
        int maxRow = Math.min(20, getRowCount());
        try {
            for (int row = 0; row < maxRow; row++) {
                renderer = getCellRenderer(row, col);
                comp = renderer.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col);
                if (comp != null) {
                    int rowWidth = comp.getPreferredSize().width;
                    width = Math.max(width, rowWidth);
                }
            }
        } catch (Exception e) {
            log.log(Level.SEVERE, column.getIdentifier().toString(), e);
        }
        //	Width not greater than 250
        width = Math.min(MAXSIZE, width + SLACK);
    }
    //
    column.setPreferredWidth(width);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JComponent(javax.swing.JComponent) Component(java.awt.Component) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 99 with Component

use of java.awt.Component in project adempiere by adempiere.

the class CTable method autoSize.

//  stopEditor
/**************************************************************************
	 *	Size Columns.
	 *	@param useColumnIdentifier if false uses plain content -
	 *  otherwise uses Column Identifier to indicate displayed columns
	 */
public void autoSize(boolean useColumnIdentifier) {
    TableModel model = this.getModel();
    int size = model.getColumnCount();
    //	for all columns
    for (int c = 0; c < size; c++) {
        TableColumn column = getColumnModel().getColumn(c);
        //	Not displayed columns
        if (useColumnIdentifier && (column.getIdentifier() == null || column.getMaxWidth() == 0 || column.getIdentifier().toString().length() == 0))
            continue;
        int width = 0;
        //	Header
        TableCellRenderer renderer = column.getHeaderRenderer();
        if (renderer == null)
            renderer = new DefaultTableCellRenderer();
        Component comp = null;
        if (renderer != null)
            comp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, 0, 0);
        //
        if (comp != null) {
            width = comp.getPreferredSize().width;
            width = Math.max(width, comp.getWidth());
            //	Cells
            int col = column.getModelIndex();
            int maxRow = Math.min(20, getRowCount());
            try {
                for (int row = 0; row < maxRow; row++) {
                    renderer = getCellRenderer(row, col);
                    comp = renderer.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col);
                    if (comp != null) {
                        int rowWidth = comp.getPreferredSize().width;
                        width = Math.max(width, rowWidth);
                    }
                }
            } catch (Exception e) {
                log.log(Level.SEVERE, column.getIdentifier().toString(), e);
            }
            //	Width not greater than 250
            width = Math.min(MAXSIZE, width + SLACK);
        }
        //
        column.setPreferredWidth(width);
    }
//	for all columns
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JComponent(javax.swing.JComponent) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn) TableModel(javax.swing.table.TableModel) DefaultTableModel(javax.swing.table.DefaultTableModel) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 100 with Component

use of java.awt.Component in project jmeter by apache.

the class RemoteStart method doAction.

@Override
public void doAction(ActionEvent e) {
    String name = ((Component) e.getSource()).getName();
    if (name != null) {
        name = name.trim();
    }
    String action = e.getActionCommand();
    if (action.equals(ActionNames.REMOTE_STOP)) {
        GuiPackage.getInstance().getMainFrame().showStoppingMessage(name);
        distributedRunner.stop(Arrays.asList(name));
    } else if (action.equals(ActionNames.REMOTE_SHUT)) {
        GuiPackage.getInstance().getMainFrame().showStoppingMessage(name);
        distributedRunner.shutdown(Arrays.asList(name));
    } else if (action.equals(ActionNames.REMOTE_START)) {
        popupShouldSave(e);
        HashTree testTree = getTestTree();
        if (popupCheckExistingFileListener(testTree)) {
            distributedRunner.init(Arrays.asList(name), testTree);
            distributedRunner.start(Arrays.asList(name));
        }
    } else if (action.equals(ActionNames.REMOTE_START_ALL)) {
        popupShouldSave(e);
        HashTree testTree = getTestTree();
        if (popupCheckExistingFileListener(testTree)) {
            distributedRunner.init(getRemoteHosts(), testTree);
            distributedRunner.start();
        }
    } else if (action.equals(ActionNames.REMOTE_STOP_ALL)) {
        distributedRunner.stop(getRemoteHosts());
    } else if (action.equals(ActionNames.REMOTE_SHUT_ALL)) {
        distributedRunner.shutdown(getRemoteHosts());
    } else if (action.equals(ActionNames.REMOTE_EXIT)) {
        distributedRunner.exit(Arrays.asList(name));
    } else if (action.equals(ActionNames.REMOTE_EXIT_ALL)) {
        distributedRunner.exit(getRemoteHosts());
    }
}
Also used : HashTree(org.apache.jorphan.collections.HashTree) Component(java.awt.Component)

Aggregations

Component (java.awt.Component)645 JComponent (javax.swing.JComponent)163 Dimension (java.awt.Dimension)81 JLabel (javax.swing.JLabel)65 JPanel (javax.swing.JPanel)60 Insets (java.awt.Insets)55 Point (java.awt.Point)55 TableCellRenderer (javax.swing.table.TableCellRenderer)47 Container (java.awt.Container)46 JScrollPane (javax.swing.JScrollPane)42 JTable (javax.swing.JTable)36 JButton (javax.swing.JButton)35 BorderLayout (java.awt.BorderLayout)34 GridBagConstraints (java.awt.GridBagConstraints)34 JTextComponent (javax.swing.text.JTextComponent)34 GridBagLayout (java.awt.GridBagLayout)33 Color (java.awt.Color)32 JList (javax.swing.JList)31 TableColumn (javax.swing.table.TableColumn)31 MouseEvent (java.awt.event.MouseEvent)27