Here I will place some most demanding java codes, actually they are links to the actual code in my site Zybocodes.
Colors for alternate rows of jtable
The class AlternateTableRowColorRenderer overrides the getTableCellRenderer function. It alternates the color and sets it to the row. To use it, create objet of the class and set it as the property setDefaultRenderer(Object.class,object)
Textfield accepting only numeric values
The code for creating a textfield that accepts only numeric values. You can even set the precison and the length of the textfield by changing the attributes.
Auto complete data entry in the combo box
Code to auto complete the data in the combobox as they are typed. If any of the elements in the list matches the data you are entering, they will be auto completed. You just need to create a Object of the class JComboBoxAutoCompleter by passing the combobox as argument to the constructor.
Calendar component for displaying calendar and selecting a date.
The code contains a class JCalendar. It is a subclass of JDialog and can be used to create a Dialog that will pop up a Calendar. Using the calendar, you can select a date and the selected date can be obtained using calendar.getDate() function. Run the class to check its working.
Connect to derby database in embedded or client server mode.
class for connecting to the derby database. Just set the appropriate attribute values and call the static getConnection() method to connect to the database. The code is provided for embedded connection and by checking the comment you can set it for client-server mode also.
Format date, round float,round bigdecimal values and escape sequences in sql
A class that format the date to the form (Month, day year), round the float and BigDecimal to first two decimal values. It has also the code for escape sequencing the single quotes in the sql string.
Garbage collection and finalization. finalize() and gc() methods
Code showing the usage of garbage collection in java.It also shows the clean up tasks done in finalize methods and running the finalization.
gzip compression algorithm, compressing data stream using gzip
The GZIP interface is simple and thus is probably more appropriate when you have a single stream of data that you want to compress (rather than a collection of dissimilar pieces of data). Here\'s an example that compresses a single file.You should provide the filename as commandline arguments
Input and output stream classes demo.
The code shows the creation and use of typical IO configurations so you can use it as a reference when writing your own code. Note that each configuration begins with a commented number and title that corresponds to the heading for the appropriate explanation that follows in the text.
literals in java, range of primitive data types.
Code shows the literals in java and also the range of char, byte, short,long,float and double datatypes.
No comments:
Post a Comment