// get first day of week (Sunday in the U.S.)
int firstDayOfWeek = d.getFirstDayOfWeek();
// start a new line at the start of the week
if (weekday == firstDayOfWeek)
System.out.println();
System.out.printf("%d %d", new Object[] { new Integer(d), "widgets" } );to
System.out.printf("%d %s", new Object[] { new Integer(n), "widgets" } );
while (cl != Object.class);to
while (cl != null);
System.out.printf("%10.4f | %10.4f%n" + y, x, y);to
System.out.printf("%10.4f | %10.4f%n", x, y);
return super.clone();to
return (Employee) super.clone();
public Object clone() throws CloneNotSupportedExceptionto
public Employee clone() throws CloneNotSupportedException
java ReflectionTest 'TalkingClock$TimePrinter'to
java ReflectionTest TalkingClock\$TimePrinter(that is, remove the quotes and add a backslash). Both methods work, but the change matches the preceding text.
Timer t = new Timer(1000, listener)to
Timer t = new Timer(interval, listener)
JSpinner timeSpinner
JSpinner timeSpinner = new JSpinner(new
     SpinnerDateModel(new Date(), null, null, Calendar.HOUR)
     {
        public void setCalendarField(int field) {}
     });
add(panel, BorderLayout.CENTER);
panel.add(style, bold);
panel.add(component, constraints);
Spring.max(layout.getConstraints(faceLabel).getWidth(),to
Spring.max(layout.getConstraints(sizeLabel).getWidth()));
Spring.max(layout.getConstraints(faceLabel).getWidth(),(i.e., remove the second Spring.Max()
layout.getConstraints(sizeLabel).getWidth()));
public Enumeration getApplets() { return null; }to
public Enumeration<Applet> getApplets() { return null; }and
public Iterator getStreamKeys() { return null; }to
public Iterator<String> getStreamKeys() { return null; }
defaultSettings.put("color.red", "0 50 50");to
defaultSettings.put("color.red", "0");
java -Dcom.sun.management.jmxremote MyProgram.javato
java -Dcom.sun.management.jmxremote MyProgram
Pair<Employee> = ArrayAlg...
Pair<Employee> result = ArrayAlg...
enum | an enumerated type | 3 |
203. public static final int STEPS = 1000; 204. public static final int DELAY = 3;
return offset < elements.length;to
return offset < count;
22. Runnable r = new ThreadedEchoHandler(incoming); 44. public ThreadedEchoHandler(Socket i)
47. incoming = i;
stat.releaseSavepoint(svpt)to
conn.releaseSavepoint(svpt)
import java.rmi.*; public interface Product extends Remote { /** Gets the description of this product. @return the product description */ String getDescription() throws RemoteException; final int MALE = 1; final int FEMALE = 2; final int BOTH = MALE + FEMALE; }
import java.rmi.*; import java.rmi.server.*; public class ProductImpl extends UnicastRemoteObject implements Product { public ProductImpl(String n, int s, int age1, int age2, String h) throws RemoteException { name = n; ageLow = age1; ageHigh = age2; sex = s; hobby = h; } public boolean match(Customer c) { if (c.getAge() < ageLow || c.getAge() > ageHigh) return false; if (!c.hasHobby(hobby)) return false; if ((sex & c.getSex()) == 0) return false; return true; } public String getDescription() throws RemoteException { return "I am a " + name + ". Buy me!"; } private String name, hobby; private int ageLow, ageHigh, sex; }
name = (String) data.get();;to
name = (String) data.get();
import java.io.*; import java.rmi.*; import java.rmi.activation.*; public class ProductImpl extends Activatable implements Product { /** Constructs a product implementation @param id the activation id @param data the marshalled construction parameter (containing the product name) */ public ProductImpl(ActivationID id, MarshalledObject data) throws RemoteException, IOException, ClassNotFoundException { super(id, 0); name = (String) data.get(); System.out.println("Constructed " + name); } public String getDescription() throws RemoteException { return "I am a " + name + ". Buy me!"; } private String name; }
static Remote register(ActivationDescriptor desc)to
static Remote register(ActivationDesc desc)
System.out.println(orb.object_to_string(impl));to
System.out.println(orb.object_to_string(ref));
JLabel label = new JLabel();
class ColorTableCellRenderer extends JPanel implements TableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { setBackground((Color) value); if (hasFocus) setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); else setBorder(null); return this; } }
package com.horstmann.corejava;
import java.awt.*;
import java.beans.*;
/**
The bean info for the chart bean, specifying the
icons and the customizer.
*/
public class ChartBean2BeanInfo extends SimpleBeanInfo
{
public BeanDescriptor getBeanDescriptor()
{
return new BeanDescriptor(ChartBean2.class, ChartBean2Customizer.class);
}
public Image getIcon(int iconType)
{
String name = "";
if (iconType == BeanInfo.ICON_COLOR_16x16) name = "COLOR_16x16";
else if (iconType == BeanInfo.ICON_COLOR_32x32) name = "COLOR_32x32";
else if (iconType == BeanInfo.ICON_MONO_16x16) name = "MONO_16x16";
else if (iconType == BeanInfo.ICON_MONO_32x32) name = "MONO_32x32";
else return null;
return loadImage("ChartBean2_" + name + ".gif");
}
}
int outputSize= cipher.getOutputSize(inLength);to
int outputSize= cipher.getOutputSize(blockSize);
jint ThrowNew(JNIEnv *env, jclass clazz, const char msg[])to
jint ThrowNew(JNIEnv *env, jclass cl, const char msg[])
Â
# options used by netbeans launcher by default, can be overridden by explicit
# command line switches
netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-ea -J-Dapple.laf.useScreenMenuBar=true --fontsize 13"
# --- tips for more advanced options you could use ---
# for JDKs where it is supported (for example Sun's JDK 5.0 and newer),
# you can use the following set of options which enable Concurrent Mark and
# Sweep garbage collection algorithm and improve UI responsiveness
# (see FAQ item http://www.netbeans.org/kb/faqs/performance.html#FaqGCPauses)
#netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled"
# ---
# default location of J2SE JDK, can be overridden by using --jdkhome <dir> switch
netbeans_jdkhome="D:\Program Files\Java\jdk1.5.0_08"
# clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"
å…¶ä¸fontsizeå¯ä»¥æ›´å¤§,ä¸è¿‡æœ¬äh觉得13够了和netbeans5.0å·®ä¸å¤?
2.netbeans5.5ä¸åŠ å¿«ä»£ç æ½Cºé€Ÿåº¦
======================================
在选项ä¸?高çñ”选项-->>¾~–辑-->>¾~–辑器设¾|?->>Java¾~–辑å™?->完戽H—å£è‡ªåŠ¨å¼¹å‡ºä¹‹å‰çš„åšgæ—¶æ—¶é—?ž®?50讄¡½®ä¸?
高çñ”选项-->>¾~–辑-->>¾~–辑器设¾|?->>Java¾~–辑å™?-> 属性æ é‡Œé¢æŠŠåŒºåˆ†å¤§ž®å†™çš„代ç 完æˆå‰é¢çš„ž®å‹¾åŽÀLމ(默认没有选上å³false状æ€?如果ä¸å°å¿ƒé€‰ä¸Šè¯·åŽ»æŽ?
3.netbeans5.5ž®†NetBeansçš„é¡¹ç›®ç¼–è¯‘æˆæœ¬åœ°exeæ–‡äšg
======================================
æ–°å¾™å¹ç›®->>NetBeansæ’äšg模å—->>模å—套äšg™å¹ç›®
4.netbeans5.5最好将NetBeanså¿«æ·é”®è®¾ä¸ºeclipse的模å¼?本äh觉得˜q™æ ·æ–¹ä¾¿eclipse与netbeanså…±åŒä½¿ç”¨
The 10 Things You Need to Know About Java SE 6 'Mustang'
Need a digest, summary, compressed form, precis of what's up with Java SE 6 'Mustang', currently in beta ?
Here it is, the top 10 things you need to know.
1. Web Services
All developers get first class support for writing XML web service client applications. No messing with the plumbing, you can expose your APIs as .NET interoperable web services with a simple annotation. Not your style ? Want to handle the XML directly ? Knock yourself out: Mustang adds new parsing and XML to Java object mapping APIs, previously only available in Java EE implementations or the Java Web Services Pack.
2. Scripting
You can now mix in JavaScript with your Java Source code, useful for prototyping, or when you have teams with a variety of skill sets. More advanced developers can plug in their own scripting engines, and mix their favorite scripting language in with Java as they see fit.
Perhaps You ThougHt yOu couldN't program with a scripting language and Java togetheR. Which will yoUBe trYing ?
3. Database
All developers get the updated JDBC 4.0, which is a new upgrade of a well-used API, focusing mainly on making it easier to use, although there are many feature additions like special support for XML as an SQL datatype, and better integration of BLOBs and CLOBs into the APIs. My favorite ease of use things include removal of some JDBC boilerplate, and some of the new annotations which make SQL strings embed better into your JDBC application. Like decorating your getAllUsers() method with an @Query(sql="select * from user") annotation, and that being all you need.
4. More Desktop APIs
Much has been said about this spoonful of sugar (to go with the desktop team's cake), so I will only skim a little. GUI developers get a large number of new tricks to play like the ever popular yet newly incorporated SwingWorker utility to help you with threading in GUI apps, JTable sorting and filtering and a new facility for quick splash screens to quieten impatient users.
5. Monitoring and Management
Really the big deal here is that you don't need do anything special to the startup to be able to attach on demand with any of the monitoring and management tools in Java SE. Mustang adds yet more diagnostic information, and we cobundled the infamous memory heap analysis tool jhat for forensic explorations of those core dumps.
6. Compiler Access
Really aimed at people who create tools for Java development, and for frameworks like JSP or PHP engines that need to generate a bunch of classes on demand, the compiler API opens up programmatic access to javac for in-process compilation of dynamically generate Java code. Not directly intended for the everyday developer, but for those of you deafened by your screaming inner geek, roll up your sleeves and give it a try. And the rest of us will happily benefit from the tools and the improved Java frameworks that use this.
7. Pluggable Annotations
Its becoming a running joke in Java circles, at least some that contain me, that for every wished for feature missing in Java, there's a budding annotation that will solve the problem. Joke no more, because Java tool and framework vendors can put a different smile on your face, defining their own annotations and have core support for plugging in and executing the processors that do the heaving lifting that can make custom annotations so cool.
8. Desktop Deployment
Those of you deploying applications to the desktop will soon discover that its a tale of a large number of smaller changes that add up to a big difference to existing applications. Like better platform look & feels in Swing, LCD text rendering, and snappier GUI performance overall. Java apps can integrate better with the native platform with things like new access to the System Tray and Start menu of the platform. At long last, Mustang unifies the Java Plugin and Java WebStart engines which just makes sense. Java WebStart application installation got a much needed makeover.
9. Security
You can have all the security features you like in the platform (and Mustang adds a few more, like the XML-DSIG APIs for creating and manipulating digital signatures), but if you don't have well supported security administrators, your security may be at risk. So Mustang has simplified the job of its security administrators by providing various new ways to access platform native security services such as native PKI and cryptographic services on Windows for secure authentication and communication, GSS/Kerberos services for authentication, and access to LDAP servers for authenticating users.
10. The Ilities: Quality, Compatibility, Stability
You probably knew that Sun has done regular feature releases of the Java SE platform over the last 10 years, so we certainly feel like we've built up some expertise in this area (the ever growing 80,000 test cases and several million lines of code testing conformance being just one aspect of our testing activity), but different from the last release, you probably noticed that people have been downloading snapshots of Mustang for the last fifteen (not just six) months. And what's more they've been filing bugs. And what's even more we've (and some of you!) been fixing them as we go. We're even challenging people to find more. So unlike previous releases, before we even got to beta, we'd fixed a number of quality and regression issues. Doesn't that add up to a better product ? Oh, and by the way, performance is looking better than Java SE 5 'Tiger'. Already..
So now you know all you need to know. Go on, try it !
Â
The message comes from sun weblog My short BIO