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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
Source File: CardTransfertHandler.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
	DisplayableCard p = (DisplayableCard) c;
	Point pt = p.getLocation();
	SwingUtilities.convertPointToScreen(pt, p);
	dragLab.setIcon(p.toIcon());
	window.setLocation(pt);
	return MOVE;
}
 
Example #8
Source File: IntegerInputVerifier.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies the input with the side effect that the background color of {@code input} to {@code background} if
 * returns {@code true}, or {@code warningBackground} otherwise
 *
 * @param input component
 * @return if input is valid
 */
public boolean shouldYieldFocus(JComponent input) {
    boolean isValidInput = verify(input);
    if (isValidInput) {
        input.setBackground(background);
    } else {
        input.setBackground(warningBackground);
    }
    return isValidInput;
}
 
Example #9
Source File: MultiFileChooserUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getAccessibleChildrenCount</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 int getAccessibleChildrenCount(JComponent a) {
    int returnValue =
        ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
    }
    return returnValue;
}
 
Example #10
Source File: EditableTableHeader.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public Component prepareEditor(TableCellEditor editor, int index) {
	Object value = columnModel.getColumn(index).getHeaderValue();
	boolean isSelected = true;
	int row = HEADER_ROW;
	JTable table = getTable();
	Component comp = editor.getTableCellEditorComponent(table, value, isSelected, row, index);
	if (comp instanceof JComponent) {
		((JComponent) comp).setNextFocusableComponent(this);
	}
	return comp;
}
 
Example #11
Source File: ExampleVisualizer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
protected JComponent makeMainVisualizationComponent(Example example) {
	JComponent main;
	String[] columnNames = new String[] { "Attribute", "Value" };
	String[][] data = new String[exampleSet.getAttributes().allSize()][2];
	Iterator<Attribute> a = exampleSet.getAttributes().allAttributes();
	int counter = 0;
	while (a.hasNext()) {
		Attribute attribute = a.next();
		data[counter][0] = attribute.getName();
		data[counter][1] = getFormattedValue(example, attribute);
		counter++;
	}
	ExtendedJTable table = new ExtendedJTable();
	table.setDefaultEditor(Object.class, null);
	TableModel tableModel = new DefaultTableModel(data, columnNames);
	table.setRowHighlighting(true);
	table.setRowHeight(PropertyPanel.VALUE_CELL_EDITOR_HEIGHT);
	table.setModel(tableModel);
	main = new ExtendedJScrollPane(table);
	main.setBorder(null);
	int tableHeight = (int) (table.getPreferredSize().getHeight() + table.getTableHeader().getPreferredSize().getHeight()
			+ 5); // 5 for border
	if (tableHeight < main.getPreferredSize().getHeight()) {
		main.setPreferredSize(new Dimension((int) main.getPreferredSize().getWidth(), tableHeight));
	}
	return main;
}
 
Example #12
Source File: MultiSeparatorUI.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getAccessibleChild</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 Accessible getAccessibleChild(JComponent a, int b) {
    Accessible returnValue =
        ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
    }
    return returnValue;
}
 
Example #13
Source File: FormLayout.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
private static void invalidateAndRepaint(Container container) {
    if (container == null) {
        return;
    }
    if (container instanceof JComponent) {
        ((JComponent) container).revalidate();
    } else {
        container.invalidate();
    }
    container.repaint();
}
 
Example #14
Source File: MultiProgressBarUI.java    From jdk8u-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 MultiProgressBarUI();
    return MultiLookAndFeel.createUIs(mui,
                                      ((MultiProgressBarUI) mui).uis,
                                      a);
}
 
Example #15
Source File: OnSaveTabPanelController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JComponent getComponent(Lookup masterLookup) {
    if (panel == null) {
        panel = new OnSaveTabPanel();
    }
    return panel;
}
 
Example #16
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 #17
Source File: MultiOptionPaneUI.java    From openjdk-jdk9 with GNU General Public License v2.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 =
        uis.elementAt(0).contains(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        uis.elementAt(i).contains(a,b,c);
    }
    return returnValue;
}
 
Example #18
Source File: MultiDesktopIconUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getAccessibleChildrenCount</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 int getAccessibleChildrenCount(JComponent a) {
    int returnValue =
        ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
    }
    return returnValue;
}
 
Example #19
Source File: MultiTabbedPaneUI.java    From jdk8u-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 #20
Source File: ChooseKnowledgeAction.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public ChooseKnowledgeAction(WorldObject playerCharacter, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader, World world, JComponent parent, ActionContainingArgs guiAction, JFrame parentFrame) {
	super();
	this.playerCharacter = playerCharacter;
	this.imageInfoReader = imageInfoReader;
	this.soundIdReader = soundIdReader;
	this.world = world;
	this.parent = parent;
	this.guiAction = guiAction;
	this.parentFrame = parentFrame;
}
 
Example #21
Source File: MultiSliderUI.java    From openjdk-jdk9 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 =
        uis.elementAt(0).getMinimumSize(a);
    for (int i = 1; i < uis.size(); i++) {
        uis.elementAt(i).getMinimumSize(a);
    }
    return returnValue;
}
 
Example #22
Source File: SlidingSpinner.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
SlidingSpinner(ColorPanel panel, JComponent label) {
    this.panel = panel;
    this.label = label;
    this.slider.addChangeListener(this);
    this.spinner.addChangeListener(this);
    DefaultEditor editor = (DefaultEditor) this.spinner.getEditor();
    ValueFormatter.init(3, false, editor.getTextField());
    editor.setFocusable(false);
    this.spinner.setFocusable(false);
}
 
Example #23
Source File: MultiTableUI.java    From openjdk-jdk8u-backup 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 MultiTableUI();
    return MultiLookAndFeel.createUIs(mui,
                                      ((MultiTableUI) mui).uis,
                                      a);
}
 
Example #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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);
        }
    });
}