当前位置: 首页>>代码示例>>Java>>正文


Java JComponent类代码示例

本文整理汇总了Java中javax.swing.JComponent的典型用法代码示例。如果您正苦于以下问题:Java JComponent类的具体用法?Java JComponent怎么用?Java JComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JComponent类属于javax.swing包,在下文中一共展示了JComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAndShowGUI

import javax.swing.JComponent; //导入依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
public static JFrame createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("DropDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    JComponent newContentPane = new DropDemo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
    return frame;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:DropDemo.java

示例2: makeNoButton

import javax.swing.JComponent; //导入依赖的package包/类
@Override
protected JButton makeNoButton() {
	ResourceAction noAction = new ResourceAction("start.normally") {

		private static final long serialVersionUID = -8887199234055845095L;

		@Override
		public void actionPerformed(ActionEvent e) {
			setReturnOption(NO_OPTION);
			no();
		}
	};
	getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
	        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), "NO");
	getRootPane().getActionMap().put("NO", noAction);
	JButton noButton = new JButton(noAction);
	return noButton;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:SafeModeDialog.java

示例3: createCenterPane

import javax.swing.JComponent; //导入依赖的package包/类
@Override
protected JComponent createCenterPane() {
	graphpanel = new SampleGraphPanel();
	graphpanel.setPreferredSize(new Dimension(600, 300));
	new DropTarget(graphpanel, new FileDropTargetListener() {
		@Override
		protected void openFile(File file) {
			// insert your own function for loading a file
			JOptionPane.showMessageDialog(graphpanel,
					"Opened " + file.getName());
		}

		@Override
		protected boolean canOpenFile() {
			// is GUI ready for opening a file?
			return true;
		}
	});
	return graphpanel;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:21,代码来源:PaneledGuiDemo.java

示例4: initialize

import javax.swing.JComponent; //导入依赖的package包/类
public void initialize(WizardDescriptor wiz) {
    this.wizardDescriptor = wiz;
    
    Object prop = wiz.getProperty(WizardDescriptor.PROP_CONTENT_DATA); //NOI18N
    String[] beforeSteps = null;
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[]) prop;
    }
    String[] steps = createSteps(beforeSteps, panels);
    
    // Make sure list of steps is accurate.
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, //NOI18N
                                                new Integer(i)); 
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); //NOI18N
        }
    }        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JAXBWizardIterator.java

示例5: paintHorizontalSeparators

import javax.swing.JComponent; //导入依赖的package包/类
protected void paintHorizontalSeparators(Graphics g, JComponent c) {
	Rectangle clipBounds = g.getClipBounds();

	int beginRow = getRowForPath(this.tree, getClosestPathForLocation(this.tree, 0, clipBounds.y));
	int endRow = getRowForPath(this.tree, getClosestPathForLocation(this.tree, 0, clipBounds.y + clipBounds.height - 1));

	if ((beginRow <= -1) || (endRow <= -1)) {
		return;
	}

	for (int i = beginRow; i <= endRow; ++i) {
		TreePath path = getPathForRow(this.tree, i);

		if ((path != null) && (path.getPathCount() == 2)) {
			Rectangle rowBounds = getPathBounds(this.tree, getPathForRow(this.tree, i));

			// Draw a line at the top
			if (rowBounds != null) {
				g.drawLine(clipBounds.x, rowBounds.y, clipBounds.x + clipBounds.width, rowBounds.y);
			}
		}
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:TreeUI.java

示例6: getThumbSelector

import javax.swing.JComponent; //导入依赖的package包/类
/**
 * create returns the thumb selector component
 *
 * @param f
 * @return
 */
private JComponent getThumbSelector(final String f) {
    final JCheckBox cb = new JCheckBox();
    cb.setText("");
    cb.setSelected(false);
    cb.setName(f);
    cb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cb.isSelected()) {
                selflist.add(f);
            } else {
                selflist.remove(f);
            }
        }
    });
    cb.setPreferredSize(CB_SIZE);
    return cb;

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:27,代码来源:ImageGallery.java

示例7: initialize

import javax.swing.JComponent; //导入依赖的package包/类
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps);
        }
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:25,代码来源:ExampleBotProjectWizardIterator.java

示例8: createDetailsSection

