myTableView.setPlaceholder(new Label("My table is empty."));
Search This Blog
JavaFX: set empty message for TableView
JavaFX: how to use ListProperty?
when adding element to ListProperty, like below:
ListProperty<String> members = new SimpleListProperty<String>(); members.add("John"); members.add("David");it throws UnsupportedOperationException
java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:148) at java.util.AbstractList.add(AbstractList.java:108) at java.util.AbstractCollection.addAll(AbstractCollection.java:334) at javafx.beans.binding.ListExpression.addAll(ListExpression.java:280)The problem was that the ListProperty was not properly initialized. To make it work, see the following code
ObservableList<String> observableList = FXCollections.observableArrayList(new ArrayList<String>()); ListProperty<String> members = new SimpleListProperty<Priority>(observableList); members.add("John"); members.add("David");
see also
目前看国内电视直播最好的办法:使用Bluestacks模拟器加《电视家》APP
- 安装Bluestacks安卓模拟器
- 下载《电视家直播》破解版,用Bluestacks打开,会自动安装。
- 启动Bluestacks运行《电视家直播》,一定要调成软解码。否则不停出现源失效错误。
See also
JavaFX TreeTableView set font weight of a TreeTableColumn
Create a css file:
column.setStyle("-fx-font-weight: bold;");
Include javascript on github.com
Including raw github url of javascript in your web page will not work. You need to use some web site with CDN services to forward the request to github.
see this http://stackoverflow.com/questions/7180099/including-js-from-raw-github-com
or https://rawgit.com/
see this http://stackoverflow.com/questions/7180099/including-js-from-raw-github-com
or https://rawgit.com/
Make Papaya Javascript DICOM viewer work in JavaFX WebView
When loading Papaya Javascript DICOM/NIFTI Viewer in a JavaFX WebView, it failed with error message:
Papaya requires Safari version 6 or higher.So I checked WebKit version of JavaFX 8 using the following code:
WebView web = new WebView(); System.out.println(web.getEngine().getUserAgent());it shows the JavaFX 8 WebKit UserAgent information:
Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.19 (KHTML, like Gecko) JavaFX/8.0 Safari/538.19According to Safari version history, Safari 6.0 is based on WebKit 536.25, while Webkit in JavaFX 8 is 538.19. WebKit in JavaFX 8 is above Safari 6.0. The problem is the browser detection in Papaya could not detect the version. So the work around is to modify the Papaya source code to accept JavaFX 8 WebKit agent.
- Check out Papaya js:
git clone https://github.com/rii-mango/Papaya.git
- Edit src/js/utilities/platform-utils.js, insert the following code:
papaya.utilities.PlatformUtils.checkForBrowserCompatibility = function () { if (navigator.userAgent.indexOf('JavaFX')>=0) { return null; } ... ... ... }
- Download and build Papaya-builder, then install it into Papaya/lib/:
git clone https://github.com/rii-mango/Papaya-Builder.git cd Papaya-Builder ant cp build/papaya-builder.jar ../Papaya/lib/
- Build Papaya:
cd Papaya ./papaya-builder.sh ls build/
Java: Open a url with default web browser
Open a web page with default web browser (from Java code):
try { java.awt.Desktop.getDesktop().browse(new URI("http://notepad2.blogspot.com.au/")); } catch (Throwable e) { e.printStackTrace(); }
SIM Unlock Telstra ZTE MF60 WIFI modem
- Install ZTE MF60 Windows Driver on your Windows PC
- Install latest DC Unlocker
- Insert a non Telstra SIM, powered it on, and connect the ZTE MF60 WIFI modem to your Windows PC via USB
- Open DC-Unlocker as Administrator, select "ZTE Modems" then click "Detect" to detect the device
- Close DC Unlocker
- Run DCCrap to unlock the device (This will retain the IMEI & MAC address).
See also
JavaFX: load css from file
- load from relative path:
// the java class is in the same directory as the .css file. String css = getClass().getResource("MyApp.css").toExternalForm(); scene.getStyleSheets().add(css);
- load from absolute path:
// the .css file is stored under <ROOT>/css/ directory. String css = getClass().getResource("css/MyApp.css").toExternalForm(); scene.getStyleSheets().add(css);
JavaFX: Show grid lines of TreeTableView
- Save the following to resources/MyApp.css:
.tree-table-row-cell { -fx-background-color: -fx-table-cell-border-color, -fx-control-inner-background; -fx-background-insets: 0, 0 0 1 0; -fx-padding: 0.0em; -fx-text-fill: -fx-text-inner-color; } .tree-table-row-cell:selected { -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color; -fx-background-insets: 0, 1, 2; } .tree-table-row-cell:odd { -fx-background-color: -fx-table-cell-border-color, derive(-fx-control-inner-background,-5%); -fx-background-insets: 0, 0 0 1 0; } .tree-table-row-cell:selected:odd { -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color; -fx-background-insets: 0, 1, 2; }
- In your Java class, add the css to a scene.
String css = getClass().getResource("/resources/MyApp.css").toExternalForm(); scene.getStyleSheets().add(getClass().getResource(cs);
Java: Convert image to png format
- Make sure you have JAI & ImageIO plugins installed. Recommend to use standlone/independent jai-imageio-core from github.
- The example code:
import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public static void main(String[] args) { ImageIO.scanForPlugins(); // read a tiff image BufferedImage bufferedImage = ImageIO.read(new File("c:/tmp/1.tif")); // write back to another file in png format ImageIO.write(bufferedImage, "png", new File("c:/tmp/1.png")); }
SSH access to Github from multiple accounts
- Generate SSH Keys:
ssh-keygen -t rsa -b 4096 -C "email@personal.com" -f ~/.ssh/id_rsa_personal ssh-keygen -t rsa -b 4096 -C "email@work.com" -f ~/.ssh/id_rsa_work
The two commands above generate two key pairs: id_rsa_personal/id_rsa_personal.pub, id_rsa_work/id_rsa_work.pub. - Add SSH Keys to your github accounts.
- Add id_rsa_personal.pub to your personal github account:
- Login to your github
- Go to Settings -> Add SSH Keys
- Copy of the content of id_rsa_personal.pub to the key field
- Click Add Key
- Add id_rsa_work.pub to your github account for work:
- Login to your github
- Go to Settings -> Add SSH Keys
- Copy of the content of id_rsa_work.pub to the key field
- Click Add Key
- Create a file: ~/.ssh/config and add:
Host personal HostName github.com User git IdentityFile ~/.ssh/id_rsa_personal Host work HostName github.com User git IdentityFile ~/.ssh/id_rsa_work
ssh-add -D ssh-add id_rsa_personal ssh-add id_rsa_work
ssh -T personal Hi githubPersonal! You've successfully authenticated, but GitHub does not provide shell access. $ ssh -T work Hi githubWork! You've successfully authenticated, but GitHub does not provide shell access.
Github: Use Access Token to authenticate over HTTPS
- Login to Github
- If you have not enabled Two-factor authentication, you need to enable it:
- Go to "Settings" -> "Security"
- Generate Personal Access Tokens:
- Go to "Settings" -> "Personal Access Tokens"
- Click "Generate new token" at the top right corner.
- Remember/Copy the token.
- Insert the token to your repository url:
https://<token>@github.com/owner/repo.git
- Now you can push to the repository without typing username & password.
Subscribe to:
Posts (Atom)