/**Lazily create (or create a new instance of) the radio button editor */ private InplaceEditor getRadioEditor(boolean newInstance) { RadioInplaceEditor result; if (newInstance) { result = new RadioInplaceEditor(tableUI); } else { if (radio == null) { radio = new RadioInplaceEditor(tableUI); //Mainly for debugging ((JComponent) radio).setName( "RadioEditor for " + getClass().getName() + "@" + System.identityHashCode(this) ); //NOI18N } result = (RadioInplaceEditor) radio; } result.setUseTitle(useLabels); return result; }
public void connect(PropertyEditor pe, PropertyEnv env) { if (!tableUI && (env != null) && useTitle) { setBorder(new TitledBorder(env.getFeatureDescriptor().getDisplayName())); } else { setBorder(null); } editor = pe; String[] tags = editor.getTags(); group = new ButtonGroup(); InvRadioButton[] buttons = getButtons(tags.length); if (env != null) { setEnabled(env.isEditable()); } for (int i = 0; i < tags.length; i++) { InvRadioButton jr = buttons[i]; configureButton(jr, tags[i]); add(jr); } }
public void connect(PropertyEditor pe, PropertyEnv env) { super.connect(pe, env); needLayout = true; }
public void paint(Graphics g) { if (isShowing()) { super.paint(g); } else { getLayout().layoutContainer(this); Component[] c = getComponents(); Color col = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); for (int i = 0; i < c.length; i++) { Rectangle r = c[i].getBounds(); if (g.hitClip(r.x, r.y, r.width, r.height)) { Graphics g2 = g.create(r.x, r.y, r.width, r.height); try { c[i].paint(g2); } finally { g2.dispose(); } } } if (getBorder() != null) { super.paintBorder(g); } } finally { g.setColor(col); } } }
public void handleInitialInputEvent(InputEvent e) { System.err.println("HandleInitialInputEvent"); getLayout().layoutContainer(this); if (e instanceof MouseEvent) { Point p = SwingUtilities.convertPoint((JComponent) e.getSource(), ((MouseEvent) e).getPoint(), this); Component c = getComponentAt(p); if (c instanceof JRadioButton) { ((JRadioButton) c).setSelected(true); c.requestFocus(); fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS)); } } else { Component[] c = getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof JRadioButton) { if (((JRadioButton) c[i]).isSelected()) { c[i].requestFocusInWindow(); } } } } }
/** Renderer version overrides this */ protected void configureButton(InvRadioButton ire, String txt) { ire.addActionListener(this); if (editor.getTags().length == 1) { ire.setEnabled(false); } else { ire.setEnabled(isEnabled()); } if (tableUI) { ire.setFocusable(false); } else { ire.setFocusable(true); } ire.setText(txt); if (txt.equals(editor.getAsText())) { ire.setSelected(true); } else { ire.setSelected(false); } ire.setFont(getFont()); ire.setBackground(getBackground()); ire.setForeground(getForeground()); group.add(ire); }
public void actionPerformed(ActionEvent e) { ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS); fireActionPerformed(ae); }
private InvRadioButton[] getButtons(int count) { InvRadioButton[] result = new InvRadioButton[count]; Iterator<InvRadioButton> i = buttonCache.iterator(); int idx = 0; while (i.hasNext() && (idx < count)) { result[idx] = i.next(); if (result[idx] != null) { result[idx].setEnabled(true); result[idx].setSelected(false); idx++; } } for (; idx < count; idx++) { result[idx] = createButton(); buttonCache.add(result[idx]); } return result; }
public void paint (Graphics g) { if (isShowing()) { super.paint(g); } else { getLayout().layoutContainer(this); Component[] c = getComponents(); Color col = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0,0, getWidth(),getHeight()); for (int i=0; i < c.length; i++) { Rectangle r = c[i].getBounds(); if (g.hitClip(r.x, r.y,r.width,r.height)) { Graphics g2 = g.create(r.x, r.y, r.width, r.height); try { c[i].paint(g2); } finally { g2.dispose(); } } } if (getBorder() != null) { super.paintBorder(g); } } finally { g.setColor(col); } } }
public void handleInitialInputEvent(InputEvent e) { System.err.println("HandleInitialInputEvent"); getLayout().layoutContainer(this); if (e instanceof MouseEvent) { Point p = SwingUtilities.convertPoint( (JComponent)e.getSource(), ((MouseEvent) e).getPoint(), this); Component c = getComponentAt(p); if (c instanceof JRadioButton) { ((JRadioButton) c).setSelected(true); c.requestFocus(); fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS)); } } else { Component[] c = getComponents(); for (int i=0; i < c.length; i++) { if (c[i] instanceof JRadioButton) { if (((JRadioButton) c[i]).isSelected()) { c[i].requestFocusInWindow(); } } } } }
/** Renderer version overrides this */ protected void configureButton (InvRadioButton ire, String txt) { ire.addActionListener(this); if (editor.getTags().length == 1) { ire.setEnabled(false); } else { ire.setEnabled(isEnabled()); } if (tableUI) { ire.setFocusable(false); } else { ire.setFocusable(true); } ire.setText(txt); if (txt.equals(editor.getAsText())) { ire.setSelected(true); } else { ire.setSelected(false); } ire.setFont(getFont()); ire.setBackground(getBackground()); ire.setForeground(getForeground()); group.add(ire); }
public void actionPerformed(ActionEvent e) { ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS); fireActionPerformed(ae); }
private InvRadioButton[] getButtons(int count) { InvRadioButton[] result = new InvRadioButton[count]; Iterator i = buttonCache.iterator(); int idx=0; while (i.hasNext() && idx < count) { result[idx] = (InvRadioButton) i.next(); if (result[idx] != null) { result[idx].setEnabled(true); result[idx].setSelected(false); idx++; } } for (;idx < count; idx++) { result[idx] = createButton(); buttonCache.add(result[idx]); } return result; }
public void paint (Graphics g) { if (isShowing()) { super.paint(g); } else { getLayout().layoutContainer(this); Component[] c = getComponents(); Color col = g.getColor(); try { g.setColor(getBackground()); g.fillRect(0,0, getWidth(),getHeight()); for (int i=0; i < c.length; i++) { Rectangle r = c[i].getBounds(); if (g.hitClip(r.x, r.y,r.width,r.height)) { Graphics g2 = g.create(r.x, r.y, r.width, r.height); try { c[i].paint(g2); } finally { g2.dispose(); } } } if (getBorder() != null) { super.paintBorder(g); } } finally { g.setColor(col); } } }
public void connect(PropertyEditor pe, PropertyEnv env) { if (!tableUI && env != null && useTitle) { setBorder (new TitledBorder(env.getFeatureDescriptor().getDisplayName())); } else { setBorder(null); } editor = pe; String[] tags = editor.getTags(); group = new ButtonGroup(); InvRadioButton[] buttons=getButtons(tags.length); if (env != null) { setEnabled (env.isEditable()); } for (int i=0; i < tags.length; i++) { InvRadioButton jr = buttons[i]; configureButton (jr, tags[i]); add(jr); } }
public void handleInitialInputEvent(InputEvent e) { System.err.println("HandleInitialInputEvent"); getLayout().layoutContainer(this); if (e instanceof MouseEvent) { Point p = SwingUtilities.convertPoint( (JComponent)e.getSource(), ((MouseEvent) e).getPoint(), this); Component c = getComponentAt(p); if (c instanceof JRadioButton) { ((JRadioButton) c).setSelected(true); c.requestFocus(); fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS)); } } else { Component[] c = getComponents(); for (int i=0; i < c.length; i++) { if (c[i] instanceof JRadioButton) { if (((JRadioButton) c[i]).isSelected()) { c[i].requestFocusInWindow(); } } } } }
/** Renderer version overrides this */ protected void configureButton (InvRadioButton ire, String txt) { ire.addActionListener(this); if (editor.getTags().length == 1) { ire.setEnabled(false); } else { ire.setEnabled(isEnabled()); } if (tableUI) { ire.setFocusable(false); } else { ire.setFocusable(true); } ire.setText(txt); if (txt.equals(editor.getAsText())) { ire.setSelected(true); } else { ire.setSelected(false); } ire.setFont(getFont()); ire.setBackground(getBackground()); ire.setForeground(getForeground()); group.add(ire); }
/**Lazily create (or create a new instance of) the radio button editor */ private InplaceEditor getRadioEditor(boolean newInstance) { RadioInplaceEditor result; if (newInstance) { result = new RadioInplaceEditor(tableUI); } else { if (radio == null) { radio = new RadioInplaceEditor(tableUI); //Mainly for debugging ((JComponent) radio).setName("RadioEditor for " + getClass().getName() + "@" + System.identityHashCode(this)); //NOI18N } result = (RadioInplaceEditor) radio; } result.setUseTitle(useLabels); return result; }
public void actionPerformed(ActionEvent e) { ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, InplaceEditor.COMMAND_SUCCESS); fireActionPerformed(ae); }
public void connect(PropertyEditor pe, PropertyEnv env) { super.connect(pe,env); needLayout = true; }