javax.swing.JComponent Java Examples

The following examples show how to use javax.swing.JComponent. 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: MostradorDeCodigo.java    From brModelo with GNU General Public License v3.0 6 votes vote down vote up
public MostradorDeCodigo(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    lblHtml = new JLabel();
    scrPrincipal.getViewport().add(lblHtml);
    //dbModel.InicieAnsi2011();
    
    getRootPane().registerKeyboardAction(e -> {
        //this.dispose();
        //setResultado(JOptionPane.CANCEL_OPTION);
        setVisible(false);

    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
    getRootPane().registerKeyboardAction(e -> {
        //setResultado(JOptionPane.OK_OPTION);
        setVisible(false);
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, java.awt.event.InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    getRootPane().registerKeyboardAction(e -> {
        btnCopyActionPerformed(null);
    }, KeyStroke.getKeyStroke(KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    setTitle(Editor.fromConfiguracao.getValor("Controler.interface.Titulo.MostradorDeCodigo"));
    this.pack();
}
 
Example #2
Source File: DefaultSwingBundleDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void valueChanged(long bid)
{
  boolean bHasVisible = false;
  for (final JComponent comp : components) {
    if (comp.isShowing()) {
      bHasVisible = true;
      break;
    }
  }
  lastBID = bid;

  if (bHasVisible) {
    valueChangedLazy(bid);
  }
}
 
Example #3
Source File: SeaGlassTextFieldUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void mouseMoved(MouseEvent e) {
    currentMouseX = e.getX();
    currentMouseY = e.getY();
    
    Cursor cursorToUse = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR);
    if (isOverCancelButton() || isOverFindButton()) {
       cursorToUse = Cursor.getDefaultCursor();  
    }
    JComponent c = (JComponent) e.getSource();
    if (!cursorToUse.equals(c.getCursor())) {
        c.setCursor(cursorToUse);
    }
    super.mouseMoved(e);
}
 
Example #4
Source File: ProgressHandleFactoryTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@RandomlyFails // NB-Core-Build #1176
public void testCustomComponentIsInitialized() {
    Controller.defaultInstance = new TestController();
    
    ProgressHandle handle = ProgressHandleFactory.createHandle("task 1");

    // Warning, this will make the handle to work with a new Controller, not TestController.
    JComponent component = ProgressHandleFactory.createProgressComponent(handle);
    handle.start(15);
    handle.progress(2);
    waitForTimerFinish();
    
    assertEquals(15, ((JProgressBar) component).getMaximum());
    assertEquals(2, ((JProgressBar) component).getValue());
    
    handle = ProgressHandleFactory.createHandle("task 2");
    component = ProgressHandleFactory.createProgressComponent(handle);
    
    handle.start(20);
    waitForTimerFinish();
    
    assertEquals(20, ((JProgressBar) component).getMaximum());
    assertEquals(0, ((JProgressBar) component).getValue());
    
}
 
Example #5
Source File: ToolsAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "LAB_ToolsActionInitializing=Initializing..."
})
@Override
public JComponent[] synchMenuPresenters(JComponent[] items) {
    G g = gl(50);
    if (g == null) {
        JMenuItem init = new JMenuItem();
        init.setText(Bundle.LAB_ToolsActionInitializing());
        init.setEnabled(false);
        return new JMenuItem[] { init };
    }
    if (timestamp == g.getTimestamp()) {
        return items;
    }
    // generate directly list of menu items
    List<JMenuItem> l = generate(toolsAction, true);
    timestamp = gl().getTimestamp();
    return l.toArray(new JMenuItem[l.size()]);
}
 
Example #6
Source File: DockingWindowManagerTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void assertStacked(DockingWindowManager dwm, ComponentProvider... providers) {

		Integer x = null;
		Integer y = null;

		for (ComponentProvider p : providers) {

			ComponentPlaceholder ph = dwm.getActivePlaceholder(p);
			ComponentNode n = ph.getNode();
			JComponent c = n.getComponent();
			Point l = c.getLocationOnScreen();

			if (x == null) {
				x = l.x;
				y = l.y;
			}
			else {
				assertEquals("Providers are not stacked together", x.intValue(), l.x);
				assertEquals("Providers are not stacked together", y.intValue(), l.y);
			}

		}
	}
 
Example #7
Source File: MultiTabbedPaneUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a multiplexing UI instance if any of the auxiliary
 * <code>LookAndFeel</code>s supports this UI.  Otherwise, just returns the
 * UI object obtained from the default <code>LookAndFeel</code>.
 */
public static ComponentUI createUI(JComponent a) {
    ComponentUI mui = new MultiTabbedPaneUI();
    return MultiLookAndFeel.createUIs(mui,
                                      ((MultiTabbedPaneUI) mui).uis,
                                      a);
}
 
Example #8
Source File: MultiSeparatorUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>contains</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public boolean contains(JComponent a, int b, int c) {
    boolean returnValue =
        ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
    }
    return returnValue;
}
 
Example #9
Source File: MultiSliderUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example #10
Source File: ClasspathCategoryProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JComponent createComponent(Category category, Lookup context) {
    Project project = context.lookup(Project.class);
    ProjectAccessor acc = context.lookup(ProjectAccessor.class);
    AuxiliaryConfiguration aux = context.lookup(AuxiliaryConfiguration.class);
    assert aux != null;
    assert acc != null;
    assert project != null;
    
    final JdkConfiguration jdkConf = new JdkConfiguration(project, acc.getHelper(), acc.getEvaluator());
    
    final ClasspathPanel panel = new ClasspathPanel(jdkConf);
    final JavaPlatform initialPlatform = (JavaPlatform) panel.javaPlatform.getSelectedItem();
    ProjectModel pm = context.lookup(ProjectModel.class);
    assert pm != null;
    panel.setModel(pm);
    pm.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            panel.updateControls();
        }
    });
    category.setOkButtonListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JavaPlatform p = (JavaPlatform) panel.javaPlatform.getSelectedItem();
            if (p != initialPlatform) {
                try {
                    jdkConf.setSelectedPlatform(p);
                } catch (IOException x) {
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, x);
                }
            }
        }
    });
    return panel;
    
}
 