import javax.swing.JComponent; //导入依赖的package包/类
private JComponent createDetailsSection()
{
	final JLabel notesLabel = new JLabel(getString("label.notes")); //$NON-NLS-1$

	notes = new JTextArea();
	notes.setWrapStyleWord(true);
	notes.setLineWrap(true);
	notes.setRows(3);
	notes.setBorder(new EmptyBorder(0, 0, 10, 0));

	final int height1 = notesLabel.getPreferredSize().height;
	final int height2 = notes.getPreferredSize().height;

	final int[] rows = {height1, height2};
	final int[] cols = {TableLayout.FILL};
	final JPanel all = new JPanel(new TableLayout(rows, cols));

	all.add(notesLabel, new Rectangle(0, 0, 1, 1));
	all.add(new JScrollPane(notes), new Rectangle(0, 1, 1, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:AdvancedScriptControlEditor.java

示例9: createBooleanOption

import javax.swing.JComponent; //导入依赖的package包/类
private JComponent createBooleanOption(OptionDescriptor option, Preferences prefs)  {
    JCheckBox checkBox = new JCheckBox();

    org.openide.awt.Mnemonics.setLocalizedText(checkBox, option.displayName);
    checkBox.setToolTipText(option.tooltip);
    checkBox.addActionListener(new ActionListenerImpl(option.preferencesKey, prefs));

    checkBox.setSelected(prefs.getBoolean(option.preferencesKey, 
            Boolean.TRUE == option.defaultValue));
    prefs.putBoolean(option.preferencesKey, checkBox.isSelected());
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridheight = 1;
    constraints.gridwidth = 2;
    constraints.gridx = 0;
    constraints.gridy = row++;
    constraints.weightx = 0;
    constraints.weighty = 0;

    add(checkBox, constraints);
    return checkBox;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ReflectiveCustomizerProvider.java

示例10: getEditorComponent

import javax.swing.JComponent; //导入依赖的package包/类
private JComponent getEditorComponent(JComponent text) {
    if ( !Config.getDefault().isLineNumbers()) {
        return text;
    }
    JComponent lineNumber = getLineNumberComponent(getParent(text));

    if (lineNumber == null) {
        return text;
    }
    List<JComponent> components = new ArrayList<JComponent>();

    components.add(lineNumber);
    components.add(text);

    return new ComponentPanel(components);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EditorProvider.java

示例11: watchRemoved

import javax.swing.JComponent; //导入依赖的package包/类
@Override
public void watchRemoved(Watch watch) {
    synchronized(watchToAnnotation) {
        Annotation annotation = watchToAnnotation.remove(watch);
        if(annotation != null) {
            annotation.detach();
        }
        JComponent frame = watchToWindow.remove(watch);
        if(frame != null) {
            EditorUI eui = ((StickyPanel) frame).eui;
            eui.getStickyWindowSupport().removeWindow(frame);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:WatchAnnotationProvider.java

示例12: getSwing

import javax.swing.JComponent; //导入依赖的package包/类
@HTMLComponent(
    url = "simple.html", className = "TestPages",
    type = JComponent.class, 
    techIds = "second"
) 
static void getSwing(int param, CountDownLatch called) {
    assertEquals(param, 10, "Correct value passed in");
    called.countDown();
    ATech t = Contexts.find(BrwsrCtx.findDefault(ComponentsTest.class), ATech.class);
    assertNotNull(t, "A technology found");
    assertEquals(t.getClass(), ATech.Second.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ComponentsTest.java

示例13: displayAttributeNotFoundParameterInformation

import javax.swing.JComponent; //导入依赖的package包/类
/**
 * Displays an information bubble that alerts the user that the attribute specified in the
 * operator parameters was not found. The bubble is located at the operator and the process view
 * will change to said operator. This method is used after the error occurred during process
 * execution.
 *
 * @param error
 *            the error containing all the information about the operator, the parameter and the
 *            name of the attribute which was not found
 * @param i18nKey
 *            the i18n key which defines the title, text and button label for the bubble. Format
 *            is "gui.bubble.{i18nKey}.title", "gui.bubble.{i18nKey}.body" and
 *            "gui.bubble.{i18nKey}.button.label".
 * @param isError
 *            if {@code true}, an error bubble will be shown; otherwise a warning bubble is
 *            displayed
 * @param arguments
 *            optional i18n arguments
 * @return the {@link OperatorInfoBubble} instance, never {@code null}
 */
private static OperatorInfoBubble displayAttributeNotFoundParameterInformation(final AttributeNotFoundError error,
		final boolean isError, final String i18nKey, final Object... arguments) {
	final Operator op = error.getOperator();
	final ParameterType param = op.getParameterType(error.getKey());
	final JButton ackButton = new JButton(I18N.getGUIMessage("gui.bubble." + i18nKey + ".button.label", arguments));
	ackButton.setToolTipText(I18N.getGUIMessage("gui.bubble." + i18nKey + ".button.tip"));

	String decoratorKey = param instanceof CombinedParameterType || param instanceof ParameterTypeAttributes
			? "attributes_not_found_decoration" : "attribute_not_found_decoration";

	ParameterErrorBubbleBuilder builder = new ParameterErrorBubbleBuilder(RapidMinerGUI.getMainFrame(), op, param,
			decoratorKey, i18nKey, arguments);
	final ParameterErrorInfoBubble attributeNotFoundParameterBubble = builder.setHideOnDisable(true)
			.setAlignment(AlignedSide.BOTTOM).setStyle(isError ? BubbleStyle.ERROR : BubbleStyle.WARNING)
			.setEnsureVisible(true).hideCloseButton().setHideOnProcessRun(true)
			.setAdditionalComponents(new JComponent[] { ackButton }).build();

	ackButton.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent e) {
			attributeNotFoundParameterBubble.killBubble(true);
		}
	});

	attributeNotFoundParameterBubble.setVisible(true);
	return attributeNotFoundParameterBubble;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:49,代码来源:ProcessGUITools.java

示例14: clearPopupMenu

import javax.swing.JComponent; //导入依赖的package包/类
private void clearPopupMenu(JComponent component) {
    component.setComponentPopupMenu(null);
    for (int i = 0; i < component.getComponentCount(); i++) {
        Component c = component.getComponent(i);
        if (c instanceof JComponent)
            clearPopupMenu((JComponent) c);
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:ModelPropertiesDialog.java

示例15: isInTabbedContainer

import javax.swing.JComponent; //导入依赖的package包/类
private static boolean isInTabbedContainer( Component c ) {
    Component parent = c.getParent();
    while( null != parent ) {
        if( parent instanceof JComponent
                && "TabbedContainerUI".equals( ((JComponent)parent).getUIClassID() ) ) //NOI18N
            return true;
        parent = parent.getParent();
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ViewUtil.java


注:本文中的javax.swing.JComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。