/** * Deserializes this {@code DragGestureRecognizer}. This method first * performs default deserialization for all non-{@code transient} * fields. This object's {@code DragGestureListener} is then * deserialized as well by using the next object in the stream. * * @since 1.4 */ @SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { ObjectInputStream.GetField f = s.readFields(); DragSource newDragSource = (DragSource)f.get("dragSource", null); if (newDragSource == null) { throw new InvalidObjectException("null DragSource"); } dragSource = newDragSource; component = (Component)f.get("component", null); sourceActions = f.get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); events = (ArrayList<InputEvent>)f.get("events", new ArrayList<>(1)); dragGestureListener = (DragGestureListener)s.readObject(); }
/** * Moves mouse pointer in the center of a given {@code comp} component * and performs a left mouse button click using the {@code robot} parameter * with the {@code delay} delay between press and release. */ public static void clickOnComp(final Component comp, final Robot robot, int delay) { pointOnComp(comp, robot); robot.delay(delay); robot.mousePress(InputEvent.BUTTON1_MASK); robot.delay(delay); robot.mouseRelease(InputEvent.BUTTON1_MASK); }
private void checkStoredGlassPane() { // remember current glass pane to set back at end of dragging over this compoment if (!DropGlassPane.isOriginalPaneStored() || dropPane == null) { if (DropGlassPane.isOriginalPaneStored()) { // Original panel is stored, but dropPane == null, see #236349. DropGlassPane.putBackOriginal(); } Component comp = table.getRootPane().getGlassPane(); DropGlassPane.setOriginalPane(table, comp, comp.isVisible()); // set glass pane for paint selection line dropPane = DropGlassPane.getDefault(table); table.getRootPane().setGlassPane(dropPane); dropPane.revalidate(); dropPane.setVisible(true); log("dropPane was set"); // NOI18N } }
@Override protected Component createFirstTab(JTabbedPane pane) { sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework, framework.getAccessRules()); sectorNameEditor = new SectorNameEditor(dataPlugin, framework, framework.getAccessRules()) { @Override protected void createReplacementPanel(JPanel ignoreMe) { } @Override public Stream getStream() { return sectorRowsEditor.getStream(); } }; sectorNameEditor.box.setVisible(false); sectorRowsEditor.setSectorNameEditor(sectorNameEditor); pane.addTab(ResourceLoader.getString("name"), sectorRowsEditor); return sectorNameEditor; }
private void handleDocumentEvent(DocumentEvent e, Shape a, ViewFactory f) { int n = calculateLineCount(); if (this.nlines != n) { this.nlines = n; WrappedSyntaxView.this.preferenceChanged(this, false, true); // have to repaint any views after the receiver. RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer(); textArea.repaint(); // Must also revalidate container so gutter components, such // as line numbers, get updated for this line's new height Gutter gutter = RSyntaxUtilities.getGutter(textArea); if (gutter!=null) { gutter.revalidate(); gutter.repaint(); } } else if (a != null) { Component c = getContainer(); Rectangle alloc = (Rectangle) a; c.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } }
static DescriptablePathChooser converChoosers(final ComponentChooser[] choosers) { return (new DescriptablePathChooser() { @Override public boolean checkPathComponent(int depth, Object component) { return choosers[depth].checkComponent((Component) component); } @Override public int getDepth() { return choosers.length; } @Override public String getDescription() { return createDescription(choosers); } @Override public String toString() { return "JMenuOperator.converChoosers.DescriptablePathChooser{description = " + getDescription() + '}'; } }); }
/** Requests refresh of our lookup everytime component is chagned. */ public void propertyChange(java.beans.PropertyChangeEvent evt) { if (TopComponent.Registry.PROP_ACTIVATED.equals (evt.getPropertyName())) { org.openide.util.Utilities.actionsGlobalContext ().lookup (javax.swing.ActionMap.class); } if ("permanentFocusOwner".equals(evt.getPropertyName())) { Component[] arr = { (Component)evt.getNewValue() }; if (arr[0] instanceof AbstractButton) { Action a = ((AbstractButton)arr[0]).getAction(); if (a instanceof ContextAwareAction) { // ignore focus change into a button with our action return; } } blickActionMap(null, arr); } }
protected void createRenderers() { final TableCellRenderer boolRend = getDefaultRenderer(Boolean.class); setDefaultRenderer(Boolean.class, new DisabledCellRenderer() { /** * */ private static final long serialVersionUID = 1L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cbox = boolRend.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); cbox.setEnabled(true); if (value == null) { Component disabled = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); cbox.setBackground(disabled.getBackground()); cbox.setEnabled(false); } return cbox; } }); }
@Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { int selectedIndex = ((Integer) value).intValue(); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } ImageIcon icon = iconArray[selectedIndex]; setIcon(icon); return this; }
protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) { Color oldColor = g.getColor(); int h = height; int w = width; g.translate(x, y); g.setColor(getHighlightOuterColor(c)); g.drawLine(0, 0, 0, h - 2); g.drawLine(1, 0, w - 2, 0); g.setColor(getShadowOuterColor(c)); g.drawLine(0, h - 1, w - 1, h - 1); g.drawLine(w - 1, 0, w - 1, h - 2); g.translate(-x, -y); g.setColor(oldColor); }
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { String[] tupel; if (value instanceof String) { tupel = ParameterTypeTupel.transformString2Tupel((String) value); } else { tupel = (String[]) value; } if (panel == null) { constructPanel(tupel); } for (int i = 0; i < editors.length; i++) { editors[i].getTableCellEditorComponent(null, tupel[i], false, 0, 0); } return panel; }
/** This method is called by Swing to actually draw the borders. */ public void paintBorder(Component component, Graphics graphics, int x, int y, int width, int height) { if (width < 1 || height < 1) return; Color old = graphics.getColor(); if (top != null) { graphics.setColor(top); graphics.drawLine(x, y, x + width - 1, y); } if (bottom != null) { graphics.setColor(bottom); graphics.drawLine(x, y + height - 1, x + width - 1, y + height - 1); } if (left != null) { graphics.setColor(left); graphics.drawLine(x, y, x, y + height - 1); } if (right != null) { graphics.setColor(right); graphics.drawLine(x + width - 1, y, x + width - 1, y + height - 1); } graphics.setColor(old); }
@Override public Component getComponent() { if (gui == null) { gui = new TemplateChooserPanelGUI(includeTemplatesWithProjects); gui.addChangeListener(this); gui.setDefaultActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { if( null != wizard ) { wizard.doNextClick(); } } }); } return gui; }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (isSelected){ setBackground(UIManager.getColor("List.selectionBackground")); //NOI18N setForeground(UIManager.getColor("List.selectionForeground")); //NOI18N } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (!useTreeColors && (sel || hasFocus)) { SynthLookAndFeel.setSelectedUI((SynthLabelUI)SynthLookAndFeel. getUIOfType(getUI(), SynthLabelUI.class), sel, hasFocus, tree.isEnabled(), false); } else { SynthLookAndFeel.resetSelectedUI(); } return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); }
/** * */ public static JTableRenderer getVertex(Component component) { while (component != null) { if (component instanceof JTableRenderer) { return (JTableRenderer) component; } component = component.getParent(); } return null; }
@Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, value.toString().replace('_', ' '), index, isSelected, cellHasFocus); if (!isSelected) { listCellRendererComponent.setBackground(Colors.PANEL_BACKGROUND); } return spacerPanel; }
public static Future<?> showDetailsDisableable( Component parent, Throwable thrown, String details, Object key, String messageKey, Object... args) { return ProblemDialog.showDetailsDisableable( JOptionPane.WARNING_MESSAGE, parent, thrown, details, key, messageKey, args ); }
/** * Creates a {@code GroupLayout} for the specified {@code Container}. * * @param host the {@code Container} the {@code GroupLayout} is * the {@code LayoutManager} for * @throws IllegalArgumentException if host is {@code null} */ public GroupLayout(Container host) { if (host == null) { throw new IllegalArgumentException("Container must be non-null"); } honorsVisibility = true; this.host = host; setHorizontalGroup(createParallelGroup(Alignment.LEADING, true)); setVerticalGroup(createParallelGroup(Alignment.LEADING, true)); componentInfos = new HashMap<Component,ComponentInfo>(); tmpParallelSet = new HashSet<Spring>(); }
public boolean queueSurfaceDataReplacing(Component c, Runnable r) { if (c instanceof RootPaneContainer) { AppContext appContext = SunToolkit.targetToAppContext(c); RepaintManager.currentManager(appContext). nativeQueueSurfaceDataRunnable(appContext, c, r); return true; } return super.queueSurfaceDataReplacing(c, r); }
@Override public synchronized Component prepareRenderer( TableCellRenderer renderer, int row, int column) { //In case we have a repaint thread that is in the process of //repainting an obsolete table, just ignore the call. //It can happen when MBean selection is switched at a very quick rate if (row >= getRowCount()) { return null; } Component comp = super.prepareRenderer(renderer, row, column); if (normalFont == null) { normalFont = comp.getFont(); boldFont = normalFont.deriveFont(Font.BOLD); } UserDataCell cell = getUserDataCell(row, 2); if (column == 2 && cell != null) { comp.setFont(boldFont); int size = cell.getHeight(); if (size > 0) { if (getRowHeight(row) != size) { setRowHeight(row, size); } } } else { comp.setFont(normalFont); } return comp; }
private void setToolTip(Component renderer, Property<?> property) throws IllegalAccessException, InvocationTargetException { if (renderer instanceof JLabel) { Object val = property.getValue(); if (val != null) { ((JLabel) renderer).setToolTipText(val.toString()); } } }
private void changeSelection( MouseEvent e ) { Point p = e.getPoint(); // It may have occured on the button that invoked the tabtable if (e.getSource() != this) { p = SwingUtilities.convertPoint((Component) e.getSource(), p, pTable); } if (pTable.contains(p)) { int row = pTable.rowAtPoint(p); int col = pTable.columnAtPoint(p); pTable.changeSelection(row, col, false, false); } else { pTable.clearSelection(); } }
static Window getComponentWindow(Component component) { while (true) { if (component == null) { return null; } else if (component instanceof Window) { return (Window) component; } else { component = component.getParent(); } } }
/** * Maps {@code JLabel.getLabelFor()} through queue */ public Component getLabelFor() { return (runMapping(new MapAction<Component>("getLabelFor") { @Override public Component map() { return ((JLabel) getSource()).getLabelFor(); } })); }
/** * Set up and show the dialog. The first Component argument determines which * frame the dialog depends on; it should be a component in the dialog's * controlling frame. The second Component argument should be null if you * want the dialog to come up with its left corner in the center of the * screen; otherwise, it should be the component on top of which the dialog * should appear. */ public TransferDialog(Component frameComp, Component locationComp, String title, I_TickerManager tickerManager) { super(frameComp, locationComp, title, tickerManager); String[] currencies = {"EUR", "USD", "SEK" , "NOK"}; currencyList = new JComboBox(currencies); currencyList.setEditable(true); currencyList.addActionListener(this); currencyList.setSelectedIndex(0); currencyList.setActionCommand(CURRENCY_CHANGED); totalCostField = new JTextField(FIELD_LEN); totalCostField.setEditable(true); totalCostField.setText(""); totalCostField.addKeyListener(this); dateFieldLabel = new JLabel("Maksupäivä: "); dateFieldLabel.setLabelFor(dateChooser); totalCostFieldLabel = new JLabel("yhteensä: "); totalCostFieldLabel.setLabelFor(totalCostField); currencyFieldLabel = new JLabel("Valuutta: "); updateRateFieldCcy((String) currencyList.getSelectedItem(), true); init(getDialogLabels(), getDialogComponents()); }
@Override public void pushKey(ComponentOperator oper, int keyCode, int modifiers, Timeout pushTime) { Component nativeContainer = findNativeParent(oper.getSource()); pressKey(nativeContainer, keyCode, modifiers); pushTime.sleep(); releaseKey(nativeContainer, keyCode, modifiers); }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String label; // First element in the list is new action/sense whatever... if (index == 0) { label = value.toString(); } else { T item = (T) value; label = getRenderedLabel(item); } return listRenderer.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus); }
/** * {@inheritDoc} */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Player player = (Player)table.getValueAt(row, PlayersTable.PLAYER_COLUMN); final NationType nationType = ((Nation)table.getValueAt(row, PlayersTable.NATION_COLUMN)).getType(); JLabel label; switch (advantages) { case SELECTABLE: return Utility.localizedLabel(Messages.nameKey((player == null) ? nationType : player.getNationType())); case FIXED: label = Utility.localizedLabel(Messages.nameKey(nationType)); break; case NONE: default: label = Utility.localizedLabel("none"); break; } label.setForeground((player != null && player.isReady()) ? Color.GRAY : table.getForeground()); label.setBackground(table.getBackground()); Utility.localizeToolTip(this, StringTemplate .key(advantages.getShortDescriptionKey())); return label; }
private Component createBottom() { final JPanel panel = new JPanel(new GridLayout(1, 4, 5, 0)); panel.add(bBack); panel.add(bNext); panel.add(bCancel); panel.add(bFinish); final JPanel p = new JPanel(new FlowLayout()); p.add(panel); final JPanel res = new JPanel(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; final JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); p1.add(etap); c.weightx = 1.0; c.gridx = 0; c.gridy = 0; res.add(p1, c); c.weightx = 0; c.gridx = 1; c.gridy = 0; res.add(p, c); return res; }
/** * Initialization of the wizard iterator. */ public void initialize(TemplateWizard wizard) { index = 0; Project project = Templates.getProject( wizard ); panels = createPanels (project, wizard); // Creating steps. Object prop = wizard.getProperty (WizardDescriptor.PROP_CONTENT_DATA); // NOI18N String[] beforeSteps = null; if (prop instanceof String[]) { beforeSteps = (String[])prop; } String[] steps = createSteps (beforeSteps, panels); 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 #. jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i)); // NOI18N // Step name (actually the whole list for reference). jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N } } }
private Component createPlotAllCheckbox() { drawAllIcons = new JCheckBox("Draw All Center Icons",false); drawAllIcons.addActionListener(this); drawAllIcons.setActionCommand("drawAll"); drawAllIcons.setEnabled(false); return drawAllIcons; }
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { Component c = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); c.setForeground(isEditable((DefaultMutableTreeNode) value) ? Color.BLACK : Color.GRAY); return c; }
protected Component getComponent(FontBuilder builder) { JLabel label = new JLabel(); label.setHorizontalAlignment(JLabel.CENTER); label.setFont(builder.createInstance()); label.setText(Bundle.FontView_Preview()); return label; }
/** * Create the installation window which the pages appear in. */ private void createWindow() { JImage sideImage = new JImage(getClass().getResource(imagePath)); sideImage.setVerticalAlignment(SwingConstants.TOP); sideImage.setAlignmentY(Component.TOP_ALIGNMENT); pageArea = new JPanel(); pageArea.setLayout(new GridLayout(1, 1)); JSeparator bar = new JSeparator(); navArea = new JPanel(); navArea.setLayout(new GridLayout(1, 1)); JPanel bottom = new JPanel(new BorderLayout(5, 5)); bottom.add(bar, BorderLayout.NORTH); bottom.add(navArea, BorderLayout.CENTER); JPanel all = new JPanel(new BorderLayout(5, 5)); all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); all.add(sideImage, BorderLayout.WEST); all.add(pageArea, BorderLayout.CENTER); all.add(bottom, BorderLayout.SOUTH); frame = new JFrame(); frame.getContentPane().add(all); frame.setTitle(productName); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
@Override public void mouseEntered(MouseEvent e) { Component component = e.getComponent(); if (component instanceof AbstractButton) { AbstractButton button = (AbstractButton) component; button.setBorderPainted(true); } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return comp; }
/** * Return the first SplitPane ancestor with a different orientation from this SplitPane * * @return */ public SplitPane getTransverseSplit() { SplitPane split = null; for (Component c = getParent(); c != null; c = c.getParent()) { if (c instanceof SplitPane) { SplitPane p = (SplitPane) c; if (p.getOrientation() != getOrientation() && SwingUtilities.isDescendingFrom(this, p.getBaseComponent())) { split = p; break; } } } return split; }
PopupPane(Component content, boolean resize) { super(new BorderLayout()); add(content, BorderLayout.CENTER); setFocusCycleRoot(true); setFocusTraversalPolicyProvider(true); setFocusTraversalPolicy(new PopupFocusTraversalPolicy()); if (UIUtils.isAquaLookAndFeel()) { if (resize) { setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); addMouseListener(this); addMouseMotionListener(this); } } else { Border border = BorderFactory.createLineBorder(UIUtils.getDisabledLineColor()); if (resize) { setBorder(BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(8, 8, 8, 8))); addMouseListener(this); addMouseMotionListener(this); } else { setBorder(border); } } }