rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
public Object getValue() { return val; }
public Object getValue() { return value; }
public Object getValue() { return val; }
public void setAsText(String s) throws IllegalArgumentException { if(s.equals("null")) {
public void setAsText(String s) throws IllegalArgumentException { if (s.equals("null"))
public void setAsText(String s) throws IllegalArgumentException { if(s.equals("null")) { setValue(null); } else { throw new IllegalArgumentException(); } }
} else {
else
public void setAsText(String s) throws IllegalArgumentException { if(s.equals("null")) { setValue(null); } else { throw new IllegalArgumentException(); } }
}
public void setAsText(String s) throws IllegalArgumentException { if(s.equals("null")) { setValue(null); } else { throw new IllegalArgumentException(); } }
public void setValue(Object val) { Object oldVal = val; this.val = val; if(!oldVal.equals(val)) { pSupport.firePropertyChange(null,oldVal,val); } }
public void setValue(Object newValue) { value = newValue; pSupport.firePropertyChange(null, null, null); }
public void setValue(Object val) { Object oldVal = val; this.val = val; if(!oldVal.equals(val)) { pSupport.firePropertyChange(null,oldVal,val); } }
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); size = defaults.getDimension("ToolBar.separatorSize");
size = UIManager.getDimension("ToolBar.separatorSize");
protected void installDefaults(JSeparator s) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); size = defaults.getDimension("ToolBar.separatorSize"); }
int row = BasicListUI.this.convertYToRow(event.getY()); if (row == -1)
Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1)
public void mousePressed(MouseEvent event) { int row = BasicListUI.this.convertYToRow(event.getY()); if (row == -1) return; BasicListUI.this.list.setSelectedIndex(row); }
BasicListUI.this.list.setSelectedIndex(row);
BasicListUI.this.list.setSelectedIndex(index);
public void mousePressed(MouseEvent event) { int row = BasicListUI.this.convertYToRow(event.getY()); if (row == -1) return; BasicListUI.this.list.setSelectedIndex(row); }
rendererPane = new CellRendererPane();
public BasicListUI() { focusListener = new FocusHandler(); listDataListener = new ListDataHandler(); listSelectionListener = new ListSelectionHandler(); mouseInputListener = new MouseInputHandler(); propertyChangeListener = new PropertyChangeHandler(); updateLayoutStateNeeded = 1; }
int convertRowToY(int row)
protected int convertRowToY(int row)
int convertRowToY(int row) { int y = 0; for (int i = 0; i < row; ++i) { int h = getRowHeight(i); if (h == -1) return -1; y += h; } return y; }
int convertYToRow(int y0)
protected int convertYToRow(int y0)
int convertYToRow(int y0) { for (int row = 0; row < cellHeights.length; ++row) { int h = getRowHeight(row); if (y0 < h) return row; y0 -= h; } return -1; }
void damageLayout()
private void damageLayout()
void damageLayout() { updateLayoutStateNeeded = 1; list.revalidate(); }
int lo = Math.min(index1, index2); int hi = Math.max(index1, index2); Rectangle lobounds = new Rectangle(0, convertRowToY(lo), cellWidth, getRowHeight(lo)); Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth, getRowHeight(hi));
int minIndex = Math.min(index1, index2); int maxIndex = Math.max(index1, index2); Point loc = indexToLocation(list, minIndex); Rectangle bounds = new Rectangle(loc.x, loc.y, cellWidth, getRowHeight(minIndex));
public Rectangle getCellBounds(JList l, int index1, int index2) { maybeUpdateLayoutState(); if (l != list || cellWidth == -1) return null; int lo = Math.min(index1, index2); int hi = Math.max(index1, index2); Rectangle lobounds = new Rectangle(0, convertRowToY(lo), cellWidth, getRowHeight(lo)); Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth, getRowHeight(hi)); return lobounds.union(hibounds); }
return lobounds.union(hibounds);
for (int i = minIndex + 1; i <= maxIndex; i++) { Point hiLoc = indexToLocation(list, i); Rectangle hibounds = new Rectangle(hiLoc.x, hiLoc.y, cellWidth, getRowHeight(i)); bounds = bounds.union(hibounds); } return bounds;
public Rectangle getCellBounds(JList l, int index1, int index2) { maybeUpdateLayoutState(); if (l != list || cellWidth == -1) return null; int lo = Math.min(index1, index2); int hi = Math.max(index1, index2); Rectangle lobounds = new Rectangle(0, convertRowToY(lo), cellWidth, getRowHeight(lo)); Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth, getRowHeight(hi)); return lobounds.union(hibounds); }
if (list.getModel().getSize() == 0)
int size = list.getModel().getSize(); if (size == 0)
public Dimension getPreferredSize(JComponent c) { if (list.getModel().getSize() == 0) return new Dimension(0, 0); Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1); return bounds.getSize(); }
return bounds.getSize();
Dimension retVal = bounds.getSize(); Component parent = list.getParent(); if ((visibleRows == -1) && (parent instanceof JViewport)) { JViewport viewport = (JViewport) parent; if (layoutOrientation == JList.HORIZONTAL_WRAP) { int h = viewport.getSize().height; int cellsPerCol = h / cellHeight; int w = size / cellsPerCol * cellWidth; retVal = new Dimension(w, h); } else if (layoutOrientation == JList.VERTICAL_WRAP) { int w = viewport.getSize().width; int cellsPerRow = Math.max(w / cellWidth, 1); int h = size / cellsPerRow * cellHeight; retVal = new Dimension(w, h); } } return retVal;
public Dimension getPreferredSize(JComponent c) { if (list.getModel().getSize() == 0) return new Dimension(0, 0); Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1); return bounds.getSize(); }
int getRowHeight(int row)
protected int getRowHeight(int row)
int getRowHeight(int row) { if (row < 0 || row >= cellHeights.length) return -1; else if (cellHeight != -1) return cellHeight; else return cellHeights[row]; }
return new Point(0, convertRowToY(index));
int layoutOrientation = list.getLayoutOrientation(); Point loc = null; switch (layoutOrientation) { case JList.VERTICAL: loc = new Point(0, convertRowToY(index)); break; case JList.HORIZONTAL_WRAP: int visibleRows = list.getVisibleRowCount(); int numberOfCellsPerRow = -1; if (visibleRows <= 0) { Dimension listDim = list.getSize(); numberOfCellsPerRow = Math.max(listDim.width / cellWidth, 1); } else { int numberOfItems = list.getModel().getSize(); numberOfCellsPerRow = numberOfItems / visibleRows + 1; } int gridX = index % numberOfCellsPerRow; int gridY = index / numberOfCellsPerRow; int locX = gridX * cellWidth; int locY = gridY * cellHeight; loc = new Point(locX, locY); break; case JList.VERTICAL_WRAP: int visibleRows2 = list.getVisibleRowCount(); if (visibleRows2 <= 0) { Dimension listDim2 = list.getSize(); visibleRows2 = listDim2.height / cellHeight; } if (visibleRows2 > 0) { int gridY2 = index % visibleRows2; int gridX2 = index / visibleRows2; int locX2 = gridX2 * cellWidth; int locY2 = gridY2 * cellHeight; loc = new Point(locX2, locY2); } else loc = new Point(0, convertRowToY(index)); break; } return loc;
public Point indexToLocation(JList list, int index) { return new Point(0, convertRowToY(index)); }
void installDefaults()
protected void installDefaults()
void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); list.setForeground(defaults.getColor("List.foreground")); list.setBackground(defaults.getColor("List.background")); list.setSelectionForeground(defaults.getColor("List.selectionForeground")); list.setSelectionBackground(defaults.getColor("List.selectionBackground")); list.setOpaque(true); }
void installKeyboardActions()
protected void installKeyboardActions()
void installKeyboardActions() { }
void installListeners()
protected void installListeners()
void installListeners() { list.addFocusListener(focusListener); list.getModel().addListDataListener(listDataListener); list.addListSelectionListener(listSelectionListener); list.addMouseListener(mouseInputListener); list.addMouseMotionListener(mouseInputListener); list.addPropertyChangeListener(propertyChangeListener); }
list.addComponentListener(componentListener);
void installListeners() { list.addFocusListener(focusListener); list.getModel().addListDataListener(listDataListener); list.addListSelectionListener(listSelectionListener); list.addMouseListener(mouseInputListener); list.addMouseMotionListener(mouseInputListener); list.addPropertyChangeListener(propertyChangeListener); }
return convertYToRow(location.y);
int layoutOrientation = list.getLayoutOrientation(); int index = -1; switch (layoutOrientation) { case JList.VERTICAL: index = convertYToRow(location.y); break; case JList.HORIZONTAL_WRAP: int visibleRows = list.getVisibleRowCount(); int cellsPerRow = -1; int numberOfItems = list.getModel().getSize(); Dimension listDim = list.getSize(); if (visibleRows <= 0) { try { cellsPerRow = listDim.width / cellWidth; } catch (ArithmeticException ex) { cellsPerRow = 1; } } else { cellsPerRow = numberOfItems / visibleRows + 1; } int cellsPerColumn = numberOfItems / cellsPerRow + 1; int gridX = Math.min(location.x / cellWidth, cellsPerRow - 1); int gridY = Math.min(location.y / cellHeight, cellsPerColumn); index = gridX + gridY * cellsPerRow; break; case JList.VERTICAL_WRAP: int visibleRows2 = list.getVisibleRowCount(); if (visibleRows2 <= 0) { Dimension listDim2 = list.getSize(); visibleRows2 = listDim2.height / cellHeight; } int numberOfItems2 = list.getModel().getSize(); int cellsPerRow2 = numberOfItems2 / visibleRows2 + 1; Dimension listDim2 = list.getSize(); int gridX2 = Math.min(location.x / cellWidth, cellsPerRow2 - 1); int gridY2 = Math.min(location.y / cellHeight, visibleRows2); index = gridY2 + gridX2 * visibleRows2; break; } return index;
public int locationToIndex(JList list, Point location) { return convertYToRow(location.y); }
void maybeUpdateLayoutState()
protected void maybeUpdateLayoutState()
void maybeUpdateLayoutState() { if (updateLayoutStateNeeded != 0) { updateLayoutState(); updateLayoutStateNeeded = 0; } }
public void paintBackground(Graphics g, JComponent c)
private void paintBackground(Graphics g, JComponent c)
public void paintBackground(Graphics g, JComponent c) { Dimension size = getPreferredSize(c); Color save = g.getColor(); g.setColor(c.getBackground()); g.fillRect(0, 0, size.width, size.height); g.setColor(save); }
void paintCell(Graphics g, int row, Rectangle bounds, ListCellRenderer rend, ListModel data, ListSelectionModel sel, int lead)
protected void paintCell(Graphics g, int row, Rectangle bounds, ListCellRenderer rend, ListModel data, ListSelectionModel sel, int lead)
void paintCell(Graphics g, int row, Rectangle bounds, ListCellRenderer rend, ListModel data, ListSelectionModel sel, int lead) { boolean is_sel = list.isSelectedIndex(row); boolean has_focus = false; Component comp = rend.getListCellRendererComponent(list, data.getElementAt(row), 0, is_sel, has_focus); g.translate(bounds.x, bounds.y); comp.setBounds(new Rectangle(0, 0, bounds.width, bounds.height)); comp.paint(g); g.translate(-bounds.x, -bounds.y); }
g.translate(bounds.x, bounds.y); comp.setBounds(new Rectangle(0, 0, bounds.width, bounds.height)); comp.paint(g); g.translate(-bounds.x, -bounds.y);
rendererPane.paintComponent(g, comp, list, bounds);
void paintCell(Graphics g, int row, Rectangle bounds, ListCellRenderer rend, ListModel data, ListSelectionModel sel, int lead) { boolean is_sel = list.isSelectedIndex(row); boolean has_focus = false; Component comp = rend.getListCellRendererComponent(list, data.getElementAt(row), 0, is_sel, has_focus); g.translate(bounds.x, bounds.y); comp.setBounds(new Rectangle(0, 0, bounds.width, bounds.height)); comp.paint(g); g.translate(-bounds.x, -bounds.y); }
void uninstallDefaults()
protected void uninstallDefaults()
void uninstallDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); list.setForeground(null); list.setBackground(null); list.setSelectionForeground(null); list.setSelectionBackground(null); }
void uninstallKeyboardActions()
protected void uninstallKeyboardActions()
void uninstallKeyboardActions() { }
void uninstallListeners()
protected void uninstallListeners()
void uninstallListeners() { list.removeFocusListener(focusListener); list.getModel().removeListDataListener(listDataListener); list.removeListSelectionListener(listSelectionListener); list.removeMouseListener(mouseInputListener); list.removeMouseMotionListener(mouseInputListener); list.removePropertyChangeListener(propertyChangeListener); }
void updateLayoutState()
protected void updateLayoutState()
void updateLayoutState() { int nrows = list.getModel().getSize(); cellHeight = -1; cellWidth = -1; if (cellHeights == null || cellHeights.length != nrows) cellHeights = new int[nrows]; if (list.getFixedCellHeight() == -1 || list.getFixedCellWidth() == -1) { ListCellRenderer rend = list.getCellRenderer(); for (int i = 0; i < nrows; ++i) { Component flyweight = rend.getListCellRendererComponent(list, list.getModel() .getElementAt(i), 0, false, false); Dimension dim = flyweight.getPreferredSize(); cellHeights[i] = dim.height; cellWidth = Math.max(cellWidth, dim.width); } } else { cellHeight = list.getFixedCellHeight(); cellWidth = list.getFixedCellWidth(); } }
if (list.getLayoutOrientation() == JList.VERTICAL) cellWidth = Math.max(cellWidth, list.getSize().width);
void updateLayoutState() { int nrows = list.getModel().getSize(); cellHeight = -1; cellWidth = -1; if (cellHeights == null || cellHeights.length != nrows) cellHeights = new int[nrows]; if (list.getFixedCellHeight() == -1 || list.getFixedCellWidth() == -1) { ListCellRenderer rend = list.getCellRenderer(); for (int i = 0; i < nrows; ++i) { Component flyweight = rend.getListCellRendererComponent(list, list.getModel() .getElementAt(i), 0, false, false); Dimension dim = flyweight.getPreferredSize(); cellHeights[i] = dim.height; cellWidth = Math.max(cellWidth, dim.width); } } else { cellHeight = list.getFixedCellHeight(); cellWidth = list.getFixedCellWidth(); } }
else if (p.y + d.height > c.getHeight())
if (p.y + d.height > c.getHeight())
private Point adjustLocation(Point p, Component c, Dimension d) { if (p.x + d.width > c.getWidth()) p.x -= d.width; if (p.x < 0) p.x = 0; if (p.y + d.height < c.getHeight()) p.y += d.height; else if (p.y + d.height > c.getHeight()) p.y -= d.height*2; return p; }
JLayeredPane pane = ((JRootPane) SwingUtilities. getAncestorOfClass(JRootPane.class, currentComponent)). getLayeredPane();
JLayeredPane pane = null; JRootPane r = ((JRootPane) SwingUtilities. getAncestorOfClass(JRootPane.class, currentComponent)); if (r != null) pane = r.getLayeredPane();
void showTip() { if (!enabled || currentComponent == null || !currentComponent.isEnabled() || (currentTip != null && currentTip.isVisible())) return; if (currentTip == null || currentTip.getComponent() != currentComponent && currentComponent instanceof JComponent) currentTip = ((JComponent) currentComponent).createToolTip(); currentTip.setVisible(true); Container parent = currentComponent.getParent(); Point p = currentPoint; Dimension dims = currentTip.getPreferredSize(); if (parent instanceof JPopupMenu) setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled()); else setLightWeightPopupEnabled(true); if (isLightWeightPopupEnabled()) { JLayeredPane pane = ((JRootPane) SwingUtilities. getAncestorOfClass(JRootPane.class, currentComponent)). getLayeredPane(); // This should never happen, but just in case. if (pane == null) return; if (containerPanel != null) hideTip(); containerPanel = new Panel(); JRootPane root = new JRootPane(); root.getContentPane().add(currentTip); containerPanel.add(root); LayoutManager lm = containerPanel.getLayout(); if (lm instanceof FlowLayout) { FlowLayout fm = (FlowLayout) lm; fm.setVgap(0); fm.setHgap(0); } p = SwingUtilities.convertPoint(currentComponent, p, pane); p = adjustLocation(p, pane, dims); pane.add(containerPanel); containerPanel.setBounds(p.x, p.y, dims.width, dims.height); currentTip.setBounds(0, 0, dims.width, dims.height); containerPanel.validate(); containerPanel.repaint(); } else if (currentComponent.isShowing()) { SwingUtilities.convertPointToScreen(p, currentComponent); p = adjustLocation(p, SwingUtilities.getWindowAncestor(currentComponent), dims); tooltipWindow = new JDialog(); tooltipWindow.setContentPane(currentTip); tooltipWindow.setUndecorated(true); tooltipWindow.getRootPane(). setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); tooltipWindow.pack(); tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height); tooltipWindow.show(); tooltipWindow.validate(); tooltipWindow.repaint(); currentTip.revalidate(); currentTip.repaint(); } }
SAXParser parser = new SAXParser(); InputSource input = new InputSource(args[0]); parser.parse(input, new org.xml.sax.helpers.DefaultHandler());
boolean validating = false; boolean namespaceAware = false; boolean xIncludeAware = false; boolean expectCallbackClass = false; String callbackClass = null; int pos = 0; while (pos < args.length && (args[pos].startsWith("-") || expectCallbackClass)) { if ("-x".equals(args[pos])) xIncludeAware = true; else if ("-v".equals(args[pos])) validating = true; else if ("-n".equals(args[pos])) namespaceAware = true; else if ("-c".equals(args[pos])) expectCallbackClass = true; else if (expectCallbackClass) { callbackClass = args[pos]; expectCallbackClass = false; } pos++; } if (pos >= args.length || expectCallbackClass) { System.out.println("Syntax: SAXParser [-n] [-v] [-x] [-c <class>] <file> [<file2> [...]]"); System.out.println("\t-n: use namespace aware mode"); System.out.println("\t-v: use validating parser"); System.out.println("\t-x: use XInclude aware mode"); System.out.println("\t-c <class>: use specified class as callback handler (must have a no-arg public constructor)"); System.exit(2); } while (pos < args.length) { ContentHandler handler = null; if (callbackClass != null) { Class t = Class.forName(callbackClass); handler = (ContentHandler) t.newInstance(); } else handler = new org.xml.sax.helpers.DefaultHandler(); SAXParser parser = new SAXParser(validating, namespaceAware, xIncludeAware); InputSource input = new InputSource(args[pos]); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(handler); reader.parse(input); pos++; }
public static void main(String[] args) throws Exception { SAXParser parser = new SAXParser(); InputSource input = new InputSource(args[0]); parser.parse(input, new org.xml.sax.helpers.DefaultHandler()); }
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); Font f = comboBox.getFont(); Color fore = comboBox.getForeground(); Color back = comboBox.getBackground(); if (f == null || f instanceof UIResource) comboBox.setFont(defaults.getFont("ComboBox.font")); if (fore == null || fore instanceof UIResource) comboBox.setForeground(defaults.getColor("ComboBox.foreground")); if (back == null || back instanceof UIResource) comboBox.setBackground(defaults.getColor("ComboBox.background"));
LookAndFeel.installColorsAndFont(comboBox, "ComboBox.background", "ComboBox.foreground", "ComboBox.font");
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); Font f = comboBox.getFont(); Color fore = comboBox.getForeground(); Color back = comboBox.getBackground(); if (f == null || f instanceof UIResource) comboBox.setFont(defaults.getFont("ComboBox.font")); if (fore == null || fore instanceof UIResource) comboBox.setForeground(defaults.getColor("ComboBox.foreground")); if (back == null || back instanceof UIResource) comboBox.setBackground(defaults.getColor("ComboBox.background")); // fetch the button color scheme shadow = defaults.getColor("ComboBox.buttonShadow"); darkShadow = defaults.getColor("ComboBox.buttonDarkShadow"); highlight = defaults.getColor("ComboBox.buttonHighlight"); }
shadow = defaults.getColor("ComboBox.buttonShadow"); darkShadow = defaults.getColor("ComboBox.buttonDarkShadow"); highlight = defaults.getColor("ComboBox.buttonHighlight");
shadow = UIManager.getColor("ComboBox.buttonShadow"); darkShadow = UIManager.getColor("ComboBox.buttonDarkShadow"); highlight = UIManager.getColor("ComboBox.buttonHighlight");
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); Font f = comboBox.getFont(); Color fore = comboBox.getForeground(); Color back = comboBox.getBackground(); if (f == null || f instanceof UIResource) comboBox.setFont(defaults.getFont("ComboBox.font")); if (fore == null || fore instanceof UIResource) comboBox.setForeground(defaults.getColor("ComboBox.foreground")); if (back == null || back instanceof UIResource) comboBox.setBackground(defaults.getColor("ComboBox.background")); // fetch the button color scheme shadow = defaults.getColor("ComboBox.buttonShadow"); darkShadow = defaults.getColor("ComboBox.buttonDarkShadow"); highlight = defaults.getColor("ComboBox.buttonHighlight"); }
protected JComponent createContentPane() {
protected Container createContentPane() {
protected JComponent createContentPane() { return new SwingFrameContentPane(); }
paintBorder(g);
Rectangle clip = g.getClipBounds(); if (clip.x == 0 && clip.y == 0 && clip.width == getWidth() && clip.height == getHeight()) RepaintManager.currentManager(this).markCompletelyClean(this);
public void paint(Graphics g) { RepaintManager rm = RepaintManager.currentManager(this); // We do a little stunt act here to switch on double buffering if it's // not already on. If we are not already doublebuffered, then we jump // into the method paintDoubleBuffered, which turns on the double buffer // and then calls paint(g) again. In the second call we go into the else // branch of this if statement and actually paint things to the double // buffer. When this method completes, the call stack unwinds back to // paintDoubleBuffered, where the buffer contents is finally drawn to the // screen. if (!isPaintingDoubleBuffered && isDoubleBuffered() && rm.isDoubleBufferingEnabled()) paintDoubleBuffered(g); else { if (g.getClip() == null) g.setClip(0, 0, getWidth(), getHeight()); paintComponent(g); paintChildren(g); paintBorder(g); } }
Rectangle inner = SwingUtilities.calculateInnerArea(this, new Rectangle());
Rectangle inner = SwingUtilities.calculateInnerArea(this, rectCache);
protected void paintChildren(Graphics g) { Shape originalClip = g.getClip(); Rectangle inner = SwingUtilities.calculateInnerArea(this, new Rectangle()); g.clipRect(inner.x, inner.y, inner.width, inner.height); Component[] children = getComponents(); for (int i = children.length - 1; i >= 0; --i) { if (!children[i].isVisible()) continue; Rectangle bounds = children[i].getBounds(); Rectangle oldClip = g.getClipBounds(); if (oldClip == null) oldClip = bounds; Rectangle clip = oldClip.intersection(bounds); if (clip.isEmpty()) continue; boolean translated = false; try { g.setClip(clip.x, clip.y, clip.width, clip.height); g.translate(bounds.x, bounds.y); translated = true; children[i].paint(g); } finally { if (translated) g.translate(-bounds.x, -bounds.y); g.setClip(oldClip); } } g.setClip(originalClip); }
Rectangle bounds = children[i].getBounds();
Rectangle bounds = children[i].getBounds(rectCache);
protected void paintChildren(Graphics g) { Shape originalClip = g.getClip(); Rectangle inner = SwingUtilities.calculateInnerArea(this, new Rectangle()); g.clipRect(inner.x, inner.y, inner.width, inner.height); Component[] children = getComponents(); for (int i = children.length - 1; i >= 0; --i) { if (!children[i].isVisible()) continue; Rectangle bounds = children[i].getBounds(); Rectangle oldClip = g.getClipBounds(); if (oldClip == null) oldClip = bounds; Rectangle clip = oldClip.intersection(bounds); if (clip.isEmpty()) continue; boolean translated = false; try { g.setClip(clip.x, clip.y, clip.width, clip.height); g.translate(bounds.x, bounds.y); translated = true; children[i].paint(g); } finally { if (translated) g.translate(-bounds.x, -bounds.y); g.setClip(oldClip); } } g.setClip(originalClip); }
Rectangle clip = oldClip.intersection(bounds); if (clip.isEmpty())
if (!g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height))
protected void paintChildren(Graphics g) { Shape originalClip = g.getClip(); Rectangle inner = SwingUtilities.calculateInnerArea(this, new Rectangle()); g.clipRect(inner.x, inner.y, inner.width, inner.height); Component[] children = getComponents(); for (int i = children.length - 1; i >= 0; --i) { if (!children[i].isVisible()) continue; Rectangle bounds = children[i].getBounds(); Rectangle oldClip = g.getClipBounds(); if (oldClip == null) oldClip = bounds; Rectangle clip = oldClip.intersection(bounds); if (clip.isEmpty()) continue; boolean translated = false; try { g.setClip(clip.x, clip.y, clip.width, clip.height); g.translate(bounds.x, bounds.y); translated = true; children[i].paint(g); } finally { if (translated) g.translate(-bounds.x, -bounds.y); g.setClip(oldClip); } } g.setClip(originalClip); }
g.setClip(clip.x, clip.y, clip.width, clip.height);
g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height);
protected void paintChildren(Graphics g) { Shape originalClip = g.getClip(); Rectangle inner = SwingUtilities.calculateInnerArea(this, new Rectangle()); g.clipRect(inner.x, inner.y, inner.width, inner.height); Component[] children = getComponents(); for (int i = children.length - 1; i >= 0; --i) { if (!children[i].isVisible()) continue; Rectangle bounds = children[i].getBounds(); Rectangle oldClip = g.getClipBounds(); if (oldClip == null) oldClip = bounds; Rectangle clip = oldClip.intersection(bounds); if (clip.isEmpty()) continue; boolean translated = false; try { g.setClip(clip.x, clip.y, clip.width, clip.height); g.translate(bounds.x, bounds.y); translated = true; children[i].paint(g); } finally { if (translated) g.translate(-bounds.x, -bounds.y); g.setClip(oldClip); } } g.setClip(originalClip); }
synchronized (paintLock) {
void paintDoubleBuffered(Graphics g) { Rectangle r = g.getClipBounds(); if (r == null) r = new Rectangle(0, 0, getWidth(), getHeight()); RepaintManager rm = RepaintManager.currentManager(this); // Paint on the offscreen buffer. synchronized (paintLock) { Image buffer = rm.getOffscreenBuffer(this, getWidth(), getHeight()); Graphics g2 = buffer.getGraphics(); g2 = getComponentGraphics(g2); g2.setClip(r.x, r.y, r.width, r.height); isPaintingDoubleBuffered = true; paint(g2); isPaintingDoubleBuffered = false; g2.dispose(); // Paint the buffer contents on screen. g.drawImage(buffer, 0, 0, this); } }
}
void paintDoubleBuffered(Graphics g) { Rectangle r = g.getClipBounds(); if (r == null) r = new Rectangle(0, 0, getWidth(), getHeight()); RepaintManager rm = RepaintManager.currentManager(this); // Paint on the offscreen buffer. synchronized (paintLock) { Image buffer = rm.getOffscreenBuffer(this, getWidth(), getHeight()); Graphics g2 = buffer.getGraphics(); g2 = getComponentGraphics(g2); g2.setClip(r.x, r.y, r.width, r.height); isPaintingDoubleBuffered = true; paint(g2); isPaintingDoubleBuffered = false; g2.dispose(); // Paint the buffer contents on screen. g.drawImage(buffer, 0, 0, this); } }
if (oldX != getX() || oldY != getY()) fireAncestorEvent(this, AncestorEvent.ANCESTOR_MOVED);
public void reshape(int x, int y, int w, int h) { super.reshape(x, y, w, h); }
repaint();
public void setBackground(Color bg) { super.setBackground(bg); }
Border oldBorder = border;
Border oldBorder = getBorder(); if (oldBorder == newBorder) return;
public void setBorder(Border newBorder) { Border oldBorder = border; border = newBorder; firePropertyChange("border", oldBorder, newBorder); }
repaint();
public void setBorder(Border newBorder) { Border oldBorder = border; border = newBorder; firePropertyChange("border", oldBorder, newBorder); }
boolean oldEnabled = isEnabled();
if (enable == isEnabled()) return;
public void setEnabled(boolean enable) { boolean oldEnabled = isEnabled(); super.setEnabled(enable); firePropertyChange("enabled", oldEnabled, enable); }
firePropertyChange("enabled", oldEnabled, enable);
firePropertyChange("enabled", !enable, enable); repaint();
public void setEnabled(boolean enable) { boolean oldEnabled = isEnabled(); super.setEnabled(enable); firePropertyChange("enabled", oldEnabled, enable); }
revalidate(); repaint();
public void setFont(Font f) { super.setFont(f); }
repaint();
public void setForeground(Color fg) { super.setForeground(fg); }
revalidate(); repaint();
protected void setUI(ComponentUI newUI) { if (ui != null) ui.uninstallUI(this); ComponentUI oldUI = ui; ui = newUI; if (ui != null) ui.installUI(this); firePropertyChange("UI", oldUI, newUI); }
if (isVisible() == v) return;
public void setVisible(boolean v) { super.setVisible(v); Container parent = getParent(); if (parent != null) parent.repaint(getX(), getY(), getWidth(), getHeight()); revalidate(); }
xform.concatenate(post);
concetenateTransform (post);
public void concatenateTransform(AffineTransform post) { xform.concatenate(post); }
concatenateTransform(post);
xform.concatenate (post);
public void concetenateTransform(AffineTransform post) { concatenateTransform(post); }
xform.preConcatenate(pre);
preConcetenateTransform (pre);
public void preConcatenateTransform(AffineTransform pre) { xform.preConcatenate(pre); }
preConcetenateTransform(pre);
xform.preConcatenate (pre);
public void preConcetenateTransform(AffineTransform pre) { preConcetenateTransform(pre); }
setIcon(getLeafIcon());
setLeafIcon(getLeafIcon());
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.selected = selected; this.hasFocus = hasFocus; if (leaf) setIcon(getLeafIcon()); else if (expanded) setIcon(getOpenIcon()); else setIcon(getClosedIcon()); setText(val.toString()); setHorizontalAlignment(LEFT); setVerticalAlignment(TOP); return this; }
setIcon(getOpenIcon());
setOpenIcon(getOpenIcon());
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.selected = selected; this.hasFocus = hasFocus; if (leaf) setIcon(getLeafIcon()); else if (expanded) setIcon(getOpenIcon()); else setIcon(getClosedIcon()); setText(val.toString()); setHorizontalAlignment(LEFT); setVerticalAlignment(TOP); return this; }
setIcon(getClosedIcon());
setClosedIcon(getClosedIcon());
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.selected = selected; this.hasFocus = hasFocus; if (leaf) setIcon(getLeafIcon()); else if (expanded) setIcon(getOpenIcon()); else setIcon(getClosedIcon()); setText(val.toString()); setHorizontalAlignment(LEFT); setVerticalAlignment(TOP); return this; }
setEnabled(true); setFont(getFont()); if (selected) { super.setBackground(getBackgroundSelectionColor()); super.setForeground(getTextSelectionColor()); } else { super.setBackground((tree.getParent()).getBackground()); super.setForeground(getTextNonSelectionColor()); }
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.selected = selected; this.hasFocus = hasFocus; if (leaf) setIcon(getLeafIcon()); else if (expanded) setIcon(getOpenIcon()); else setIcon(getClosedIcon()); setText(val.toString()); setHorizontalAlignment(LEFT); setVerticalAlignment(TOP); return this; }
if (attribs[i].begin_index > getEndIndex() || attribs[i].end_index <= getBeginIndex()) continue;
getAllAttributeKeys(){ HashSet s = new HashSet(); if (attribs == null) return(s); for (int i = 0; i < attribs.length; i++) { Set key_set = attribs[i].attribs.keySet(); Iterator iter = key_set.iterator(); while (iter.hasNext()) { s.add(iter.next()); } } return(s);}
(ci.getIndex() <= attribs[i].end_index))
(ci.getIndex() < attribs[i].end_index))
getAttribute(AttributedCharacterIterator.Attribute attrib){ if (attribs == null) return(null); for (int i = 0; i < attribs.length; i++) { Set key_set = attribs[i].attribs.keySet(); Iterator iter = key_set.iterator(); while (iter.hasNext()) { Object obj = iter.next(); // Check for attribute match and range match if (obj.equals(attrib)) if ((ci.getIndex() >= attribs[i].begin_index) && (ci.getIndex() <= attribs[i].end_index)) return(attribs[i].attribs.get(obj)); } } return(null);}
(ci.getIndex() <= attribs[i].end_index))
(ci.getIndex() < attribs[i].end_index))
getAttributes(){ HashMap m = new HashMap(); if (attribs == null) return(m); for (int i = 0; i < attribs.length; i++) { if ((ci.getIndex() >= attribs[i].begin_index) && (ci.getIndex() <= attribs[i].end_index)) m.putAll(attribs[i].attribs); } return(m);}
private ThreadGroup() { this.parent = null; this.name = "Root Thread Group"; this.maxPriority = java.lang.Thread.MAX_PRIORITY; this.daemon = false; this.process = VmProcess.getRootProcess(this); }
private ThreadGroup() { name = "main"; parent = null; maxpri = Thread.MAX_PRIORITY; }
private ThreadGroup() { this.parent = null; this.name = "Root Thread Group"; this.maxPriority = java.lang.Thread.MAX_PRIORITY; this.daemon = false; this.process = VmProcess.getRootProcess(this); }
public int activeCount() { return allThreadsCount();
public int activeCount() { int total = 0; if (groups == null) return total; int i = threads.size(); while (--i >= 0) if (((Thread) threads.get(i)).isAlive()) total++; i = groups.size(); while (--i >= 0) total += ((ThreadGroup) groups.get(i)).activeCount(); return total;
public int activeCount() { return allThreadsCount(); }
public int activeGroupCount() { return allGroupsCount();
public int activeGroupCount() { if (groups == null) return 0; int total = groups.size(); int i = total; while (--i >= 0) total += ((ThreadGroup) groups.get(i)).activeGroupCount(); return total;
public int activeGroupCount() { return allGroupsCount(); }
public boolean allowThreadSuspension(boolean b) { return true; }
public boolean allowThreadSuspension(boolean allow) { return false; }
public boolean allowThreadSuspension(boolean b) { // Ignore return true; }
public final void checkAccess() { SecurityManager sm = System.getSecurityManager();
public final void checkAccess() { SecurityManager sm = SecurityManager.current;
public final void checkAccess() { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkAccess(this); }
public final void destroy() { checkAccess(); if (destroyed) throw new IllegalThreadStateException("ThreadGroup has already been destroyed"); if (threads.size() > 0) throw new IllegalThreadStateException("ThreadGroup has Threads remaining"); Enumeration e = groups.elements(); while (e.hasMoreElements()) { ThreadGroup g = (ThreadGroup) e.nextElement(); g.destroy(); } parent.remove(this); destroyed = true;
public final synchronized void destroy() { checkAccess(); if (! threads.isEmpty() || groups == null) throw new IllegalThreadStateException(); int i = groups.size(); while (--i >= 0) ((ThreadGroup) groups.get(i)).destroy(); groups = null; if (parent != null) parent.removeGroup(this);
public final void destroy() { checkAccess(); if (destroyed) throw new IllegalThreadStateException("ThreadGroup has already been destroyed"); if (threads.size() > 0) throw new IllegalThreadStateException("ThreadGroup has Threads remaining"); Enumeration e = groups.elements(); while (e.hasMoreElements()) { ThreadGroup g = (ThreadGroup) e.nextElement(); g.destroy(); } parent.remove(this); destroyed = true; }
public int enumerate(Thread[] list) { return enumerate(list, false);
public int enumerate(Thread[] array) { return enumerate(array, 0, true);
public int enumerate(Thread[] list) { return enumerate(list, false); }
public final int getMaxPriority() { return maxPriority;
public final int getMaxPriority() { return maxpri;
public final int getMaxPriority() { return maxPriority; }
public final ThreadGroup getParent() { return parent; }
public final ThreadGroup getParent() { if (parent != null) parent.checkAccess(); return parent; }
public final ThreadGroup getParent() { return parent; }
public final boolean isDaemon() { return daemon; }
public final boolean isDaemon() { return daemon_flag; }
public final boolean isDaemon() { return daemon; }
public boolean isDestroyed() { return destroyed;
public synchronized boolean isDestroyed() { return groups == null;
public boolean isDestroyed() { return destroyed; }
public final boolean parentOf(ThreadGroup g) { return (this == g) || parentOf(g.getParent());
public final boolean parentOf(ThreadGroup group) { while (group != null) { if (group == this) return true; group = group.parent; } return false;
public final boolean parentOf(ThreadGroup g) { return (this == g) || parentOf(g.getParent()); }
public final void resume() { checkAccess(); Enumeration et = threads.elements(); while (et.hasMoreElements()) { Thread t = (Thread) et.nextElement(); t.resume(); } Enumeration eg = groups.elements(); while (eg.hasMoreElements()) { ThreadGroup g = (ThreadGroup) et.nextElement(); g.resume(); }
public final synchronized void resume() { checkAccess(); if (groups == null) return; int i = threads.size(); while (--i >= 0) ((Thread) threads.get(i)).resume(); i = groups.size(); while (--i >= 0) ((ThreadGroup) groups.get(i)).resume();
public final void resume() { checkAccess(); Enumeration et = threads.elements(); while (et.hasMoreElements()) { Thread t = (Thread) et.nextElement(); t.resume(); } Enumeration eg = groups.elements(); while (eg.hasMoreElements()) { ThreadGroup g = (ThreadGroup) et.nextElement(); g.resume(); } }
public final void setDaemon(boolean daemon) { checkAccess(); this.daemon = daemon; }
public final void setDaemon(boolean daemon) { checkAccess(); daemon_flag = daemon; }
public final void setDaemon(boolean daemon) { checkAccess(); this.daemon = daemon; }
public final void setMaxPriority(int n) { checkAccess(); if (n < Thread.MIN_PRIORITY || n > Thread.MAX_PRIORITY) throw new IllegalArgumentException("Invalid priority: " + n); if (parent != null && n > parent.maxPriority) n = parent.maxPriority; maxPriority = n; Enumeration e = groups.elements(); while (e.hasMoreElements()) { ThreadGroup g = (ThreadGroup) e.nextElement(); g.setMaxPriority(n); }
public final synchronized void setMaxPriority(int maxpri) { checkAccess(); if (maxpri < Thread.MIN_PRIORITY || maxpri > Thread.MAX_PRIORITY) return; if (parent != null && maxpri > parent.maxpri) maxpri = parent.maxpri; this.maxpri = maxpri; if (groups == null) return; int i = groups.size(); while (--i >= 0) ((ThreadGroup) groups.get(i)).setMaxPriority(maxpri);
public final void setMaxPriority(int n) { checkAccess(); if (n < Thread.MIN_PRIORITY || n > Thread.MAX_PRIORITY) throw new IllegalArgumentException("Invalid priority: " + n); if (parent != null && n > parent.maxPriority) n = parent.maxPriority; maxPriority = n; Enumeration e = groups.elements(); while (e.hasMoreElements()) { ThreadGroup g = (ThreadGroup) e.nextElement(); g.setMaxPriority(n); } }
public final void stop() { checkAccess(); Enumeration et = threads.elements(); while (et.hasMoreElements()) { Thread t = (Thread) et.nextElement(); t.stop(); } Enumeration eg = groups.elements(); while (eg.hasMoreElements()) { ThreadGroup g = (ThreadGroup) eg.nextElement(); g.stop(); }
public final synchronized void stop() { checkAccess(); if (groups == null) return; int i = threads.size(); while (--i >= 0) ((Thread) threads.get(i)).stop(); i = groups.size(); while (--i >= 0) ((ThreadGroup) groups.get(i)).stop();
public final void stop() { checkAccess(); Enumeration et = threads.elements(); while (et.hasMoreElements()) { Thread t = (Thread) et.nextElement(); t.stop(); } Enumeration eg = groups.elements(); while (eg.hasMoreElements()) { ThreadGroup g = (ThreadGroup) eg.nextElement(); g.stop(); } }
public final void suspend() { checkAccess(); Enumeration et = threads.elements(); while (et.hasMoreElements()) { Thread t = (Thread) et.nextElement(); t.suspend(); } Enumeration eg = groups.elements(); while (eg.hasMoreElements()) { ThreadGroup g = (ThreadGroup) eg.nextElement(); g.suspend(); }
public final synchronized void suspend() { checkAccess(); if (groups == null) return; int i = threads.size(); while (--i >= 0) ((Thread) threads.get(i)).suspend(); i = groups.size(); while (--i >= 0) ((ThreadGroup) groups.get(i)).suspend();
public final void suspend() { checkAccess(); Enumeration et = threads.elements(); while (et.hasMoreElements()) { Thread t = (Thread) et.nextElement(); t.suspend(); } Enumeration eg = groups.elements(); while (eg.hasMoreElements()) { ThreadGroup g = (ThreadGroup) eg.nextElement(); g.suspend(); } }
public String toString() { return getClass().getName() + "[name=" + name + ",maxpri=" + maxPriority + "]";
public String toString() { return getClass().getName() + "[name=" + name + ",maxpri=" + maxpri + ']';
public String toString() { return getClass().getName() + "[name=" + name + ",maxpri=" + maxPriority + "]"; }
public void uncaughtException(Thread t, Throwable e) { if (parent != null) parent.uncaughtException(t, e); else if (!(e instanceof ThreadDeath)) e.printStackTrace();
public void uncaughtException(Thread thread, Throwable t) { if (parent != null) parent.uncaughtException(thread, t); else if (! (t instanceof ThreadDeath)) { if (t == null) throw new NullPointerException(); had_uncaught_exception = true; try { if (thread != null) System.err.print("Exception in thread \"" + thread.name + "\" "); t.printStackTrace(System.err); } catch (Throwable x) { try { System.err.println(t); System.err.println("*** Got " + x + " while trying to print stack trace."); } catch (Throwable x2) { System.err.println("*** Catastrophic failure while handling " + "uncaught exception."); throw new InternalError(); } }
public void uncaughtException(Thread t, Throwable e) { if (parent != null) parent.uncaughtException(t, e); else if (!(e instanceof ThreadDeath)) e.printStackTrace(); }
}
public void uncaughtException(Thread t, Throwable e) { if (parent != null) parent.uncaughtException(t, e); else if (!(e instanceof ThreadDeath)) e.printStackTrace(); }
JDesktopPane toUse = getDesktopPaneForComponent(parentComponent);
JLayeredPane toUse = getDesktopPaneForComponent(parentComponent);
public JInternalFrame createInternalFrame(Component parentComponent, String title) throws RuntimeException { JDesktopPane toUse = getDesktopPaneForComponent(parentComponent); if (toUse == null) throw new RuntimeException("parentComponent does not have a valid parent"); JInternalFrame frame = new JInternalFrame(title); inputValue = UNINITIALIZED_VALUE; value = UNINITIALIZED_VALUE; frame.setClosable(true); toUse.add(frame); // FIXME: JLayeredPane broken? See bug # 16576 // frame.setLayer(JLayeredPane.MODAL_LAYER); return frame; }
throw new RuntimeException("parentComponent does not have a valid parent");
toUse = JLayeredPane.getLayeredPaneAbove(parentComponent); if (toUse == null) throw new RuntimeException ("parentComponent does not have a valid parent");
public JInternalFrame createInternalFrame(Component parentComponent, String title) throws RuntimeException { JDesktopPane toUse = getDesktopPaneForComponent(parentComponent); if (toUse == null) throw new RuntimeException("parentComponent does not have a valid parent"); JInternalFrame frame = new JInternalFrame(title); inputValue = UNINITIALIZED_VALUE; value = UNINITIALIZED_VALUE; frame.setClosable(true); toUse.add(frame); // FIXME: JLayeredPane broken? See bug # 16576 // frame.setLayer(JLayeredPane.MODAL_LAYER); return frame; }
frame.pack(); frame.setVisible(true);
public JInternalFrame createInternalFrame(Component parentComponent, String title) throws RuntimeException { JDesktopPane toUse = getDesktopPaneForComponent(parentComponent); if (toUse == null) throw new RuntimeException("parentComponent does not have a valid parent"); JInternalFrame frame = new JInternalFrame(title); inputValue = UNINITIALIZED_VALUE; value = UNINITIALIZED_VALUE; frame.setClosable(true); toUse.add(frame); // FIXME: JLayeredPane broken? See bug # 16576 // frame.setLayer(JLayeredPane.MODAL_LAYER); return frame; }
startModal(frame, pane);
startModal(frame);
public static int showInternalConfirmDialog(Component parentComponent, Object message) { JOptionPane pane = new JOptionPane(message); JInternalFrame frame = pane.createInternalFrame(parentComponent, null); startModal(frame, pane); return ((Integer) pane.getValue()).intValue(); }
startModal(frame, pane);
startModal(frame);
public static String showInternalInputDialog(Component parentComponent, Object message) { JOptionPane pane = new JOptionPane(message); pane.setWantsInput(true); JInternalFrame frame = pane.createInternalFrame(parentComponent, null); startModal(frame, pane); return (String) pane.getInputValue(); }
startModal(frame, pane);
startModal(frame);
public static void showInternalMessageDialog(Component parentComponent, Object message) { JOptionPane pane = new JOptionPane(message); JInternalFrame frame = pane.createInternalFrame(parentComponent, null); startModal(frame, pane); }
startModal(frame, pane);
startModal(frame);
public static int showInternalOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) { JOptionPane pane = new JOptionPane(message, messageType, optionType, icon, options, initialValue); JInternalFrame frame = pane.createInternalFrame(parentComponent, title); startModal(frame, pane); return ((Integer) pane.getValue()).intValue(); }
private static void startModal(JInternalFrame f, JOptionPane pane)
private static void startModal(JInternalFrame f)
private static void startModal(JInternalFrame f, JOptionPane pane) { f.getContentPane().add(pane); f.pack(); f.show(); Dimension pref = f.getPreferredSize(); f.setBounds(0, 0, pref.width, pref.height); synchronized (f) { final JInternalFrame tmp = f; tmp.toFront(); f.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosed(InternalFrameEvent e) { synchronized (tmp) { tmp.removeInternalFrameListener(this); tmp.notifyAll(); } } }); try { while (! f.isClosed()) f.wait(); } catch (InterruptedException ignored) { } } }
f.getContentPane().add(pane); f.pack(); f.show(); Dimension pref = f.getPreferredSize(); f.setBounds(0, 0, pref.width, pref.height);
private static void startModal(JInternalFrame f, JOptionPane pane) { f.getContentPane().add(pane); f.pack(); f.show(); Dimension pref = f.getPreferredSize(); f.setBounds(0, 0, pref.width, pref.height); synchronized (f) { final JInternalFrame tmp = f; tmp.toFront(); f.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosed(InternalFrameEvent e) { synchronized (tmp) { tmp.removeInternalFrameListener(this); tmp.notifyAll(); } } }); try { while (! f.isClosed()) f.wait(); } catch (InterruptedException ignored) { } } }
if (cs != null) { ProtectionDomain protectionDomain = new ProtectionDomain(cs, getPermissions(cs));
if (cs != null) { ProtectionDomain protectionDomain = new ProtectionDomain(cs, getPermissions(cs), this, null);
protected final Class defineClass( String name, byte[] b, int off, int len, CodeSource cs) { // FIXME: Need to cache ProtectionDomains according to 1.3 docs. if (cs != null) { ProtectionDomain protectionDomain = new ProtectionDomain(cs, getPermissions(cs)); return super.defineClass(name, b, off, len, protectionDomain); } else return super.defineClass(name, b, off, len); }
protected PermissionCollection getPermissions(CodeSource cs) { Policy policy = Policy.getPolicy();
protected PermissionCollection getPermissions(CodeSource cs) { Policy policy = Policy.getCurrentPolicy();
protected PermissionCollection getPermissions(CodeSource cs) { Policy policy = Policy.getPolicy(); return policy.getPermissions(cs); }
public ProtectionDomain(CodeSource code_source, PermissionCollection perms) { this.code_source = code_source; this.perms = perms; if (perms != null) perms.setReadOnly(); }
public ProtectionDomain(CodeSource codesource, PermissionCollection permissions) { this(codesource, permissions, null, null, true); }
public ProtectionDomain(CodeSource code_source, PermissionCollection perms) { this.code_source = code_source; this.perms = perms; if (perms != null) perms.setReadOnly(); }
protected final Class defineClass(String name, byte[] data, int offset, int length, ProtectionDomain protDomain) { if (data == null) { throw new NullPointerException(); } if (offset < 0 || length < 0 || (offset + length) > data.length) { throw new IndexOutOfBoundsException(); } if (protDomain == null) { protDomain = (ProtectionDomain) AccessController .doPrivileged(new PrivilegedAction() { public Object run() { return getDefaultProtectionDomain(); } }); } return vmClassLoader .defineClass(name, data, offset, length, protDomain).asClass();
protected final Class defineClass(byte[] data, int offset, int length) { return defineClass(null, data, offset, length, null);
protected final Class defineClass(String name, byte[] data, int offset, int length, ProtectionDomain protDomain) { if (data == null) { throw new NullPointerException(); } if (offset < 0 || length < 0 || (offset + length) > data.length) { throw new IndexOutOfBoundsException(); } if (protDomain == null) { protDomain = (ProtectionDomain) AccessController .doPrivileged(new PrivilegedAction() { public Object run() { return getDefaultProtectionDomain(); } }); } return vmClassLoader .defineClass(name, data, offset, length, protDomain).asClass(); }
int id = event == null ? 0 : event.getID(); if (((mask & AWTEvent.ACTION_EVENT_MASK) != 0 && event instanceof ActionEvent) || ((mask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 && event instanceof AdjustmentEvent) || ((mask & AWTEvent.COMPONENT_EVENT_MASK) != 0 && event instanceof ComponentEvent && (id >= ComponentEvent.COMPONENT_FIRST && id <= ComponentEvent.COMPONENT_LAST)) || ((mask & AWTEvent.CONTAINER_EVENT_MASK) != 0 && event instanceof ContainerEvent) || ((mask & AWTEvent.FOCUS_EVENT_MASK) != 0 && event instanceof FocusEvent) || ((mask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 && event instanceof HierarchyEvent && (id == HierarchyEvent.ANCESTOR_MOVED || id == HierarchyEvent.ANCESTOR_RESIZED)) || ((mask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && event instanceof HierarchyEvent && id == HierarchyEvent.HIERARCHY_CHANGED) || ((mask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 && event instanceof InputMethodEvent) || ((mask & AWTEvent.INVOCATION_EVENT_MASK) != 0 && event instanceof InvocationEvent) || ((mask & AWTEvent.ITEM_EVENT_MASK) != 0 && event instanceof ItemEvent) || ((mask & AWTEvent.KEY_EVENT_MASK) != 0 && event instanceof KeyEvent) || ((mask & AWTEvent.MOUSE_EVENT_MASK) != 0 && event instanceof MouseEvent && (id == MouseEvent.MOUSE_PRESSED || id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED || id == MouseEvent.MOUSE_ENTERED || id == MouseEvent.MOUSE_EXITED)) || ((mask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 && event instanceof MouseEvent && (id == MouseEvent.MOUSE_MOVED || id == MouseEvent.MOUSE_DRAGGED)) || ((mask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 && event instanceof MouseWheelEvent) || ((mask & AWTEvent.PAINT_EVENT_MASK) != 0 && event instanceof PaintEvent) || ((mask & AWTEvent.TEXT_EVENT_MASK) != 0 && event instanceof TextEvent) || ((mask & AWTEvent.WINDOW_EVENT_MASK) != 0 && event instanceof WindowEvent && (id == WindowEvent.WINDOW_OPENED || id == WindowEvent.WINDOW_CLOSING || id == WindowEvent.WINDOW_CLOSED || id == WindowEvent.WINDOW_ICONIFIED || id == WindowEvent.WINDOW_DEICONIFIED || id == WindowEvent.WINDOW_ACTIVATED || id == WindowEvent.WINDOW_DEACTIVATED)) || ((mask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 && event instanceof WindowEvent && (id == WindowEvent.WINDOW_GAINED_FOCUS || id == WindowEvent.WINDOW_LOST_FOCUS)) || ((mask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 && event instanceof WindowEvent && id == WindowEvent.WINDOW_STATE_CHANGED))
public void eventDispatched(AWTEvent event) { int id = event == null ? 0 : event.getID(); if (((mask & AWTEvent.ACTION_EVENT_MASK) != 0 && event instanceof ActionEvent) || ((mask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 && event instanceof AdjustmentEvent) || ((mask & AWTEvent.COMPONENT_EVENT_MASK) != 0 && event instanceof ComponentEvent && (id >= ComponentEvent.COMPONENT_FIRST && id <= ComponentEvent.COMPONENT_LAST)) || ((mask & AWTEvent.CONTAINER_EVENT_MASK) != 0 && event instanceof ContainerEvent) || ((mask & AWTEvent.FOCUS_EVENT_MASK) != 0 && event instanceof FocusEvent) || ((mask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 && event instanceof HierarchyEvent && (id == HierarchyEvent.ANCESTOR_MOVED || id == HierarchyEvent.ANCESTOR_RESIZED)) || ((mask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && event instanceof HierarchyEvent && id == HierarchyEvent.HIERARCHY_CHANGED) || ((mask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 && event instanceof InputMethodEvent) || ((mask & AWTEvent.INVOCATION_EVENT_MASK) != 0 && event instanceof InvocationEvent) || ((mask & AWTEvent.ITEM_EVENT_MASK) != 0 && event instanceof ItemEvent) || ((mask & AWTEvent.KEY_EVENT_MASK) != 0 && event instanceof KeyEvent) || ((mask & AWTEvent.MOUSE_EVENT_MASK) != 0 && event instanceof MouseEvent && (id == MouseEvent.MOUSE_PRESSED || id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED || id == MouseEvent.MOUSE_ENTERED || id == MouseEvent.MOUSE_EXITED)) || ((mask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 && event instanceof MouseEvent && (id == MouseEvent.MOUSE_MOVED || id == MouseEvent.MOUSE_DRAGGED)) || ((mask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 && event instanceof MouseWheelEvent) || ((mask & AWTEvent.PAINT_EVENT_MASK) != 0 && event instanceof PaintEvent) || ((mask & AWTEvent.TEXT_EVENT_MASK) != 0 && event instanceof TextEvent) || ((mask & AWTEvent.WINDOW_EVENT_MASK) != 0 && event instanceof WindowEvent && (id == WindowEvent.WINDOW_OPENED || id == WindowEvent.WINDOW_CLOSING || id == WindowEvent.WINDOW_CLOSED || id == WindowEvent.WINDOW_ICONIFIED || id == WindowEvent.WINDOW_DEICONIFIED || id == WindowEvent.WINDOW_ACTIVATED || id == WindowEvent.WINDOW_DEACTIVATED)) || ((mask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 && event instanceof WindowEvent && (id == WindowEvent.WINDOW_GAINED_FOCUS || id == WindowEvent.WINDOW_LOST_FOCUS)) || ((mask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 && event instanceof WindowEvent && id == WindowEvent.WINDOW_STATE_CHANGED)) ((AWTEventListener) getListener()).eventDispatched(event); }