當前位置: 首頁>>代碼示例>>Java>>正文


Java Component類代碼示例

本文整理匯總了Java中java.awt.Component的典型用法代碼示例。如果您正苦於以下問題:Java Component類的具體用法?Java Component怎麽用?Java Component使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Component類屬於java.awt包,在下文中一共展示了Component類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readObject

import java.awt.Component; //導入依賴的package包/類
/**
 * Deserializes this {@code DragGestureRecognizer}. This method first
 * performs default deserialization for all non-{@code transient}
 * fields. This object's {@code DragGestureListener} is then
 * deserialized as well by using the next object in the stream.
 *
 * @since 1.4
 */
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s)
    throws ClassNotFoundException, IOException
{
    ObjectInputStream.GetField f = s.readFields();

    DragSource newDragSource = (DragSource)f.get("dragSource", null);
    if (newDragSource == null) {
        throw new InvalidObjectException("null DragSource");
    }
    dragSource = newDragSource;

    component = (Component)f.get("component", null);
    sourceActions = f.get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
    events = (ArrayList<InputEvent>)f.get("events", new ArrayList<>(1));

    dragGestureListener = (DragGestureListener)s.readObject();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:DragGestureRecognizer.java

示例2: clickOnComp

import java.awt.Component; //導入依賴的package包/類
/**
 * Moves mouse pointer in the center of a given {@code comp} component
 * and performs a left mouse button click using the {@code robot} parameter
 * with the {@code delay} delay between press and release.
 */
public static void clickOnComp(final Component comp, final Robot robot, int delay) {
    pointOnComp(comp, robot);
    robot.delay(delay);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.delay(delay);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:Util.java

示例3: checkStoredGlassPane

import java.awt.Component; //導入依賴的package包/類
private void checkStoredGlassPane() {
    // remember current glass pane to set back at end of dragging over this compoment
    if (!DropGlassPane.isOriginalPaneStored() || dropPane == null) {
        if (DropGlassPane.isOriginalPaneStored()) {
            // Original panel is stored, but dropPane == null, see #236349.
            DropGlassPane.putBackOriginal();
        }
        Component comp = table.getRootPane().getGlassPane();
        DropGlassPane.setOriginalPane(table, comp, comp.isVisible());

        // set glass pane for paint selection line
        dropPane = DropGlassPane.getDefault(table);
        table.getRootPane().setGlassPane(dropPane);
        dropPane.revalidate();
        dropPane.setVisible(true);
        log("dropPane was set"); // NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:OutlineViewDropSupport.java

示例4: createFirstTab

import java.awt.Component; //導入依賴的package包/類
@Override
protected Component createFirstTab(JTabbedPane pane) {
    sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework,
            framework.getAccessRules());
    sectorNameEditor = new SectorNameEditor(dataPlugin, framework,
            framework.getAccessRules()) {
        @Override
        protected void createReplacementPanel(JPanel ignoreMe) {
        }

        @Override
        public Stream getStream() {
            return sectorRowsEditor.getStream();
        }
    };
    sectorNameEditor.box.setVisible(false);
    sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
    pane.addTab(ResourceLoader.getString("name"), sectorRowsEditor);
    return sectorNameEditor;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:21,代碼來源:DFDSRoleOptionsDialog.java

示例5: handleDocumentEvent

import java.awt.Component; //導入依賴的package包/類
private void handleDocumentEvent(DocumentEvent e, Shape a,
									ViewFactory f) {
	int n = calculateLineCount();
	if (this.nlines != n) {
		this.nlines = n;
		WrappedSyntaxView.this.preferenceChanged(this, false, true);
		// have to repaint any views after the receiver.
		RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
		textArea.repaint();
		// Must also revalidate container so gutter components, such
		// as line numbers, get updated for this line's new height
		Gutter gutter = RSyntaxUtilities.getGutter(textArea);
		if (gutter!=null) {
			gutter.revalidate();
			gutter.repaint();
		}
	}
	else if (a != null) {
		Component c = getContainer();
		Rectangle alloc = (Rectangle) a;
		c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
	}
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:24,代碼來源:WrappedSyntaxView.java

示例6: converChoosers

import java.awt.Component; //導入依賴的package包/類
static DescriptablePathChooser converChoosers(final ComponentChooser[] choosers) {
    return (new DescriptablePathChooser() {
        @Override
        public boolean checkPathComponent(int depth, Object component) {
            return choosers[depth].checkComponent((Component) component);
        }

        @Override
        public int getDepth() {
            return choosers.length;
        }

        @Override
        public String getDescription() {
            return createDescription(choosers);
        }

        @Override
        public String toString() {
            return "JMenuOperator.converChoosers.DescriptablePathChooser{description = " + getDescription() + '}';
        }
    });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:JMenuOperator.java

示例7: propertyChange

import java.awt.Component; //導入依賴的package包/類
/** Requests refresh of our lookup everytime component is chagned.
 */
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    if (TopComponent.Registry.PROP_ACTIVATED.equals (evt.getPropertyName())) {
        org.openide.util.Utilities.actionsGlobalContext ().lookup (javax.swing.ActionMap.class);
    }
    if ("permanentFocusOwner".equals(evt.getPropertyName())) {
        Component[] arr = { (Component)evt.getNewValue() };
        if (arr[0] instanceof AbstractButton) {
            Action a = ((AbstractButton)arr[0]).getAction();
            if (a instanceof ContextAwareAction) {
                // ignore focus change into a button with our action
                return;
            }
        }
        blickActionMap(null, arr);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:GlobalActionContextImpl.java

示例8: createRenderers

import java.awt.Component; //導入依賴的package包/類
protected void createRenderers() {
	final TableCellRenderer boolRend = getDefaultRenderer(Boolean.class);
	setDefaultRenderer(Boolean.class, new DisabledCellRenderer() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
			Component cbox = boolRend.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
			cbox.setEnabled(true);
			if (value == null) {
				Component disabled = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
				cbox.setBackground(disabled.getBackground());
				cbox.setEnabled(false);
			}
			return cbox;
		}
	});
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:22,代碼來源:ConnectionsPanel.java

示例9: getListCellRendererComponent

import java.awt.Component; //導入依賴的package包/類
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	

	int selectedIndex = ((Integer) value).intValue();

	if (isSelected) {
		setBackground(list.getSelectionBackground());
		setForeground(list.getSelectionForeground());
	} else {
		setBackground(list.getBackground());
		setForeground(list.getForeground());
	}

	ImageIcon icon = iconArray[selectedIndex];
	setIcon(icon);
	
	return this;
}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:21,代碼來源:LanguageCmbBox.java

示例10: paintRaisedBevel

import java.awt.Component; //導入依賴的package包/類
protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getHighlightOuterColor(c));
    g.drawLine(0, 0, 0, h - 2);
    g.drawLine(1, 0, w - 2, 0);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 0, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ThinBevelBorder.java

示例11: getTableCellEditorComponent

import java.awt.Component; //導入依賴的package包/類
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
	String[] tupel;
	if (value instanceof String) {
		tupel = ParameterTypeTupel.transformString2Tupel((String) value);
	} else {
		tupel = (String[]) value;
	}
	if (panel == null) {
		constructPanel(tupel);
	}
	for (int i = 0; i < editors.length; i++) {
		editors[i].getTableCellEditorComponent(null, tupel[i], false, 0, 0);
	}
	return panel;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:17,代碼來源:ParameterTupelCellEditor.java

示例12: paintBorder

import java.awt.Component; //導入依賴的package包/類
/** This method is called by Swing to actually draw the borders. */
public void paintBorder(Component component, Graphics graphics, int x, int y, int width, int height) {
	if (width < 1 || height < 1)
		return;
	Color old = graphics.getColor();
	if (top != null) {
		graphics.setColor(top);
		graphics.drawLine(x, y, x + width - 1, y);
	}
	if (bottom != null) {
		graphics.setColor(bottom);
		graphics.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
	}
	if (left != null) {
		graphics.setColor(left);
		graphics.drawLine(x, y, x, y + height - 1);
	}
	if (right != null) {
		graphics.setColor(right);
		graphics.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
	}
	graphics.setColor(old);
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:24,代碼來源:OurBorder.java

示例13: getComponent

import java.awt.Component; //導入依賴的package包/類
@Override
public Component getComponent() {
    if (gui == null) {
        gui = new TemplateChooserPanelGUI(includeTemplatesWithProjects);
        gui.addChangeListener(this);
        gui.setDefaultActionListener(new ActionListener() {

            @Override
            public void actionPerformed( ActionEvent e ) {
                if( null != wizard ) {
                    wizard.doNextClick();
                }
            }
        });
    }
    return gui;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:TemplateChooserPanel.java

示例14: getListCellRendererComponent

import java.awt.Component; //導入依賴的package包/類
@Override
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    super.getListCellRendererComponent(list,
                                       value,
                                       index,
                                       isSelected,
                                       cellHasFocus);
    if (isSelected){
        setBackground(UIManager.getColor("List.selectionBackground")); //NOI18N
        setForeground(UIManager.getColor("List.selectionForeground")); //NOI18N
    } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
    }
    return this;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:FilesModifiedConfirmation.java

示例15: getTreeCellRendererComponent

import java.awt.Component; //導入依賴的package包/類
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    if (!useTreeColors && (sel || hasFocus)) {
        SynthLookAndFeel.setSelectedUI((SynthLabelUI)SynthLookAndFeel.
                     getUIOfType(getUI(), SynthLabelUI.class),
                           sel, hasFocus, tree.isEnabled(), false);
    }
    else {
        SynthLookAndFeel.resetSelectedUI();
    }
    return super.getTreeCellRendererComponent(tree, value, sel,
                                              expanded, leaf, row, hasFocus);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:SynthTreeUI.java


注:本文中的java.awt.Component類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。