Example #11
Source File: MultiFileChooserUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a multiplexing UI instance if any of the auxiliary
 * <code>LookAndFeel</code>s supports this UI.  Otherwise, just returns the
 * UI object obtained from the default <code>LookAndFeel</code>.
 */
public static ComponentUI createUI(JComponent a) {
    ComponentUI mui = new MultiFileChooserUI();
    return MultiLookAndFeel.createUIs(mui,
                                      ((MultiFileChooserUI) mui).uis,
                                      a);
}
 
Example #12
Source File: AbstractDesignEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Used to get the JComponent used for the structure pane. Usually a container for the structure component or the structure component itself.
 * @return the JComponent
 */
public JComponent getStructureView(){
    if (structureView ==null){
        structureView = createStructureComponent();
        structureView.addPropertyChangeListener(new NodeSelectedListener());
    }
    return structureView;
}
 
Example #13
Source File: HexHighlightMouseListener.java    From Rails with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param pf Portfolio which is dynamically evaluated at mouse-even-time for
 * any contained private companies
 */
public static void addMouseListener(JComponent c,ORUIManager orUIManager,PortfolioModel pf) {
    if (isEnabled(false)) {
        HexHighlightMouseListener l = new HexHighlightMouseListener(orUIManager);
        l.portfolio = pf;
        c.addMouseListener(l);
    }
}
 
Example #14
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void hideLabelAndLabelFor(JComponent component, String lab) {
    JLabel label = findLabel(component, lab);
    if(label != null) {
        label.setVisible(false);
        Component c = label.getLabelFor();
        if(c != null) {
            c.setVisible(false);
        }
    }
}
 
Example #15
Source File: NimbusLookAndFeel.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
 
Example #16
Source File: PopupPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public PopupPane() {
    listComponents = new HashSet<ListComponent>();
    view = new JPanel();
    GridLayout grid = new GridLayout(0, 1);
    grid.setHgap(0);
    grid.setVgap(0);
    view.setLayout(grid);
    view.setBorder(BorderFactory.createEmptyBorder());
    setName("progresspopup"); //NOI18N
    setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    setViewportView(view);
    setFocusable(true);
    setRequestFocusEnabled(true);

    Action down = new MoveDownAction();
    getActionMap().put("Move-Down", down);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Move-Down");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Move-Down");
    
    Action up = new MoveUpAction();
    getActionMap().put("Move-Up", up);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Move-Up");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Move-Up");
    Action cancel = new CancelAction();
    getActionMap().put("Cancel-Task", cancel);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Cancel-Task");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Cancel-Task");
    
    Action select = new SelectAction();
    getActionMap().put("select-task", select);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "select-task");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "select-task");
    
    
    setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
 
