本文整理汇总了Java中javax.swing.JComponent.add方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.add方法的具体用法?Java JComponent.add怎么用?Java JComponent.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createExtComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
protected JComponent createExtComponent() {
setLineNumberEnabled(true); // enable line numbering
// extComponent will be a panel
JComponent ec = new JPanel(new BorderLayout());
ec.putClientProperty(JTextComponent.class, component);
// Add the scroll-pane with the component to the center
JScrollPane scroller = new JScrollPane(component);
scroller.getViewport().setMinimumSize(new Dimension(4,4));
// remove default scroll-pane border, winsys will handle borders itself
scroller.setBorder(null);
setGlyphGutter(new GlyphGutter(this));
scroller.setRowHeaderView(glyphGutter);
initGlyphCorner(scroller);
ec.add(scroller);
// Install the status-bar panel to the bottom
ec.add(getStatusBar().getPanel(), BorderLayout.SOUTH);
return ec;
}
示例2: addClassNameEditorCC
import javax.swing.JComponent; //导入方法依赖的package包/类
static Pair<JScrollPane, JEditorPane> addClassNameEditorCC(String mimeType, JComponent comp, String className, String tooltipText) {
JComponent [] editorComponents = Utilities.createSingleLineEditor(mimeType);
JScrollPane sle = (JScrollPane) editorComponents[0];
JEditorPane epClassName = (JEditorPane) editorComponents[1];
epClassName.setText(className);
if (comp != null) {
java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
comp.add(sle, gridBagConstraints);
}
sle.setToolTipText(tooltipText);
epClassName.setToolTipText(tooltipText);
return Pair.<JScrollPane, JEditorPane>of(sle, epClassName);
}
示例3: wrapDialogContent
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
*/
private static JComponent wrapDialogContent(JComponent comp,
boolean selfResizing) {
JComponent result;
if ((comp.getBorder() != null) || selfResizing) {
result = selfResizing ? new SelfResizingPanel() : new JPanel();
result.setLayout(new GridLayout());
result.add(comp);
} else {
result = comp;
}
result.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
result.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_title_select_generator"));
return result;
}
示例4: FilesModifiedConfirmation
import javax.swing.JComponent; //导入方法依赖的package包/类
public FilesModifiedConfirmation(SaveCookie[] saveCookies) {
btnSaveAll = createSaveAllButton();
btnSave = createSaveButton();
Mnemonics.setLocalizedText(btnSaveAll, getInitialSaveAllButtonText());
Mnemonics.setLocalizedText(btnSave, getInitialSaveButtonText());
JScrollPane scrollPane
= new JScrollPane(list = createFilesList(saveCookies));
if (!listModel.isEmpty()) {
list.setSelectedIndex(0);
} else {
updateSaveButtonState();
}
JComponent panel = new JPanel(new GridLayout(1, 1));
panel.add(scrollPane);
panel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
mainComponent = panel;
}
示例5: activateFilter
import javax.swing.JComponent; //导入方法依赖的package包/类
public void activateFilter() {
JComponent panel = getBottomPanel();
if (filterPanel == null) {
filterPanel = FilterUtils.createFilterPanel(getResultsComponent(), getExcludesFilter(), getFilterOptions());
panel.add(filterPanel);
Container parent = panel.getParent();
parent.invalidate();
parent.revalidate();
parent.repaint();
}
panel.setVisible(true);
filterPanel.setVisible(true);
filterPanel.requestFocusInWindow();
}
示例6: activateSearch
import javax.swing.JComponent; //导入方法依赖的package包/类
public void activateSearch() {
JComponent panel = getBottomPanel();
if (searchPanel == null) {
SearchUtils.TreeHelper searchHelper = getSearchHelper();
if (searchHelper == null) searchPanel = SearchUtils.createSearchPanel(getResultsComponent(), getSearchOptions());
else searchPanel = SearchUtils.createSearchPanel((ProfilerTreeTable)getResultsComponent(), searchHelper, getSearchOptions());
panel.add(searchPanel);
Container parent = panel.getParent();
parent.invalidate();
parent.revalidate();
parent.repaint();
}
panel.setVisible(true);
searchPanel.setVisible(true);
searchPanel.requestFocusInWindow();
}
示例7: createChkBoxGroup
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Creates a labelled group of checkboxes.
*
* @param title title for the group of checkboxes
* @param elements checkboxes - members of the group
* @return visual component representing the group
*/
public static JComponent createChkBoxGroup(String title,
JCheckBox[] elements) {
/* create a component representing the group without title: */
JComponent content = new JPanel(new GridLayout(0, 1, 0, 5));
for (int i = 0; i < elements.length; i++) {
content.add(elements[i]);
}
/* add the title and insets to the group: */
JPanel result = new SizeRestrictedPanel(new BorderLayout(), true, true);
result.add(new JLabel(title), BorderLayout.NORTH);
addBorder(content, BorderFactory.createEmptyBorder(6, 12, 0, 0));
result.add(content, BorderLayout.CENTER);
return result;
}
示例8: addColorChooser
import javax.swing.JComponent; //导入方法依赖的package包/类
private void addColorChooser(JComponent c, String displayName, ColorChooser chooser) {
GridBagLayout layout = (GridBagLayout)c.getLayout();
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets(3, 3, 3, 3);
constraints.weightx = 0.0;
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.EAST;
JLabel label = new JLabel(displayName, JLabel.TRAILING);
layout.setConstraints(label, constraints);
c.add(label);
constraints.anchor = GridBagConstraints.WEST;
constraints.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(chooser, constraints);
c.add(chooser);
elements.add(chooser);
label.setLabelFor(chooser);
}
示例9: addClassNameEditor
import javax.swing.JComponent; //导入方法依赖的package包/类
static JTextField addClassNameEditor(JComponent comp, String className, String tooltipText) {
JTextField textField = new JTextField(className); // NOI18N
java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
comp.add(textField, gridBagConstraints);
textField.setToolTipText(tooltipText);
return textField;
}
示例10: injectComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
void injectComponent(JComponent p, JComponent c, boolean shape) {
if (shape) {
setShaping(c);
}
p.removeAll();
p.add(c);
}
示例11: addAdditionalControls
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void addAdditionalControls(JComponent c, boolean enabled) {
jabberUser.setEditable(enabled);
jabberPw.setEditable(enabled);
c.add(new JLabel(Resources.getString("ServerAddressBook.user_name"))); //$NON-NLS-1$
c.add(jabberUser, "wrap, grow, push"); //$NON-NLS-1$
c.add(new JLabel(Resources.getString("ServerAddressBook.password"))); //$NON-NLS-1$
c.add(jabberPw, "wrap, grow, push"); //$NON-NLS-1$
}
示例12: PopuleBarra
import javax.swing.JComponent; //导入方法依赖的package包/类
public void PopuleBarra(JComponent obj) {
ButtonGroup buttons = new ButtonGroup();
Barra = obj;
Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null);
JToggleButton btn = arrume(new JToggleButton(ac));
buttons.add(btn);
obj.add(btn);
btn.setSelected(true);
ac.IDX = -1;
this.BtnNothing = btn;
int i = 0;
for (ConfigAcao ca : Lista) {
if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) {
ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
ac.IDX = i++;
btn = arrume(new JToggleButton(ac));
buttons.add(btn);
//obj.add(btn);
listaBotoes.put(ca.command, btn);
}
}
menuComandos c = menuComandos.cmdDel;
String str = "Controler.comandos." + c.toString().substring(3).toLowerCase();
ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString());
ListaDeAcoesEditaveis.add(ac);
ac.normal = false;
JButton btn2 = new JButton(ac);
btn2.setHideActionText(true);
btn2.setFocusable(false);
btn2.setPreferredSize(new Dimension(40, 40));
obj.add(btn2);
LayoutManager la = obj.getLayout();
if (la instanceof GridLayout) {
((GridLayout) la).setRows(i + 2);
}
}
示例13: registerForm
import javax.swing.JComponent; //导入方法依赖的package包/类
private void registerForm(final RADVisualContainer metacomp, final JMenu menu) {
// don't double register
if(!formModelListeners.containsKey(metacomp)) {
FormModelListener fml = new FormModelListener() {
@Override
public void formChanged(FormModelEvent[] events) {
if (events != null) {
for(FormModelEvent evt : events) {
if(evt.getChangeType() == FormModelEvent.FORM_TO_BE_CLOSED) {
formModelListeners.remove(metacomp);
metacomp.getFormModel().addFormModelListener(this);
continue;
}
if(evt.getChangeType() == FormModelEvent.COMPONENT_PROPERTY_CHANGED) {
if("action".equals(evt.getPropertyName())) { // NOI18N
configureEditedComponent(evt.getComponent());
}
}
if(evt.getChangeType() == FormModelEvent.COMPONENT_PROPERTY_CHANGED || evt.getChangeType() == FormModelEvent.BINDING_PROPERTY_CHANGED) {
if(evt.getContainer() == metacomp || evt.getComponent() == metacomp) {
rebuildOnScreenMenu(metacomp);
}
updateIcon(evt.getComponent());
}
if(evt.getChangeType() == FormModelEvent.COMPONENT_ADDED) {
updateIcon(evt.getComponent());
//reinstall the accelerator preview when moving items around
if(evt.getComponent() != null) {
Component co = (Component) formDesigner.getComponent(evt.getComponent());
if(co instanceof JMenuItem) {
installAcceleratorPreview((JMenuItem)co);
}
}
}
// if this menu was deleted then make sure it's popup is hidden and removed
if(evt.getChangeType() == FormModelEvent.COMPONENT_REMOVED) {
if(evt.getComponent() == metacomp) {
unconfigureMenu(menu);
continue;
}
}
// if something added to the menu we monitor
if(evt.getChangeType() == FormModelEvent.COMPONENT_ADDED ||
evt.getChangeType() == FormModelEvent.COMPONENTS_REORDERED ||
evt.getChangeType() == FormModelEvent.COMPONENT_REMOVED) {
if(evt.getContainer() == metacomp) {
// then rebuild the menu
rebuildOnScreenMenu(metacomp);
return;
}
if(evt.getContainer() == getFormMenuBar()) {
JComponent comp = (JComponent) formDesigner.getComponent(getFormMenuBar());
if (comp != null) { // MenuBar not shown in the designer, see issue 124873
RADVisualContainer rad = (RADVisualContainer) getFormMenuBar();
comp.removeAll();
for(RADVisualComponent c : rad.getSubComponents()) {
if(c!=null) {
comp.add((JComponent)formDesigner.getComponent(c));
}
}
}
}
}
}
}
}
};
formModelListeners.put(metacomp,fml);
metacomp.getFormModel().addFormModelListener(fml);
}
}
示例14: addMenuItem
import javax.swing.JComponent; //导入方法依赖的package包/类
void addMenuItem(String id, JComponent menu) {
JMenuItem mitem = new JMenuItem(getString(id));
mitem.setName(id);
mitem.addActionListener(this);
menu.add(mitem);
}
示例15: createVisualComp
import javax.swing.JComponent; //导入方法依赖的package包/类
private Component createVisualComp() {
JCheckBox[] chkBoxes;
JComponent infoLabel = GuiUtils.createMultilineLabel(
NbBundle.getMessage(TestSuiteStepLocation.class,
"TXT_ClassesInSuite")); //NOI18N
JComponent optCode = GuiUtils.createChkBoxGroup(
NbBundle.getMessage(
GuiUtils.class,
"CommonTestsCfgOfCreate.groupOptCode"), //NOI18N
chkBoxes = GuiUtils.createCheckBoxes(new String[] {
GuiUtils.CHK_SETUP,
GuiUtils.CHK_TEARDOWN,
GuiUtils.CHK_BEFORE_CLASS,
GuiUtils.CHK_AFTER_CLASS}));
chkSetUp = chkBoxes[0];
chkTearDown = chkBoxes[1];
chkBeforeClass = chkBoxes[2];
chkAfterClass = chkBoxes[3];
JComponent optComments = GuiUtils.createChkBoxGroup(
NbBundle.getMessage(
GuiUtils.class,
"CommonTestsCfgOfCreate.groupOptComments"), //NOI18N
chkBoxes = GuiUtils.createCheckBoxes(new String[] {
GuiUtils.CHK_HINTS}));
chkCodeHints = chkBoxes[0];
JComponent bottomPanel = new SelfResizingPanel();
bottomPanel.setLayout(new BorderLayout(0, 24));
bottomPanel.add(infoLabel, BorderLayout.NORTH);
JComponent box = new JPanel();
box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
box.add(optCode);
box.add(Box.createHorizontalStrut(18));
box.add(optComments);
bottomPanel.add(box, BorderLayout.CENTER);
/* tune layout of the components within the box: */
infoLabel.setAlignmentX(0.0f);
optCode.setAlignmentY(0.0f);
optComments.setAlignmentY(0.0f);
return bottomPanel;
}