Thursday 25 February 2016

Create web browser with JavaFX 2.0 WebView

JavaFX 2.0 provide WebView, a full function web browser based on WebKit, an open source web browser engine. It supports Cascading Style Sheets (CSS), JavaScript, Document Object Model (DOM), and HTML5 features of rendering canvas and timed media playback.

 /*  
 * To change this template, choose Tools | Templates  
 * and open the template in the editor.  
 */  
 package javafx_webview;  
 import javafx.application.Application;  
 import javafx.scene.Scene;  
 import javafx.scene.layout.StackPane;  
 import javafx.scene.web.WebEngine;  
 import javafx.scene.web.WebView;  
 import javafx.stage.Stage;  
 /**  
 *  
 * @web https://java-tech-world.blogspot.com  
 */  
 public class JavaFX_Browser extends Application {  
  /**  
   * @param args the command line arguments  
   */  
  public static void main(String[] args) {  
    launch(args);  
  }  
  @Override  
  public void start(Stage primaryStage) {  
    primaryStage.setTitle("https://java-tech-world.blogspot.com/");  
    WebView myBrowser = new WebView();  
    WebEngine myWebEngine = myBrowser.getEngine();  
    myWebEngine.load("https://java-tech-world.blogspot.com/");  
    StackPane root = new StackPane();  
    root.getChildren().add(myBrowser);  
    primaryStage.setScene(new Scene(root, 640, 480));  
    primaryStage.show();  
  }  
 }  

Wednesday 24 February 2016

How to Switch Excel Columns and Rows

Everyone looks at information in a slightly different way. Some people create Excel spreadsheets where the data is useful, but it doesn’t work with the way you view or interact with the data. One common example is where you want to transpose or switch Excel row or column data so Row A data becomes Column A data and so on.
I recently was given a large Microsoft Excel spreadsheet that contained vendor evaluation information. The information was useful, but because of the way the data was structured, I couldn’t use tools like Auto Filter. I would also have issues if I needed to import the information to a database. A simple example of such a spreadsheet is shown below.

highlighted row to swap 

Instead, I want to have the Company names display vertically in Column A and the attributes display horizontally in Row 1. This would make it easier for me to do comparisons. For example, I can’t easily filter the spreadsheet for vendors in CA. I also didn’t want to re-enter the data. The fix is rather easy using Excel’s transpose feature.

To switch Excel columns and rows,

  1. Open the spreadsheet you need to change.
  2. If needed, insert a blank worksheet.
  3. Click the first cell of your data range such as A1.
  4. Shift-click the last cell of the range. Your selection should highlight.
  5. From the Home tab menu, select Copy.
  6. At the bottom of the page, click the tab for the blank worksheet such as Sheet2.
  7. In the blank worksheet, click cell A1.
  8. From the Home tab menu, select Paste. The Paste dialog should appear.
 transpose button on paste dialog
  1. Click the box for Transpose.
Once you transpose the data, your company names will show in Column A. I can now sort or filter the data in many ways.



transpose Excel column