Example #17
Source File: FormLayoutHelper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void addComponent(
        JComponent component, Group parallelColumnGroup) {
    parallelColumnGroup.addComponent(component,
            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
            Short.MAX_VALUE);
}
 
Example #18
Source File: MultiTabbedPaneUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a multiplexing UI instance if any of the auxiliary
 * <code>LookAndFeel</code>s supports this UI.  Otherwise, just returns the
 * UI object obtained from the default <code>LookAndFeel</code>.
 */
public static ComponentUI createUI(JComponent a) {
    ComponentUI mui = new MultiTabbedPaneUI();
    return MultiLookAndFeel.createUIs(mui,
                                      ((MultiTabbedPaneUI) mui).uis,
                                      a);
}
 
Example #19
Source File: MultiScrollPaneUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getPreferredSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
    }
    return returnValue;
}
 
Example #20
Source File: MultiColorChooserUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a multiplexing UI instance if any of the auxiliary
 * <code>LookAndFeel</code>s supports this UI.  Otherwise, just returns the
 * UI object obtained from the default <code>LookAndFeel</code>.
 */
public static ComponentUI createUI(JComponent a) {
    ComponentUI mui = new MultiColorChooserUI();
    return MultiLookAndFeel.createUIs(mui,
                                      ((MultiColorChooserUI) mui).uis,
                                      a);
}
 
Example #21
Source File: MultiViewportUI.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example #22
Source File: InfoComponentFactory.java    From JglTF with MIT License 5 votes vote down vote up
/**
 * Create an info component with the given message
 * 
 * @param string The message string
 * @return The component
 */
JComponent createMessageInfoPanel(String string)
{
    JPanel messageInfoPanel = new JPanel(new FlowLayout());
    messageInfoPanel.add(new JLabel(string));
    return messageInfoPanel;
}
 
Example #23
Source File: BackgroundErrorProcessor.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void reset() {
	for (JComponent c : colorMap.keySet()) {
		c.setBackground(colorMap.get(c));
		c.setToolTipText(null);
	}
	colorMap.clear();
}
 
Example #24
Source File: MultiTableUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getPreferredSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
    }
    return returnValue;
}
 
Example #25
Source File: XTextAreaPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
    Border vpBorder = scrollpane.getViewportBorder();
    if (vpBorder != null) {
        Rectangle r = scrollpane.getViewportBorderBounds();
        vpBorder.paintBorder(scrollpane, g, r.x, r.y, r.width, r.height);
    }
}
 
Example #26
Source File: CounterRequestTable.java    From javamelody with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize(JComponent c) {
	try {
		final String tipText = ((JToolTip) c).getTipText();
		final BufferedImage image = getRequestChartByRequestName(tipText);
		if (image != null) {
			// pas besoin de calculer la dimension de l'image, puisqu'elle est fixée avant d'avoir l'image
			return new Dimension(image.getWidth(), image.getHeight());
		}
		return super.getPreferredSize(c);
	} catch (final IOException e) {
		// s'il y a une erreur dans la récupération de l'image tant pis
		return super.getPreferredSize(c);
	}

	//			FontMetrics metrics = c.getFontMetrics(c.getFont());
	//		    String tipText = ((JToolTip) c).getTipText();
	//		    BufferedImage image = getRequestChartByRequestName(tipText);
	//		    if (tipText == null) {
	//		      tipText = "";
	//		    }
	//		    int width = SwingUtilities.computeStringWidth(metrics, tipText);
	//		    int height = metrics.getHeight() + image.getHeight(c);
	//
	//		    if (width < image.getWidth(c)) {
	//		      width = image.getWidth(c);
	//		    }
	//		    return new Dimension(width, height);
}
 
Example #27
Source File: AbstractWinViewTabDisplayerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void installUI (JComponent c) {
    super.installUI(c);
    initColors();
    c.setOpaque(true);
    getLayoutModel().setPadding( new Dimension( 2*TXT_X_PAD, 0 ) );
}
 
Example #28
Source File: MultiToolTipUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example #29
Source File: MultiToolBarUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Dimension getMinimumSize(JComponent a) {
    Dimension returnValue =
        ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
    }
    return returnValue;
}
 
Example #30
Source File: Text.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
protected JComponent getTextComponent(String locator) throws Exception {
    JTextPane textComponent = new JTextPane();
    textComponent.setText(getContent(locator));
    textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    textComponent.setEditable(false);
    textComponent.setCaretPosition(0);
    return textComponent;
}