rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
if (!isInitialized()) { | if (!isInitialized() && !isInitializing()) { | public final void initialize() { if (!isInitialized()) { linkAndInitialize(); } } |
Unsafe.debug("loadFromBootClassArray"); | Unsafe.debug("[loadFromBootClassArray:"); | protected static void loadFromBootClassArray(VmType[] bootClasses) { Unsafe.debug("loadFromBootClassArray"); final int count = bootClasses.length; for (int i = 0; i < count; i++) { final VmType<?> vmClass = bootClasses[i]; final String name = vmClass.name; if (vmClass.isPrimitive()) { if (name.equals("boolean")) { BooleanClass = (VmNormalClass) vmClass; } else if (name.equals("byte")) { ByteClass = (VmNormalClass) vmClass; } else if (name.equals("char")) { CharClass = (VmNormalClass) vmClass; } else if (name.equals("short")) { ShortClass = (VmNormalClass) vmClass; } else if (name.equals("int")) { IntClass = (VmNormalClass) vmClass; } else if (name.equals("float")) { FloatClass = (VmNormalClass) vmClass; } else if (name.equals("long")) { LongClass = (VmNormalClass) vmClass; } else if (name.equals("double")) { DoubleClass = (VmNormalClass) vmClass; } else if (name.equals("void")) { VoidClass = (VmNormalClass) vmClass; } } else if (vmClass.isArray()) { if (name.equals("[Z")) { BooleanArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[B")) { ByteArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[C")) { CharArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[S")) { ShortArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[I")) { IntArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[F")) { FloatArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[J")) { LongArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[D")) { DoubleArrayClass = (VmArrayClass) vmClass; } } else { if (name.equals("java.lang.Object")) { ObjectClass = (VmNormalClass) vmClass; } else if (name.equals("java.lang.Cloneable")) { CloneableClass = (VmInterfaceClass) vmClass; } else if (name.equals("java.io.Serializable")) { SerializableClass = (VmInterfaceClass) vmClass; } } } Unsafe.debug('\n'); } |
Unsafe.debug('\n'); | Unsafe.debug("]\n"); | protected static void loadFromBootClassArray(VmType[] bootClasses) { Unsafe.debug("loadFromBootClassArray"); final int count = bootClasses.length; for (int i = 0; i < count; i++) { final VmType<?> vmClass = bootClasses[i]; final String name = vmClass.name; if (vmClass.isPrimitive()) { if (name.equals("boolean")) { BooleanClass = (VmNormalClass) vmClass; } else if (name.equals("byte")) { ByteClass = (VmNormalClass) vmClass; } else if (name.equals("char")) { CharClass = (VmNormalClass) vmClass; } else if (name.equals("short")) { ShortClass = (VmNormalClass) vmClass; } else if (name.equals("int")) { IntClass = (VmNormalClass) vmClass; } else if (name.equals("float")) { FloatClass = (VmNormalClass) vmClass; } else if (name.equals("long")) { LongClass = (VmNormalClass) vmClass; } else if (name.equals("double")) { DoubleClass = (VmNormalClass) vmClass; } else if (name.equals("void")) { VoidClass = (VmNormalClass) vmClass; } } else if (vmClass.isArray()) { if (name.equals("[Z")) { BooleanArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[B")) { ByteArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[C")) { CharArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[S")) { ShortArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[I")) { IntArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[F")) { FloatArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[J")) { LongArrayClass = (VmArrayClass) vmClass; } else if (name.equals("[D")) { DoubleArrayClass = (VmArrayClass) vmClass; } } else { if (name.equals("java.lang.Object")) { ObjectClass = (VmNormalClass) vmClass; } else if (name.equals("java.lang.Cloneable")) { CloneableClass = (VmInterfaceClass) vmClass; } else if (name.equals("java.io.Serializable")) { SerializableClass = (VmInterfaceClass) vmClass; } } } Unsafe.debug('\n'); } |
public LinkageError(String s) { super(s); | public LinkageError() { | public LinkageError(String s) { super(s); } |
public ExceptionInInitializerError(String s) { super(s); exception = null; | public ExceptionInInitializerError() { this((String) null); | public ExceptionInInitializerError(String s) { super(s); exception = null; } |
public Object getAny(int index) { | public final Object getAny(int index) { | public Object getAny(int index) { return get(index); } |
return(parent.getAlignmentX()); | return 0.5F; | public float getLayoutAlignmentX(Container parent) { return(parent.getAlignmentX()); } |
return(parent.getAlignmentY()); | return 0.5F; | public float getLayoutAlignmentY(Container parent) { return(parent.getAlignmentY()); } |
if (treeModelListener == null) treeModelListener = createTreeModelListener(); model.addTreeModelListener(treeModelListener); | public void setModel(TreeModel model) { if (treeModel == model) return; TreeModel oldValue = treeModel; treeModel = model; firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model); } |
|
if (name.getTagClass() != DER.APPLICATION) throw new IOException("malformed GeneralName"); | int tagClass = name.getTagClass(); if (tagClass != DER.CONTEXT) throw new IOException("malformed GeneralName: Tag class is " + tagClass); | public GeneralNames(final byte[] encoded) throws IOException { names = new LinkedList(); DERReader der = new DERReader(encoded); DERValue nameList = der.read(); if (!nameList.isConstructed()) throw new IOException("malformed GeneralNames"); int len = 0; while (len < nameList.getLength()) { DERValue name = der.read(); List namePair = new ArrayList(2); if (name.getTagClass() != DER.APPLICATION) throw new IOException("malformed GeneralName"); namePair.add(new Integer(name.getTag())); DERValue val = null; switch (name.getTag()) { case RFC822_NAME: case DNS_NAME: case X400_ADDRESS: case URI: namePair.add(new String((byte[]) name.getValue())); break; case OTHER_NAME: case EDI_PARTY_NAME: namePair.add(name.getValue()); break; case DIRECTORY_NAME: byte[] b = name.getEncoded(); b[0] = (byte) (DER.CONSTRUCTED|DER.SEQUENCE); namePair.add(new X500DistinguishedName(b).toString()); break; case IP_ADDRESS: namePair.add(InetAddress.getByAddress((byte[]) name.getValue()) .getHostAddress()); break; case REGISTERED_ID: byte[] bb = name.getEncoded(); bb[0] = (byte) DER.OBJECT_IDENTIFIER; namePair.add(new OID(bb).toString()); break; default: throw new IOException("unknown tag " + name.getTag()); } names.add(namePair); len += name.getEncodedLength(); } } |
namePair.add(new X500DistinguishedName(b).toString()); | DERReader r = new DERReader (b); r.read (); namePair.add(new X500Principal(r.read ().getEncoded ()).toString()); | public GeneralNames(final byte[] encoded) throws IOException { names = new LinkedList(); DERReader der = new DERReader(encoded); DERValue nameList = der.read(); if (!nameList.isConstructed()) throw new IOException("malformed GeneralNames"); int len = 0; while (len < nameList.getLength()) { DERValue name = der.read(); List namePair = new ArrayList(2); if (name.getTagClass() != DER.APPLICATION) throw new IOException("malformed GeneralName"); namePair.add(new Integer(name.getTag())); DERValue val = null; switch (name.getTag()) { case RFC822_NAME: case DNS_NAME: case X400_ADDRESS: case URI: namePair.add(new String((byte[]) name.getValue())); break; case OTHER_NAME: case EDI_PARTY_NAME: namePair.add(name.getValue()); break; case DIRECTORY_NAME: byte[] b = name.getEncoded(); b[0] = (byte) (DER.CONSTRUCTED|DER.SEQUENCE); namePair.add(new X500DistinguishedName(b).toString()); break; case IP_ADDRESS: namePair.add(InetAddress.getByAddress((byte[]) name.getValue()) .getHostAddress()); break; case REGISTERED_ID: byte[] bb = name.getEncoded(); bb[0] = (byte) DER.OBJECT_IDENTIFIER; namePair.add(new OID(bb).toString()); break; default: throw new IOException("unknown tag " + name.getTag()); } names.add(namePair); len += name.getEncodedLength(); } } |
public X500DistinguishedName(byte[] encoded) throws IOException | public X500DistinguishedName(String name) | public X500DistinguishedName(byte[] encoded) throws IOException { this(new ByteArrayInputStream(encoded)); } |
this(new ByteArrayInputStream(encoded)); | if (name == null) throw new NullPointerException(); try { parseDN(name, true); } catch (Exception e) { parseDN(name, false); } | public X500DistinguishedName(byte[] encoded) throws IOException { this(new ByteArrayInputStream(encoded)); } |
else { System.err.println("WARNING: Tried to replace elements "); System.err.print("beyond boundaries: elementCount: "); System.err.println(e.getElementCount()); System.err.print("index: " + curr.index); System.err.println(", removed.length: " + removed.length); } } | public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.pos = offset; this.endOffset = offset + length; this.length = length; documentEvent = ev; edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false; insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); // FIXME: We probably shouldn't create the empty Element[] in the // first place. if (removed.length > 0 || added.length > 0) { e.replace(curr.index, removed.length, added); ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee); } } } |
|
rb.append ('\n'); | public void parseFields(byte[] cByte, ArrayList ffd, StringBuffer rb) { FileFieldDef f; // write out the html record information for each field that is selected for (int x = 0; x < ffd.size(); x++) { f = (FileFieldDef)ffd.get(x); if (f.isWriteField()) { switch (f.getFieldType()) { case 'P': case 'S':// rb.append(f.parseData(cByte).trim() + delimiter); rb.append(getFixedLength(cByte,f)); break; default:// rb.append(stringQualifier + f.parseData(cByte).trim() + stringQualifier + delimiter);// rb.append(f.parseData(cByte)); rb.append(getFixedLength(cByte,f)); break; } } } rb.append ('\n'); fout.println(rb); } |
|
try { FileFieldDef f; StringBuffer sb = new StringBuffer(); for (int x = 0; x < ffd.size(); x++) { f = (FileFieldDef)ffd.get(x); if (f.isWriteField()) { sb.append(f.getFieldName()); } } fout.write (sb.toString().getBytes()); fout.write ('\n'); } catch (IOException ioe) { } | public void writeHeader(String fileName, String host, ArrayList ffd, char decChar) { try { FileFieldDef f; StringBuffer sb = new StringBuffer(); // loop through each of the fields and write out the field name for // each selected field for (int x = 0; x < ffd.size(); x++) { f = (FileFieldDef)ffd.get(x); if (f.isWriteField()) { sb.append(f.getFieldName()); } } fout.write (sb.toString().getBytes()); fout.write ('\n'); } catch (IOException ioe) {// printFTPInfo(" error writing header " + ioe.getMessage()); } } |
|
synchronized (f) | JPanel modalInterceptor = new JPanel(); modalInterceptor.setOpaque(false); JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f); lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue()); modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight()); modalInterceptor.addMouseListener(new MouseAdapter(){}); modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){}); lp.add(modalInterceptor); f.toFront(); EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue(); try | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
final JInternalFrame tmp = f; tmp.toFront(); f.addInternalFrameListener(new InternalFrameAdapter() | while (! f.isClosed()) | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
public void internalFrameClosed(InternalFrameEvent e) | if (EventQueue.isDispatchThread()) | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
synchronized (tmp) | AWTEvent ev = queue.getNextEvent(); if (ev instanceof ActiveEvent) ((ActiveEvent) ev).dispatch(); else if (ev.getSource() instanceof Component) ((Component) ev.getSource()).dispatchEvent(ev); else if (ev.getSource() instanceof MenuComponent) ((MenuComponent) ev.getSource()).dispatchEvent(ev); } else | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
tmp.removeInternalFrameListener(this); tmp.notifyAll(); | Thread.yield(); | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
}); try | } catch (InterruptedException ex) | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
while (! f.isClosed()) f.wait(); | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
|
catch (InterruptedException ignored) { } | finally { lp.remove(modalInterceptor); Container parent = f.getParent(); if (parent != null) parent.remove(f); | private static void startModal(JInternalFrame f) { 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) { // Ignore this Exception. } } } |
while (next_in == next_out) wait(); | ClasspathToolkit tk = ((ClasspathToolkit) Toolkit.getDefaultToolkit()); long curr = System.currentTimeMillis(); | public synchronized AWTEvent getNextEvent() throws InterruptedException { if (next != null) return next.getNextEvent(); while (next_in == next_out) wait(); AWTEvent res = queue[next_out]; if (++next_out == queue.length) next_out = 0; return res; } |
AWTEvent res = queue[next_out]; | if (!tk.nativeQueueEmpty() && (curr - lastNativeQueueAccess > humanLatencyThreshold)) { tk.iterateNativeQueue(this, false); lastNativeQueueAccess = curr; } | public synchronized AWTEvent getNextEvent() throws InterruptedException { if (next != null) return next.getNextEvent(); while (next_in == next_out) wait(); AWTEvent res = queue[next_out]; if (++next_out == queue.length) next_out = 0; return res; } |
if (++next_out == queue.length) next_out = 0; return res; } | while (next_in == next_out) { if (isDispatchThread()) { if (isShutdown()) throw new InterruptedException(); tk.iterateNativeQueue(this, true); lastNativeQueueAccess = System.currentTimeMillis(); } else { try { wait(); } catch (InterruptedException ie) { } } } AWTEvent res = queue[next_out]; if (++next_out == queue.length) next_out = 0; return res; } | public synchronized AWTEvent getNextEvent() throws InterruptedException { if (next != null) return next.getNextEvent(); while (next_in == next_out) wait(); AWTEvent res = queue[next_out]; if (++next_out == queue.length) next_out = 0; return res; } |
public void dispatch(); | void dispatch(); | public void dispatch(); |
{ | { Event oldStyleEvent = Component.translateEvent(event); if (oldStyleEvent != null) { postEvent(oldStyleEvent); } | public final void dispatchEvent(AWTEvent event){ // See comment in Component.dispatchEvent(). dispatchEventImpl(event);} |
textComponent.setCaretPosition(caretPos - ev.getLength()); | textComponent.setCaretPosition(ev.getOffset()); | public void removeUpdate(DocumentEvent ev) { Dimension size = textComponent.getSize(); rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height), BasicTextUI.this); int caretPos = textComponent.getCaretPosition(); if (caretPos >= ev.getOffset()) textComponent.setCaretPosition(caretPos - ev.getLength()); } |
bad.minor = Minor.Any; | public static NameDynAnyPair[] extract(Any any) { try { return ((NameDynAnyPairSeqHolder) any.extract_Streamable()).value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPairSeq expected"); bad.initCause(cex); throw bad; } } |
|
try { throw new MARSHAL("The read/write are not applicable for " + Id); } catch (Exception e) { throw new MARSHAL(); } | MARSHAL m = new MARSHAL("The read/write are not applicable for " + Id); m.minor = Minor.Inappropriate; throw m; | static String not_applicable(String Id) { try { throw new MARSHAL("The read/write are not applicable for " + Id); } catch (Exception e) { throw new MARSHAL(); } } |
for (int i = 0; i < syntaxes.length; i++) { try { return syntaxes[i].complete(partial.getRemainder()); } catch (CompletionException ex) { } } System.out.println(); usage(); throw new CompletionException("Invalid command syntax"); } | String max = ""; for (int i = 0; i < syntaxes.length; i++) { try { final String s = syntaxes[ i].complete(partial .getRemainder()); if (s.length() > max.length()) { max = s; } } catch (CompletionException ex) { } } if (max.length() > 0) { return max; } else { System.out.println(); usage(); throw new CompletionException("Invalid command syntax"); } } | public String complete(CommandLine partial) throws CompletionException { //System.out.println("completing \"" + partial + "\""); for (int i = 0; i < syntaxes.length; i++) { try { return syntaxes[i].complete(partial.getRemainder()); } catch (CompletionException ex) { // this syntax is not fitting // following debug output is for testing the "intelligent" delegation mechanism // System.err.println("Syntax \"" + syntaxes[i].getDescription() + "\" threw " // + ex.toString()); } } System.out.println(); usage(); throw new CompletionException("Invalid command syntax"); } |
public void help() { Help.getHelp().help(this); } | public void help() throws HelpException { Help.getHelp().help(this); } | public void help() { Help.getHelp().help(this); } |
public ParsedArguments parse(String[] args) throws SyntaxError { for (int i = 0; i < syntaxes.length; i++) { try { return syntaxes[i].parse(args); } catch (SyntaxError ex) { } } | public ParsedArguments parse(String[] args) throws SyntaxErrorException { for (int i = 0; i < syntaxes.length; i++) { final Syntax s = syntaxes[ i]; try { return s.parse(args); } catch (SyntaxErrorException ex) { s.clearArguments(); } } | public ParsedArguments parse(String[] args) throws SyntaxError { for (int i = 0; i < syntaxes.length; i++) { try { return syntaxes[i].parse(args); } catch (SyntaxError ex) { // debug output to debug syntax finding mechanism //System.err.println(ex.toString()); //ex.printStackTrace(System.out); } } // no fitting Syntax found? trow an error throw new SyntaxError("No matching syntax found"); } |
throw new SyntaxError("No matching syntax found"); } | throw new SyntaxErrorException("No matching syntax found"); } | public ParsedArguments parse(String[] args) throws SyntaxError { for (int i = 0; i < syntaxes.length; i++) { try { return syntaxes[i].parse(args); } catch (SyntaxError ex) { // debug output to debug syntax finding mechanism //System.err.println(ex.toString()); //ex.printStackTrace(System.out); } } // no fitting Syntax found? trow an error throw new SyntaxError("No matching syntax found"); } |
Help.getHelp().usage(this); } | try { Help.getHelp().usage(this); } catch (HelpException ex) { ex.printStackTrace(); } } | public void usage() { Help.getHelp().usage(this); } |
if (!up || pause) | if (!isUp() || pause) | public void keyPressed(KeyEvent e) { int kc = e.getKeyCode(); if (kc == KeyEvent.VK_N) { newGame(); return; } if (kc == KeyEvent.VK_P) { flipPause(); return; } if (!up || pause) return; switch (e.getKeyCode()) { case KeyEvent.VK_UP: rot(1); break; case KeyEvent.VK_LEFT: trans(-1); break; case KeyEvent.VK_DOWN: rot(3); break; case KeyEvent.VK_RIGHT: trans(1); break; case KeyEvent.VK_SPACE: fall(); break; case KeyEvent.VK_N: newGame(); break; case KeyEvent.VK_P: flipPause(); break; default: return; } repaint(); } |
if (thread != null) { up = false; | setUp(false); if (thread != null) { | public void newGame() { if (thread != null) { up = false; if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } }); thread.start(); } |
up = true; | public void newGame() { if (thread != null) { up = false; if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } }); thread.start(); } |
|
stop: while (up) { | stop: while (isUp()) { | public void newGame() { if (thread != null) { up = false; if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } }); thread.start(); } |
if (!up) | if (!isUp()) | public void newGame() { if (thread != null) { up = false; if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } }); thread.start(); } |
up = false; | setUp(false); | public void newGame() { if (thread != null) { up = false; if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } }); thread.start(); } |
thread.start(); | setUp(true); thread.start(); | public void newGame() { if (thread != null) { up = false; if (pause) { flipPause(); } try { thread.join(); } catch (InterruptedException ignore) { } } for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { if (i == 0 || j == 0 || i == WIDTH_C + 1 || j == HEIGHT_C + 1) WORLD[i][j] = COLORS.length - 1; else WORLD[i][j] = 0; } } requestFocus(); end = false; score = 0; si = si_rnd.nextInt(7); next_si = si_rnd.nextInt(7); bi = bi_rnd.nextInt(4); next_bi = bi_rnd.nextInt(4); x = 1 + bi_rnd.nextInt((WIDTH_C - DIMS[si * 4 + bi][0])); y = 0; thread = new Thread(new Runnable() { public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } }); thread.start(); } |
up = true; | public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } |
|
stop: while (up) { | stop: while (isUp()) { | public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } |
if (!up) | if (!isUp()) | public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } |
up = false; | setUp(false); | public void run() { try { up = true; long before, after, sleep; stop: while (up) { before = System.currentTimeMillis(); synchronized (Tetris.class) { while (pause) { try { System.out.println("waiting"); Tetris.class.wait(); System.out.println("back from waiting"); } catch (InterruptedException ignore) { } if (!up) break stop; } } if (hasRoom(bi, x, y + 1)) { y++; repaint(); } else { newBlock(); if (!hasRoom(bi, x, y)) { up = false; end = true; repaint(); } } after = System.currentTimeMillis(); sleep = delay - (after - before); sleep = sleep < 0 ? delay : sleep; try { Thread.sleep(sleep); } catch (InterruptedException ignore) { } } } catch (Throwable ex) { ex.printStackTrace(); } } |
if (up) { | if (isUp()) { | public void paint(Graphics g) { if (img == null) { img = createImage(DIM.width, DIM.height); } Graphics g2 = img.getGraphics(); g2.setColor(COLORS[0]); g2.fillRect(0, 0, DIM.width, DIM.height); for (int i = 0; i < WIDTH_C + 2; i++) { for (int j = 0; j < HEIGHT_C + 2; j++) { int ci = WORLD[i][j]; if (ci > 0) paintBox(g2, i, j, COLORS[ci]); } } { Color c = COLORS[COLORS.length - 1]; for (int i = 0; i < WIDTH_C + 2; i++) { paintBox(g2, i, HEIGHT_C + 6, c); } for (int j = 0; j < 4; j++) { paintBox(g2, 0, HEIGHT_C + 2 + j, c); paintBox(g2, 5, HEIGHT_C + 2 + j, c); // paintBox(g2, 6, HEIGHT_C + 2 +j, c ); paintBox(g2, WIDTH_C + 1, HEIGHT_C + 2 + j, c); } } if (up) { int[][] b = BLOCKS[si][bi]; for (int i = 0; i < b.length; i++) { paintBox(g2, x + b[i][0], y + b[i][1], COLORS[si + 1]); } { g2.setColor(Color.WHITE); g2.drawString("SCORE:", CELL + 2, (HEIGHT_C + 4) * CELL - 4); g2.drawString(String.valueOf(score), 2 * CELL, (HEIGHT_C + 5) * CELL - 4); b = BLOCKS[next_si][next_bi]; for (int i = 0; i < b.length; i++) { paintBox(g2, 7 + b[i][0], HEIGHT_C + 2 + b[i][1], COLORS[next_si + 1]); } } } else if (end) { g2.setColor(Color.BLACK); g2.fillRect(2 * CELL, 9 * CELL, 8 * CELL, 4 * CELL); g2.setColor(Color.WHITE); g2.drawRect(2 * CELL, 9 * CELL, 8 * CELL, 4 * CELL); g2.drawString("GAME OVER! SCORE: " + score, (WIDTH_C - 6) * CELL / 2 + 2, (HEIGHT_C + 2) * CELL / 2); } g2.dispose(); g.drawImage(img, 0, 0, this); } |
super(toolkit, choice, new JComboBox()); this.choice = choice; final JComboBox combo = (JComboBox)jComponent; combo.setModel(new DefaultComboBoxModel()); | super(toolkit, choice, new SwingChoice(choice)); final JComboBox combo = (JComboBox) jComponent; combo.setModel(new DefaultComboBoxModel()); | public SwingChoicePeer(SwingToolkit toolkit, Choice choice) { super(toolkit, choice, new JComboBox()); this.choice = choice; final JComboBox combo = (JComboBox)jComponent; combo.setModel(new DefaultComboBoxModel()); SwingToolkit.add(choice, combo); SwingToolkit.copyAwtProperties(choice, combo); final int cnt = choice.getItemCount(); for (int i = 0; i < cnt; i++) { addItem(choice.getItem(i), i); } } |
public abstract void addItem(String item, int index); | void addItem (String item, int index); | public abstract void addItem(String item, int index); |
public static final DateFormat getTimeInstance (int style, Locale loc) | public static final DateFormat getTimeInstance () | public static final DateFormat getTimeInstance (int style, Locale loc) { return computeInstance (style, loc, false, true); } |
return computeInstance (style, loc, false, true); | return getTimeInstance (DEFAULT, Locale.getDefault()); | public static final DateFormat getTimeInstance (int style, Locale loc) { return computeInstance (style, loc, false, true); } |
public static Locale[] getAvailableLocales() | public static synchronized Locale[] getAvailableLocales() | public static Locale[] getAvailableLocales() { /* I only return those for which localized language * or country information exists. * XXX - remove hard coded list, and implement more locales (Sun's JDK 1.4 * has 148 installed locales!). */ return new Locale[] { ENGLISH, FRENCH, GERMAN, new Locale("ga", "") }; } |
return new Locale[] | if (availableLocales == null) | public static Locale[] getAvailableLocales() { /* I only return those for which localized language * or country information exists. * XXX - remove hard coded list, and implement more locales (Sun's JDK 1.4 * has 148 installed locales!). */ return new Locale[] { ENGLISH, FRENCH, GERMAN, new Locale("ga", "") }; } |
ENGLISH, FRENCH, GERMAN, new Locale("ga", "") }; | String[] localeNames = LocaleData.localeNames; availableLocales = new Locale[localeNames.length]; for (int i = 0; i < localeNames.length; i++) { String language; String region = ""; String variant = ""; String name = localeNames[i]; language = name.substring(0, 2); if (name.length() > 2) region = name.substring(3); int index = region.indexOf("_"); if (index > 0) { variant = region.substring(index + 1); region = region.substring(0, index - 1); } availableLocales[i] = getLocale(language, region, variant); } } return availableLocales; | public static Locale[] getAvailableLocales() { /* I only return those for which localized language * or country information exists. * XXX - remove hard coded list, and implement more locales (Sun's JDK 1.4 * has 148 installed locales!). */ return new Locale[] { ENGLISH, FRENCH, GERMAN, new Locale("ga", "") }; } |
empty = false; | void clear(int index) { offset = index; this.index = 0; for (int i = 0; i < start.length; i++) { start[i] = end[i] = -1; } next = null; // cut off alternates empty = false; } |
|
} | public void menuDeselected(MenuEvent e) { JMenu menu = (JMenu) menuItem; if (menu.isTopLevelMenu()) ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection(); else ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection(); } |
|
lookup_time = System.currentTimeMillis(); | InetAddress(byte[] ipaddr, String hostname) { addr = (null == ipaddr) ? null : (byte[]) ipaddr.clone(); hostName = hostname; lookup_time = System.currentTimeMillis(); family = 2; /* AF_INET */ } |
|
if (hostname == null) | if (hostname == null || hostname.equals("")) | public static InetAddress[] getAllByName(String hostname) throws UnknownHostException { SecurityManager s = System.getSecurityManager(); if (s != null) s.checkConnect(hostname, -1); InetAddress[] addresses; // Default to current host if necessary if (hostname == null) { addresses = new InetAddress[1]; addresses[0] = LOCALHOST; return addresses; } // Check the cache for this host before doing a lookup addresses = checkCacheFor(hostname); if (addresses != null) return addresses; // Not in cache, try the lookup byte[][] iplist = VMInetAddress.getHostByName(hostname); if (iplist.length == 0) throw new UnknownHostException(hostname); addresses = new InetAddress[iplist.length]; for (int i = 0; i < iplist.length; i++) { if (iplist[i].length != 4) throw new UnknownHostException(hostname); addresses[i] = new Inet4Address(iplist[i], hostname); } addToCache(hostname, addresses); return addresses; } |
addresses = checkCacheFor(hostname); if (addresses != null) return addresses; | public static InetAddress[] getAllByName(String hostname) throws UnknownHostException { SecurityManager s = System.getSecurityManager(); if (s != null) s.checkConnect(hostname, -1); InetAddress[] addresses; // Default to current host if necessary if (hostname == null) { addresses = new InetAddress[1]; addresses[0] = LOCALHOST; return addresses; } // Check the cache for this host before doing a lookup addresses = checkCacheFor(hostname); if (addresses != null) return addresses; // Not in cache, try the lookup byte[][] iplist = VMInetAddress.getHostByName(hostname); if (iplist.length == 0) throw new UnknownHostException(hostname); addresses = new InetAddress[iplist.length]; for (int i = 0; i < iplist.length; i++) { if (iplist[i].length != 4) throw new UnknownHostException(hostname); addresses[i] = new Inet4Address(iplist[i], hostname); } addToCache(hostname, addresses); return addresses; } |
|
addToCache(hostname, addresses); | public static InetAddress[] getAllByName(String hostname) throws UnknownHostException { SecurityManager s = System.getSecurityManager(); if (s != null) s.checkConnect(hostname, -1); InetAddress[] addresses; // Default to current host if necessary if (hostname == null) { addresses = new InetAddress[1]; addresses[0] = LOCALHOST; return addresses; } // Check the cache for this host before doing a lookup addresses = checkCacheFor(hostname); if (addresses != null) return addresses; // Not in cache, try the lookup byte[][] iplist = VMInetAddress.getHostByName(hostname); if (iplist.length == 0) throw new UnknownHostException(hostname); addresses = new InetAddress[iplist.length]; for (int i = 0; i < iplist.length; i++) { if (iplist[i].length != 4) throw new UnknownHostException(hostname); addresses[i] = new Inet4Address(iplist[i], hostname); } addToCache(hostname, addresses); return addresses; } |
|
inaddr_any.hostName = inaddr_any.getHostName(); | static InetAddress getInaddrAny() throws UnknownHostException { if (inaddr_any == null) { byte[] tmp = VMInetAddress.lookupInaddrAny(); inaddr_any = new Inet4Address(tmp, null); } return inaddr_any; } |
|
Inet4Address(byte[] addr, String host) | Inet4Address(byte[] addr) | Inet4Address(byte[] addr, String host) { this(addr, host, null); } |
this(addr, host, null); | this(addr, null, null); | Inet4Address(byte[] addr, String host) { this(addr, host, null); } |
optionPane.removeAll(); messageAreaContainer = createMessageArea(); optionPane.add(messageAreaContainer); optionPane.add(buttonContainer); | optionPane.remove(messageAreaContainer); messageAreaContainer = createMessageArea(); optionPane.add(messageAreaContainer); Container newButtons = createButtonArea(); optionPane.remove(buttonContainer); optionPane.add(newButtons); buttonContainer = newButtons; optionPane.add(buttonContainer); | public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(JOptionPane.ICON_PROPERTY) || e.getPropertyName().equals(JOptionPane.MESSAGE_TYPE_PROPERTY)) addIcon(messageAreaContainer); else if (e.getPropertyName().equals(JOptionPane.INITIAL_SELECTION_VALUE_PROPERTY)) resetSelectedValue(); else if (e.getPropertyName().equals(JOptionPane.INITIAL_VALUE_PROPERTY) || e.getPropertyName().equals(JOptionPane.OPTIONS_PROPERTY) || e.getPropertyName().equals(JOptionPane.OPTION_TYPE_PROPERTY)) { Container newButtons = createButtonArea(); optionPane.remove(buttonContainer); optionPane.add(newButtons); buttonContainer = newButtons; } else if (e.getPropertyName().equals(JOptionPane.MESSAGE_PROPERTY) || e.getPropertyName().equals(JOptionPane.WANTS_INPUT_PROPERTY) || e.getPropertyName().equals(JOptionPane.SELECTION_VALUES_PROPERTY)) { optionPane.removeAll(); messageAreaContainer = createMessageArea(); optionPane.add(messageAreaContainer); optionPane.add(buttonContainer); } optionPane.invalidate(); optionPane.repaint(); } |
rightSide.setBorder(BorderFactory.createEmptyBorder(0, 11, 17, 0)); | rightSide.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); | protected Container createMessageArea() { JPanel messageArea = new JPanel(); messageArea.setLayout(new BorderLayout()); addIcon(messageArea); JPanel rightSide = new JPanel(); rightSide.setBorder(BorderFactory.createEmptyBorder(0, 11, 17, 0)); rightSide.setLayout(new GridBagLayout()); GridBagConstraints con = createConstraints(); addMessageComponents(rightSide, con, getMessage(), getMaxCharactersPerLineCount(), false); if (optionPane.getWantsInput()) { Object[] selection = optionPane.getSelectionValues(); if (selection == null) inputComponent = new JTextField(15); else if (selection.length < 20) inputComponent = new JComboBox(selection); else inputComponent = new JList(selection); if (inputComponent != null) { addMessageComponents(rightSide, con, inputComponent, getMaxCharactersPerLineCount(), false); resetSelectedValue(); selectInitialValue(optionPane); } } messageArea.add(rightSide, BorderLayout.EAST); return messageArea; } |
messageArea.add(rightSide, BorderLayout.EAST); | messageArea.add(rightSide, BorderLayout.CENTER); | protected Container createMessageArea() { JPanel messageArea = new JPanel(); messageArea.setLayout(new BorderLayout()); addIcon(messageArea); JPanel rightSide = new JPanel(); rightSide.setBorder(BorderFactory.createEmptyBorder(0, 11, 17, 0)); rightSide.setLayout(new GridBagLayout()); GridBagConstraints con = createConstraints(); addMessageComponents(rightSide, con, getMessage(), getMaxCharactersPerLineCount(), false); if (optionPane.getWantsInput()) { Object[] selection = optionPane.getSelectionValues(); if (selection == null) inputComponent = new JTextField(15); else if (selection.length < 20) inputComponent = new JComboBox(selection); else inputComponent = new JList(selection); if (inputComponent != null) { addMessageComponents(rightSide, con, inputComponent, getMaxCharactersPerLineCount(), false); resetSelectedValue(); selectInitialValue(optionPane); } } messageArea.add(rightSide, BorderLayout.EAST); return messageArea; } |
return new Object[] { OK_STRING, CANCEL_STRING }; | return (optionPane.getWantsInput() ) ? new Object[] { OK_STRING, CANCEL_STRING } : ( optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE ) ? new Object[] { YES_STRING, NO_STRING, CANCEL_STRING } : new Object[] { OK_STRING }; | protected Object[] getButtons() { if (optionPane.getOptions() != null) return optionPane.getOptions(); switch (optionPane.getOptionType()) { case JOptionPane.YES_NO_OPTION: return new Object[] { YES_STRING, NO_STRING }; case JOptionPane.YES_NO_CANCEL_OPTION: return new Object[] { YES_STRING, NO_STRING, CANCEL_STRING }; case JOptionPane.OK_CANCEL_OPTION: case JOptionPane.DEFAULT_OPTION: return new Object[] { OK_STRING, CANCEL_STRING }; } return null; } |
minimumWidth = minimumSize.width; minimumHeight = minimumSize.height; | protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); optionPane.setFont(defaults.getFont("OptionPane.font")); optionPane.setBackground(defaults.getColor("OptionPane.background")); optionPane.setForeground(defaults.getColor("OptionPane.foreground")); optionPane.setBorder(defaults.getBorder("OptionPane.border")); optionPane.setOpaque(true); messageBorder = defaults.getBorder("OptionPane.messageAreaBorder"); messageForeground = defaults.getColor("OptionPane.messageForeground"); buttonBorder = defaults.getBorder("OptionPane.buttonAreaBorder"); minimumSize = defaults.getDimension("OptionPane.minimumSize"); minimumWidth = minimumSize.width; minimumHeight = minimumSize.height; // FIXME: Image icons don't seem to work properly right now. // Once they do, replace the synthetic icons with these ones. /* warningIcon = (IconUIResource) defaults.getIcon("OptionPane.warningIcon"); infoIcon = (IconUIResource) defaults.getIcon("OptionPane.informationIcon"); errorIcon = (IconUIResource) defaults.getIcon("OptionPane.errorIcon"); questionIcon = (IconUIResource) defaults.getIcon("OptionPane.questionIcon"); */ } |
|
output.write(Constants.NEW_LINE.getBytes()); | public static void debug(String msg) { if (priority > Priority.DEBUG) return; try { output.write(msg.getBytes()); output.write(Constants.NEW_LINE.getBytes()); } catch (IOException e) { System.err.println("error in Log.debug()"); e.printStackTrace(); } } |
|
output.write(Constants.NEW_LINE.getBytes()); | public static void error(String msg) { if (priority > Priority.ERROR) return; try { output.write(msg.getBytes()); output.write(Constants.NEW_LINE.getBytes()); } catch (IOException e) { System.err.println("error in Log.error()"); e.printStackTrace(); } } |
|
output.write(Constants.NEW_LINE.getBytes()); | public static void info(String msg) { if (priority > Priority.INFO) return; try { output.write(msg.getBytes()); output.write(Constants.NEW_LINE.getBytes()); } catch (IOException e) { System.err.println("error in Log.info()"); e.printStackTrace(); } } |
|
output.write(Constants.NEW_LINE.getBytes()); | public static void warn(String msg) { if (priority > Priority.WARN) return; try { output.write(msg.getBytes()); output.write(Constants.NEW_LINE.getBytes()); } catch (IOException e) { System.err.println("error in Log.warn()"); e.printStackTrace(); } } |
|
switch (buffer[offset]) | char c = buffer[offset]; if (len > 0 && (c == '\t' || c == '\n')) { g.drawChars(buffer, pos, len, pixelX, pixelY + ascent); pixelX += pixelWidth; pixelWidth = 0; pos = offset+1; len = 0; } switch (c) | public static final int drawTabbedText(Segment s, int x, int y, Graphics g, TabExpander e, int startOffset) { // This buffers the chars to be drawn. char[] buffer = s.array; // The current x and y pixel coordinates. int pixelX = x; int pixelY = y; // The font metrics of the current selected font. FontMetrics metrics = g.getFontMetrics(); int ascent = metrics.getAscent(); for (int offset = s.offset; offset < (s.offset + s.count); ++offset) { switch (buffer[offset]) { case '\t': // In case we have a tab, we just 'jump' over the tab. // When we have no tab expander we just use the width of 'm'. if (e != null) pixelX = (int) e.nextTabStop((float) pixelX, startOffset + offset - s.offset); else pixelX += metrics.charWidth(' '); break; case '\n': // In case we have a newline, we must draw // the buffer and jump on the next line. g.drawChars(buffer, offset, 1, pixelX, y); pixelY += metrics.getHeight(); pixelX = x; break; default: // Here we draw the char. g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent); pixelX += metrics.charWidth(buffer[offset]); break; } } return pixelX; } |
g.drawChars(buffer, offset, 1, pixelX, y); | public static final int drawTabbedText(Segment s, int x, int y, Graphics g, TabExpander e, int startOffset) { // This buffers the chars to be drawn. char[] buffer = s.array; // The current x and y pixel coordinates. int pixelX = x; int pixelY = y; // The font metrics of the current selected font. FontMetrics metrics = g.getFontMetrics(); int ascent = metrics.getAscent(); for (int offset = s.offset; offset < (s.offset + s.count); ++offset) { switch (buffer[offset]) { case '\t': // In case we have a tab, we just 'jump' over the tab. // When we have no tab expander we just use the width of 'm'. if (e != null) pixelX = (int) e.nextTabStop((float) pixelX, startOffset + offset - s.offset); else pixelX += metrics.charWidth(' '); break; case '\n': // In case we have a newline, we must draw // the buffer and jump on the next line. g.drawChars(buffer, offset, 1, pixelX, y); pixelY += metrics.getHeight(); pixelX = x; break; default: // Here we draw the char. g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent); pixelX += metrics.charWidth(buffer[offset]); break; } } return pixelX; } |
|
g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent); pixelX += metrics.charWidth(buffer[offset]); | ++len; pixelWidth += metrics.charWidth(buffer[offset]); | public static final int drawTabbedText(Segment s, int x, int y, Graphics g, TabExpander e, int startOffset) { // This buffers the chars to be drawn. char[] buffer = s.array; // The current x and y pixel coordinates. int pixelX = x; int pixelY = y; // The font metrics of the current selected font. FontMetrics metrics = g.getFontMetrics(); int ascent = metrics.getAscent(); for (int offset = s.offset; offset < (s.offset + s.count); ++offset) { switch (buffer[offset]) { case '\t': // In case we have a tab, we just 'jump' over the tab. // When we have no tab expander we just use the width of 'm'. if (e != null) pixelX = (int) e.nextTabStop((float) pixelX, startOffset + offset - s.offset); else pixelX += metrics.charWidth(' '); break; case '\n': // In case we have a newline, we must draw // the buffer and jump on the next line. g.drawChars(buffer, offset, 1, pixelX, y); pixelY += metrics.getHeight(); pixelX = x; break; default: // Here we draw the char. g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent); pixelX += metrics.charWidth(buffer[offset]); break; } } return pixelX; } |
if (len > 0) g.drawChars(buffer, pos, len, pixelX, pixelY + ascent); | public static final int drawTabbedText(Segment s, int x, int y, Graphics g, TabExpander e, int startOffset) { // This buffers the chars to be drawn. char[] buffer = s.array; // The current x and y pixel coordinates. int pixelX = x; int pixelY = y; // The font metrics of the current selected font. FontMetrics metrics = g.getFontMetrics(); int ascent = metrics.getAscent(); for (int offset = s.offset; offset < (s.offset + s.count); ++offset) { switch (buffer[offset]) { case '\t': // In case we have a tab, we just 'jump' over the tab. // When we have no tab expander we just use the width of 'm'. if (e != null) pixelX = (int) e.nextTabStop((float) pixelX, startOffset + offset - s.offset); else pixelX += metrics.charWidth(' '); break; case '\n': // In case we have a newline, we must draw // the buffer and jump on the next line. g.drawChars(buffer, offset, 1, pixelX, y); pixelY += metrics.getHeight(); pixelX = x; break; default: // Here we draw the char. g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent); pixelX += metrics.charWidth(buffer[offset]); break; } } return pixelX; } |
|
super(toolkit, panel, new JPanel()); final JPanel jPanel = (JPanel)jComponent; this.panel = panel; | super(toolkit, panel, new SwingPanel(panel)); final SwingPanel jPanel = (SwingPanel) jComponent; | public SwingPanelPeer(SwingToolkit toolkit, Panel panel) { super(toolkit, panel, new JPanel()); final JPanel jPanel = (JPanel)jComponent; this.panel = panel; SwingToolkit.add(panel, jPanel); SwingToolkit.copyAwtProperties(panel, jPanel); } |
Throwable throwable = record.getThrown(); if (throwable != null) { StringWriter sink = new StringWriter(); throwable.printStackTrace(new PrintWriter(sink, true)); buf.append(sink.toString()); } | public String format(LogRecord record) { StringBuffer buf = new StringBuffer(180); if (dateFormat == null) dateFormat = DateFormat.getDateTimeInstance(); buf.append(dateFormat.format(new Date(record.getMillis()))); buf.append(' '); buf.append(record.getSourceClassName()); buf.append(' '); buf.append(record.getSourceMethodName()); buf.append(lineSep); buf.append(record.getLevel()); buf.append(": "); buf.append(formatMessage(record)); buf.append(lineSep); return buf.toString(); } |
|
Dimension e = minSize(editor); Dimension n = minSize(next); Dimension p = minSize(previous); | Dimension e = prefSize(editor); Dimension n = prefSize(next); Dimension p = prefSize(previous); | public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets i = parent.getInsets(); boolean l2r = parent.getComponentOrientation().isLeftToRight(); /* -------------- -------------- | | n | | n | | | e | - | or | - | e | | | p | | p | | -------------- -------------- */ Dimension e = minSize(editor); Dimension n = minSize(next); Dimension p = minSize(previous); Dimension s = spinner.getPreferredSize(); int x = l2r ? i.left : i.right; int y = i.top; int w = Math.max(p.width, n.width); int h = Math.max(p.height, n.height); h = Math.max(h, e.height / 2); int e_width = s.width - w; if (l2r) { setBounds(editor, x, y + (s.height - e.height) / 2, e_width, e.height); x += e_width; setBounds(next, x, y, w, h); y += h; setBounds(previous, x, y, w, h); } else { setBounds(next, x, y + (s.height - e.height) / 2, w, h); y += h; setBounds(previous, x, y, w, h); x += w; y -= h; setBounds(editor, x, y, e_width, e.height); } } } |
int h = Math.max(p.height, n.height); h = Math.max(h, e.height / 2); int e_width = s.width - w; | int h = e.height / 2; int e_width = s.width - w - i.left - i.right; | public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets i = parent.getInsets(); boolean l2r = parent.getComponentOrientation().isLeftToRight(); /* -------------- -------------- | | n | | n | | | e | - | or | - | e | | | p | | p | | -------------- -------------- */ Dimension e = minSize(editor); Dimension n = minSize(next); Dimension p = minSize(previous); Dimension s = spinner.getPreferredSize(); int x = l2r ? i.left : i.right; int y = i.top; int w = Math.max(p.width, n.width); int h = Math.max(p.height, n.height); h = Math.max(h, e.height / 2); int e_width = s.width - w; if (l2r) { setBounds(editor, x, y + (s.height - e.height) / 2, e_width, e.height); x += e_width; setBounds(next, x, y, w, h); y += h; setBounds(previous, x, y, w, h); } else { setBounds(next, x, y + (s.height - e.height) / 2, w, h); y += h; setBounds(previous, x, y, w, h); x += w; y -= h; setBounds(editor, x, y, e_width, e.height); } } } |
setBounds(editor, x, y + (s.height - e.height) / 2, e_width, e.height); | setBounds(editor, x, y, e_width, 2 * h); | public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets i = parent.getInsets(); boolean l2r = parent.getComponentOrientation().isLeftToRight(); /* -------------- -------------- | | n | | n | | | e | - | or | - | e | | | p | | p | | -------------- -------------- */ Dimension e = minSize(editor); Dimension n = minSize(next); Dimension p = minSize(previous); Dimension s = spinner.getPreferredSize(); int x = l2r ? i.left : i.right; int y = i.top; int w = Math.max(p.width, n.width); int h = Math.max(p.height, n.height); h = Math.max(h, e.height / 2); int e_width = s.width - w; if (l2r) { setBounds(editor, x, y + (s.height - e.height) / 2, e_width, e.height); x += e_width; setBounds(next, x, y, w, h); y += h; setBounds(previous, x, y, w, h); } else { setBounds(next, x, y + (s.height - e.height) / 2, w, h); y += h; setBounds(previous, x, y, w, h); x += w; y -= h; setBounds(editor, x, y, e_width, e.height); } } } |
setBounds(previous, x, y, w, h); | setBounds(previous, x, y + (s.height - e.height) / 2, w, h); | public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets i = parent.getInsets(); boolean l2r = parent.getComponentOrientation().isLeftToRight(); /* -------------- -------------- | | n | | n | | | e | - | or | - | e | | | p | | p | | -------------- -------------- */ Dimension e = minSize(editor); Dimension n = minSize(next); Dimension p = minSize(previous); Dimension s = spinner.getPreferredSize(); int x = l2r ? i.left : i.right; int y = i.top; int w = Math.max(p.width, n.width); int h = Math.max(p.height, n.height); h = Math.max(h, e.height / 2); int e_width = s.width - w; if (l2r) { setBounds(editor, x, y + (s.height - e.height) / 2, e_width, e.height); x += e_width; setBounds(next, x, y, w, h); y += h; setBounds(previous, x, y, w, h); } else { setBounds(next, x, y + (s.height - e.height) / 2, w, h); y += h; setBounds(previous, x, y, w, h); x += w; y -= h; setBounds(editor, x, y, e_width, e.height); } } } |
int otherHeight = 0; | public Dimension minimumLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getMinimumSize(); d.width += tmp.width; d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getMinimumSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getMinimumSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
otherHeight += tmp.height; | public Dimension minimumLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getMinimumSize(); d.width += tmp.width; d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getMinimumSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getMinimumSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
d.height = Math.max(d.height, otherHeight); | public Dimension minimumLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getMinimumSize(); d.width += tmp.width; d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getMinimumSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getMinimumSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
int otherHeight = 0; | public Dimension preferredLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getPreferredSize(); d.width += Math.max(tmp.width, 40); d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getPreferredSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getPreferredSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
otherHeight += tmp.height; | public Dimension preferredLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getPreferredSize(); d.width += Math.max(tmp.width, 40); d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getPreferredSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getPreferredSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
d.height = Math.max(d.height, otherHeight); | public Dimension preferredLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getPreferredSize(); d.width += Math.max(tmp.width, 40); d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getPreferredSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getPreferredSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
Insets insets = parent.getInsets(); d.width = d.width + insets.left + insets.right; d.height = d.height + insets.top + insets.bottom; | public Dimension preferredLayoutSize(Container parent) { Dimension d = new Dimension(); if (editor != null) { Dimension tmp = editor.getPreferredSize(); d.width += Math.max(tmp.width, 40); d.height = tmp.height; } int nextWidth = 0; int previousWidth = 0; int otherHeight = 0; if (next != null) { Dimension tmp = next.getPreferredSize(); nextWidth = tmp.width; otherHeight += tmp.height; } if (previous != null) { Dimension tmp = previous.getPreferredSize(); previousWidth = tmp.width; otherHeight += tmp.height; } d.height = Math.max(d.height, otherHeight); d.width += Math.max(nextWidth, previousWidth); return d; } |
|
public void propertyChange(PropertyChangeEvent evt) | public void propertyChange(PropertyChangeEvent event) | protected PropertyChangeListener createPropertyChangeListener() { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // FIXME: Add check for enabled property change. Need to // disable the buttons. if ("editor".equals(evt.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) evt.getOldValue(), (JComponent) evt.getNewValue()); } }; } |
if ("editor".equals(evt.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) evt.getOldValue(), (JComponent) evt.getNewValue()); | if ("editor".equals(event.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) event.getOldValue(), (JComponent) event.getNewValue()); | protected PropertyChangeListener createPropertyChangeListener() { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // FIXME: Add check for enabled property change. Need to // disable the buttons. if ("editor".equals(evt.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) evt.getOldValue(), (JComponent) evt.getNewValue()); } }; } |
public void propertyChange(PropertyChangeEvent evt) | public void propertyChange(PropertyChangeEvent event) | public void propertyChange(PropertyChangeEvent evt) { // FIXME: Add check for enabled property change. Need to // disable the buttons. if ("editor".equals(evt.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) evt.getOldValue(), (JComponent) evt.getNewValue()); } |
if ("editor".equals(evt.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) evt.getOldValue(), (JComponent) evt.getNewValue()); | if ("editor".equals(event.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) event.getOldValue(), (JComponent) event.getNewValue()); | public void propertyChange(PropertyChangeEvent evt) { // FIXME: Add check for enabled property change. Need to // disable the buttons. if ("editor".equals(evt.getPropertyName())) BasicSpinnerUI.this.replaceEditor((JComponent) evt.getOldValue(), (JComponent) evt.getNewValue()); } |
JComponent e = spinner.getEditor(); if (e instanceof JSpinner.DefaultEditor) { JSpinner.DefaultEditor de = (JSpinner.DefaultEditor) e; de.getTextField().setBorder(null); } | protected void installDefaults() { LookAndFeel.installColorsAndFont(spinner, "Spinner.background", "Spinner.foreground", "Spinner.font"); LookAndFeel.installBorder(spinner, "Spinner.border"); spinner.setLayout(createLayout()); spinner.setOpaque(true); } |
|
boolean niceOutput = sPrettyXDFOutput; | boolean niceOutput = Specification.getInstance().isPrettyXDFOutput(); | protected void specificIOStyleToXDF( OutputStream outputstream,String indent) { boolean niceOutput = sPrettyXDFOutput; //write out the tags info String[] tags = getAxisTags(); List axisList = parentArray.getAxisList(); String axisId; String tag; int stop = axisList.size(); synchronized (axisList) { for (int i = 0; i <stop; i++) { axisId = ((AxisInterface) axisList.get(i)).getAxisId(); tag = tags[i]; if (niceOutput) { writeOut(outputstream, Constants.NEW_LINE); writeOut(outputstream, indent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\"" + axisId + "\"" + " tag = \"" + tag + "\"/>"); } } } |
ICC_ProfileGray() | ICC_ProfileGray(int cspace) | ICC_ProfileGray() { super(ColorSpace.CS_GRAY); } |
super(ColorSpace.CS_GRAY); | super(cspace); whitePoint = getXYZData(icSigMediaWhitePointTag); | ICC_ProfileGray() { super(ColorSpace.CS_GRAY); } |
return 0; | short[] data = getCurve(icSigGrayTRCTag); if (data == null) throw new IllegalArgumentException("Couldn't read Gray TRC data."); if (data.length != 1) throw new ProfileDataException("TRC is a table, not a gamma value."); double gamma = (double) (data[0] & (0xFFFF)) / 256.0; return (float) gamma; | public float getGamma() { return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.