Static metodlar kendiliğinden final olarak kabul edilir.
19 Temmuz 2016 Salı
18 Temmuz 2016 Pazartesi
JavaFX Task Sınıfı
Giriş
Şu satırı dahil ederiz.
İmzası şöyle
Şu satırı dahil ederiz.
import javafx.concurrent.Task;
Şöyle kullanırız.MyTask task = new MyTask();
new Thread (task).start();
call metoduİmzası şöyle
public class MyTask extends Task<ObservableList<Integer>> {
@Override
protected ObservableList<Integer> call() throws Exception { ...
}
}
JavaFX ListView Sınıfı
Giriş
Şu satırı dahil ederiz.
Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
import javafx.scene.control.ListView;
constructorŞöyle yaparız.
ListView<Integer> lv = new ListView<>();
setItems metoduŞöyle yaparız.
ObservableList<Integer> list = ...;
lv.setItems (list);
17 Temmuz 2016 Pazar
JavaFX ObservableList Sınıfı
Giriş
Şu satırı dahil ederiz.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
Bu sınıf genelde ekran bileşenleri ile kullanılır. Açıklaması şöyleconstructorA Task Which Returns An ObservableList
Because the ListView, TableView, and other UI controls and scene graph nodes make use of ObservableList, it is common to want to create and return an ObservableList from a Task. When you do not care to display intermediate values, the easiest way to correctly write such a Task is simply to construct an ObservableList within the call method, and then return it at the conclusion of the Task.
Şöyle yaparız.
ObservableList<Foo> list = FXCollections.observableArrayList();
add metoduŞöyle yaparız.
data.add(new Foo());
addListener metoduŞöyle yaparız.
ObservableList<Foo> list = ...;
list.addListener(new ListChangeListener<Foo>() {
public void onChanged(Change<? extends Foo> c) {
...
}
});
removeListener metoduŞöyle yaparız.
ListChangeListener<? super Foo> listener = ...;
list.removeListener(listener);
9 Temmuz 2016 Cumartesi
HashTable Sınıfı
Giriş
Açıklaması şöyle
Şöyledir.
Açıklaması şöyle
Hash metoduAs of the Java 2 platform v1.2, this class was retrofitted to implement the Map interface, making it a member of the Java Collections Framework. Unlike the new collection implementations, Hashtable is synchronized. If a thread-safe implementation is not needed, it is recommended to use HashMap in place of Hashtable. If a thread-safe highly-concurrent implementation is desired, then it is recommended to use ConcurrentHashMap in place of Hashtable.
Şöyledir.
hash = key.hashCode();
index = (hash & 0x7FFFFFFF) % tab.length;
25 Haziran 2016 Cumartesi
FileLock Sınıfı
Giriş
Şu satırı dahil ederiz.
constructor
Kilidi alıncaya kadar bloke olur. Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
import java.nio.channels.FileLock;
FileChannel tarafından oluşturulur.constructor
Kilidi alıncaya kadar bloke olur. Şöyle yaparız.
FileChannel fc = ...
FileLock lock = fc.tryLock();
if(lock != null){
...
}
Bloke olmasın istersek şöyle yaparız.FileChannel fc = ...;
FileLock lock = null;
// Try acquiring the lock without blocking. This method returns
// null or throws an exception if the file is already locked.
try {
lock = channel.tryLock();
} catch (OverlappingFileLockException e) {
// File is already locked in this thread or virtual machine
}
release metoduŞöyle yaparız.
// Release the lock - if it is not null!
if( lock != null ) {
lock.release();
}
FileSystems Sınıfı
Giriş
Şu satırı dahil ederiz.
getDefault metodu
Şöyle yaparız.
newFileSystem metodu - Uri
Zip dosyasını okumak için şöyle yaparız.
Şu satırı dahil ederiz.
import java.nio.file.FileSystems;
Bu sınıf Java 7 ile geliyor. Bu dosyanın içeriğini dosya sistemi gibi kullanabilmeyi sağlar.getDefault metodu
Şöyle yaparız.
FileSystem fs = FileSystems.getDefault();
newFileSystem metodu
Bu metodun 3 tane overload edilmiş hali var. Bunlar şöyle
newFileSystem(Path)
newFileSystem(Path, Map<String,?>)
newFileSystem(Path, Map<String,?>, ClassLoader)Zip dosyasını okumak için şöyle yaparız.
Path zipfile = ...
URI uriOfFileInZip;
try(FileSystem fs = FileSystems.newFileSystem(zipfile, null)){
...
}
newFileSystem metodu - Uri + Map
Zip dosyası oluşturmak için şöyle yaparız.Path zipFile = ...;
Map<String, String> env = new HashMap<String, String>() {{
put("create", "true");
}};
try (FileSystem zipFs = FileSystems.newFileSystem(
URI.create("jar:" + zipFile.toUri()), env)) {
...
}
Kaydol:
Kayıtlar (Atom)