Java Code Examples for javax.swing.JComponent#add()
The following examples show how to use
javax.swing.JComponent#add() .
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: CAddressSpaceNodeMenuBuilder.java From binnavi with Apache License 2.0 | 6 votes |
/** * Tells a plugin to create an extension to this menu. * * @param menu The menu the extensions are added to. * @param plugin The plugin to extend the menu. */ private void addPluginMenu(final JComponent menu, final IAddressSpaceMenuPlugin plugin) { // ESCA-JAVA0166: Catching Exception because we are calling a plugin method try { final List<JComponent> menuItems = plugin.extendAddressSpaceMenu(getPluginAddressSpaces()); if (menuItems != null) { for (final JComponent menuItem : menuItems) { if (menuItem != null) { menu.add(menuItem); } } } } catch (final Exception exception) { CUtilityFunctions.logException(exception); final String innerMessage = "E00094: " + "Plugin caused an unexpected exception"; final String innerDescription = CUtilityFunctions.createDescription( String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] {"The plugin contains a bug."}, new String[] { "The plugin probably behaves erroneously from this point on but it remains active"}); NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception); } }
Example 2
Source File: DefaultPlugin.java From netbeans with Apache License 2.0 | 6 votes |
/** */ 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; }
Example 3
Source File: MemorySamplerViewSupport.java From visualvm with GNU General Public License v2.0 | 6 votes |
private void activateFilter() { JComponent panel = getBottomPanel(); if (filterPanel == null) { filterPanel = FilterUtils.createFilterPanel(table, null); panel.add(filterPanel); Container parent = panel.getParent(); parent.invalidate(); parent.revalidate(); parent.repaint(); } panel.setVisible(true); filterPanel.setVisible(true); filterPanel.requestFocusInWindow(); }
Example 4
Source File: ThreadsMemoryView.java From visualvm with GNU General Public License v2.0 | 6 votes |
private void activateFilter() { JComponent panel = getBottomPanel(); if (filterPanel == null) { filterPanel = FilterUtils.createFilterPanel(table, null); panel.add(filterPanel); Container parent = panel.getParent(); parent.invalidate(); parent.revalidate(); parent.repaint(); } panel.setVisible(true); filterPanel.setVisible(true); filterPanel.requestFocusInWindow(); }
Example 5
Source File: MemorySamplerViewSupport.java From visualvm with GNU General Public License v2.0 | 6 votes |
private void activateSearch() { JComponent panel = getBottomPanel(); if (searchPanel == null) { searchPanel = SearchUtils.createSearchPanel(table); panel.add(searchPanel); Container parent = panel.getParent(); parent.invalidate(); parent.revalidate(); parent.repaint(); } panel.setVisible(true); searchPanel.setVisible(true); searchPanel.requestFocusInWindow(); }
Example 6
Source File: EditorUI.java From netbeans with Apache License 2.0 | 6 votes |
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; }
Example 7
Source File: GroovyJUnitTestWizard.java From netbeans with Apache License 2.0 | 5 votes |
private static JComponent wrapDialogContent(JComponent comp) { JComponent result; result = new SelfResizingPanel(); result.setLayout(new GridLayout()); result.add(comp); result.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); result.getAccessibleContext().setAccessibleDescription(BUNDLE.getString("AD_title_select_generator")); //NOI18N return result; }
Example 8
Source File: ClusterApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 5 votes |
/** * Creates and displays the UI, including the map, for this application. * * @return the UI component. */ public JComponent createUI() { // application content JComponent contentPane = createContentPane(); // map map = createMap(); contentPane.add(map); return contentPane; }
Example 9
Source File: ShapeSet.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
private static void addColoredItem (JComponent top, JMenuItem item, Color color) { if (color != null) { item.setForeground(color); } else { item.setForeground(Color.black); } top.add(item); }
Example 10
Source File: ScoreDialog.java From FancyBing with GNU General Public License v3.0 | 5 votes |
private JTextField createEntry(String labelText, int cols, String toolTip, JComponent labels, JComponent values) { labels.add(createEntryLabel(labelText)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); JTextField field = new JTextField(cols); GuiUtil.setEditableFalse(field); field.setHorizontalAlignment(JTextField.CENTER); field.setToolTipText(i18n(toolTip)); panel.add(field); values.add(panel); return field; }
Example 11
Source File: GfxdTop.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private static void createAndShowGUI(JPanel jtop) { JFrame frame = new JFrame("GfxdTop"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent contentPane = (JComponent) frame.getContentPane(); contentPane.add(jtop, BorderLayout.CENTER); contentPane.setOpaque(true); contentPane.setBorder(new EmptyBorder(12, 12, 12, 12)); frame.setContentPane(contentPane); frame.pack(); frame.setVisible(true); }
Example 12
Source File: OWSMPoliciesEditor.java From netbeans with Apache License 2.0 | 5 votes |
@Override public JComponent createWSEditorComponent( Node node ) throws InvalidDataException { if ( mySupport == null || myFileObject == null ){ JComponent component = new JPanel(); component.setLayout( new FlowLayout()); component.add( new JLabel(NbBundle.getMessage( OWSMPoliciesEditor.class, "ERR_NoPoliciesSupport"))); // NOI18N return component; } myPanel = new PoliciesVisualPanel( myPolicyIds , myFileObject ); return myPanel; }
Example 13
Source File: ConstantVoltageExample.java From astor with GNU General Public License v2.0 | 5 votes |
public static JComponent createComponent() { JComponent container = new JPanel(); container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS)); Chart chart1 = createChart("Voltage", 550, 450, LegendPosition.InsideNE, true); Chart chart2 = createChart("Error Covariance", 450, 450, LegendPosition.InsideNE, false); constantVoltageTest(chart1, chart2); container.add(new XChartPanel(chart1)); container.add(new XChartPanel(chart2)); container.setBorder(BorderFactory.createLineBorder(Color.black, 1)); return container; }
Example 14
Source File: GuiMouseListener.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private void addBuildAction(JComponent parentMenuItem, BuildAction buildAction, Function<BuildAction, Action> guiActionBuilder) { final JMenuItem buildMenuItem; if (canPlayerCharacterPerformBuildAction(buildAction)) { buildMenuItem = MenuFactory.createJMenuItem(guiActionBuilder.apply(buildAction), soundIdReader); buildMenuItem.setText(buildAction.getSimpleDescription() + "..."); parentMenuItem.add(buildMenuItem); } else { buildMenuItem = createDisabledActionMenuItem(parentMenuItem, buildAction); } String tooltip = createTooltipForBuildAction(buildAction); buildMenuItem.setToolTipText(tooltip); addImageIcon(buildAction, buildMenuItem); }
Example 15
Source File: bug4337267.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void injectComponent(JComponent p, JComponent c, boolean shape) { if (shape) { setShaping(c); } p.removeAll(); p.add(c); }
Example 16
Source File: SkillDefaultEditor.java From gcs with Mozilla Public License 2.0 | 5 votes |
private void removeDefault() { JComponent parent = (JComponent) getParent(); parent.remove(this); if (parent.getComponentCount() == 0) { parent.add(new SkillDefaultEditor()); } parent.revalidate(); parent.repaint(); notifyActionListeners(); }
Example 17
Source File: GeneralSettings.java From stendhal with GNU General Public License v2.0 | 4 votes |
/** * Creates a drop-down selector for setting battle karma mode. */ private JComponent createCombatKarmaSelector() { int pad = SBoxLayout.COMMON_PADDING; final JLabel selectorLabel = new JLabel("Use karma in combat:"); final JComboBox<String> selector = new JComboBox<>(); for (final String mode : KARMA_SETTINGS) { selector.addItem(mode); } final RPObject player = StendhalClient.get().getPlayer(); // use player attribute if available to set combat karma mode final String currentMode; if (player.has(COMBAT_KARMA) && KARMA_SETTINGS.contains(player.get(COMBAT_KARMA))) { currentMode = player.get(COMBAT_KARMA); } else { currentMode = KARMA_SETTINGS.get(1); } selector.setSelectedItem(currentMode); selector.addActionListener(new ActionListener() { /** * Sends action to the server. */ @Override public void actionPerformed(ActionEvent e) { new SetCombatKarmaAction().sendAction(selector.getSelectedItem().toString()); } }); WtWindowManager.getInstance().registerSettingChangeListener("combat.karma", new SettingChangeListener() { /** * Updates the GUI when setting is changed via slash command. */ @Override public void changed(final String newValue) { selector.setSelectedItem(newValue); } }); final JComponent karmaBox = SBoxLayout.createContainer(SBoxLayout.VERTICAL, pad); final JComponent karmaHBox = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, pad); karmaHBox.add(selectorLabel); karmaHBox.add(selector); // tooltip info final String[][] tooltipData = { {"Never", KARMA_SETTINGS.get(0), "Karma will never be used."}, {"Normal (default)", KARMA_SETTINGS.get(1), "Karma is used for stronger enemies."}, {"Always", KARMA_SETTINGS.get(2), "Karma is used regardless of how strong or weak enemy is."} }; final StringBuilder descr = new StringBuilder(); descr.append("Karma can be used in combat to give a slight edge. It helps in three ways:"); descr.append("<br>1) Increases attack strength."); descr.append("<br>2) Increases defense."); descr.append("<br>3) Increases chances of hitting enemy."); descr.append("<br><br>The following three settings define when karma is used in combat:"); karmaHBox.setToolTipText(ConvenienceMapper.createTooltip(descr.toString(), tooltipData)); karmaBox.add(karmaHBox); return karmaBox; }
Example 18
Source File: Main.java From FancyBing with GNU General Public License v3.0 | 4 votes |
private static void addFiller(JComponent component) { Box.Filler filler = GuiUtil.createFiller(); filler.setAlignmentX(Component.LEFT_ALIGNMENT); component.add(filler); }
Example 19
Source File: SplashWindow.java From Rails with GNU General Public License v2.0 | 4 votes |
public SplashWindow(boolean isLoad, String initDetailsText) { //quit directly when no visualization required //all visualization related attributes remain null then if ("no".equals(Config.get("splash.window.open"))) return; //calculate estimated duration for the respective steps cumulativeDuration = new long[STEP_DURATION.length]; boolean isDockingLayout = "yes".equals(Config.get("or.window.dockablePanels")); for ( int i = 0; i < STEP_DURATION.length ; i++) { //only consider step if relevant for this setup if ( (isLoad || !STEP_GROUP_LOAD.contains(STEP_DURATION[i].labelConfigKey)) && (isDockingLayout || !STEP_GROUP_DOCKING_LAYOUT.contains(STEP_DURATION[i].labelConfigKey)) ) { totalDuration += STEP_DURATION[i].expectedDurationInMillis; } cumulativeDuration[i] = totalDuration; } //set up dynamic elements myWin = new JWindow(); leftIcon = new JLabel(); setIcon(leftIcon, ICONS[currentIconIndex][0]); leftIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder())); rightIcon = new JLabel(); setIcon(rightIcon, ICONS[currentIconIndex][1]); rightIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder())); progressBar = new JProgressBar(0,(int)totalDuration); progressBar.setStringPainted(true); progressBar.setMinimum(0); stepLabel = new JLabel(" "); // needed in order to allocate vertical space stepLabel.setAlignmentX(Component.CENTER_ALIGNMENT); stepLabel.setBorder(new EmptyBorder(5,5,5,5)); //set up static elements JLabel railsLabel = new JLabel("Rails " +Config.getVersion()); railsLabel.setFont(railsLabel.getFont().deriveFont( (float)2.0 * railsLabel.getFont().getSize())); railsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); String commandTextKey = isLoad ? "Splash.command.loadGame" : "Splash.command.newGame"; JLabel commandLabel = new JLabel( LocalText.getText(commandTextKey,initDetailsText)); commandLabel.setFont(commandLabel.getFont().deriveFont(Font.BOLD)); commandLabel.setAlignmentX(Component.CENTER_ALIGNMENT); //plug elements together and set up layout JPanel railsCommandPanel = new JPanel(); railsCommandPanel.setLayout(new BoxLayout(railsCommandPanel, BoxLayout.Y_AXIS)); railsCommandPanel.add(railsLabel); railsCommandPanel.add(commandLabel); railsCommandPanel.setBorder(new EmptyBorder(3,3,3,3)); JPanel idPanel = new JPanel(); idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS)); idPanel.add(leftIcon); idPanel.add(railsCommandPanel); idPanel.add(rightIcon); idPanel.setBorder(new EmptyBorder(3,3,3,3)); JComponent contentPane = (JComponent)myWin.getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.add(idPanel); contentPane.add(progressBar); contentPane.add(stepLabel); contentPane.setBorder(new CompoundBorder(new EtchedBorder(),new EmptyBorder(5,5,5,5))); //perform layout within the EDT //blocking call as further initialization requires the layout to be frozen try { SwingUtilities.invokeAndWait(new Thread() { @Override public void run() { myWin.pack(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); myWin.setLocation( (dim.width - myWin.getSize().width) / 2, (dim.height - myWin.getSize().height) / 2 ); myWin.setVisible(true); } }); } catch (Exception e) {} progressVisualizer = new ProgressVisualizer(); notifyOfStep(DUMMY_STEP_START); progressVisualizer.start(); }
Example 20
Source File: MessageDialogs.java From FancyBing with GNU General Public License v3.0 | 4 votes |
private static void addFiller(JComponent component) { Box.Filler filler = GuiUtil.createFiller(); filler.setAlignmentX(Component.LEFT_ALIGNMENT); component.add(filler); }