iPhone home button

An article in Digitimes of Taiwan has claimed that Apple would be ditching the home button and integrate the finger print recognition in the button to the touch screen.

The article said that Apple is experimenting with a new technology called Touch and Display Driver Integration.  If the rumour is true, it means Apple would need only one chip to control the display and its touch technology including forced touch and finger print recognition.

Electronic touch button has been around for a long time.  About 6 years back, I had bought a 24inch Samsung monitor and the monitor came with no buttons at all.  It took me a while to figure out how to switch on the the monitor as the power button on the bottom right was not easily recognisable as a power button.

If you have used a Samsung Galaxy before, it has already done away with mechanical buttons for a long time.  But for the iPhone, you would be wondering why the button is still there.

Now that Apple had integrated the touch ID to the button, it is obvious why the button is still there.

If you have an iPhone, you will find that if there is a part that could fail easily, it is the home button.  The reason could be that iPhone goes to sleep mode easily and this force us to touch the button each time we need to turn it on.

Mechanical button is prone to failure.  But because it is mechanical, you could feel the clicking sound each time you click on it.

Have you heard of a story on how Steve Jobs could pay attention to very little details.  It was said that he requested his iPod team to redesign the iPod headphone jack simply because it did not produce any clicking sound when you put the phone jack into the iPod.

I actually thought that having the mechanical button does make the phone feel more humane.  The one reason that I thought it would be good to have the button gone was that game gadget designers would be able to design a controller that could clip easily on both sides of the of the phone.

When it comes to gaming, I still prefer to play on a well designed controller rather than playing it on the touch screen.  Mechanical controller like a playstation controller Sixaxis, I believe, is still a better choice for many gamers.

JavaFX: Which Button Is Clicked

This entry is part 24 of 55 in the series JavaFX

To test which button is clicked, I have made use of setOnAction() method of the button object and called the relevant function accordingly.

package javafxapplication20;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;

public class JavaFXApplication20 extends Application {

    Button movButton = new Button("Movie");

    Button gameButton = new Button("Game");

    Label lb = new Label("Which Do You Prefer?");

    @Override
    public void start(Stage stage) {

        BorderPane border = new BorderPane();

        border.setPrefSize(500, 400);

        movButton.setOnAction(e -> movieButton());
        
        gameButton.setOnAction(e -> gameButton());

        HBox hbox = addHorizontalBox();
        border.setTop(hbox);
        border.setLeft(addVBox());

        Scene scene = new Scene(border);
        stage.setScene(scene);
        stage.setTitle("Which Button");
        stage.show();
    }

    private void movieButton() {

        lb.setText("Movie Button Is Clicked");

    }
    
    private void gameButton() {

        lb.setText("Game is Chosen");

    }

    private HBox addHorizontalBox() {

        HBox hbox = new HBox();
        hbox.setPadding(new Insets(15, 12, 15, 12));
        hbox.setSpacing(10);   // Gap between nodes

        hbox.getChildren().addAll(movButton, gameButton);

        return hbox;
    }

    private VBox addVBox() {

        VBox vbox = new VBox();
        vbox.setPadding(new Insets(50)); // Set all sides to 10

        lb.setFont(Font.font("Consolas", FontWeight.BOLD, 24));
        vbox.getChildren().add(lb);

        return vbox;
    }

    public static void main(String[] args) {
        launch(args);
    }
}

chosen

 

JavaFX: Removing CSS effects to a Button

This entry is part 23 of 55 in the series JavaFX

When a mouse is moved over a button, we can apply an effect such as changing the color of the button.

However, when the mouse is out of the button or out of any other nodes, we will want it to get back to its original state.

We can use remove() method if we have only one class or removeAll() method if we have more than one CSS class.

package javafxapplication19;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JavaFXApplication19 extends Application {

    Button btn = new Button("Codecrawl");

    DropShadow ds = new DropShadow();

    @Override
    public void start(Stage stage) {

        stage.setTitle("JavaFX Program!");

        StackPane stackpane = new StackPane();

        Scene scene = new Scene(stackpane, 300, 250);
        scene.getStylesheets().add("javafxapplication19/style.css");
        stage.setScene(scene);

        btn.setOnMouseEntered(e -> mouseEntered());

        btn.setOnMouseExited(e -> mouseExited());

        stackpane.getChildren().add(btn);

        stage.show();
    }

    public void mouseEntered() {

        btn.getStyleClass().add("button1");
        btn.setText("Mouse In");

    }

    public void mouseExited() {

        btn.getStyleClass().remove("button1");
        btn.setText("Mouse Out");

    }

    public static void main(String[] args) {
        launch(args);
    }

}

remove

Here is the simple style.css that we use to set the color of the button.

.button1 {
    
    -fx-base: blue;    
    
}

 

 

JavaFX: Designing A Button Using CSS

This entry is part 21 of 55 in the series JavaFX

JavaFX supports the standard CSS3 format and this allows us to design JavaFX interface using standard web page design technique.

Let us first create a new file called style.css.

First add a CSS file called style.css as shown in the screenshot below.

css

In our program, we will have to set the scene to use the style sheet using the statement below.

scene.getStylesheets().add("javafxapplication19/style.css");

Once the scene knows the path of the stylesheet, to apply the design to the button, we use a statement similar to below.

btn.getStyleClass().add("button1");
stylesheet
package javafxapplication19;
 
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
 
public class JavaFXApplication19 extends Application {
 
    @Override
    public void start(Stage stage) {
 
        stage.setTitle("JavaFX Program!");
 
        StackPane stackpane = new StackPane();
 
        Scene scene = new Scene(stackpane, 300, 250);
        scene.getStylesheets().add("javafxapplication19/style.css");
        stage.setScene(scene);
 
        Button btn = new Button("Codecrawl");
        btn.getStyleClass().add("button1");
 
        stackpane.getChildren().add(btn);
 
        stage.show();
    }
 
    public static void main(String[] args) {
        launch(args);
    }
 
}

button

Here is the style.css file where we have used to set the font and base color of the button.

.button1 {
    -fx-font: 16 arial; 
    -fx-base: #9CB6CF;    
}

 

 

JavaFX: How The Button Is Created

This entry is part 4 of 55 in the series JavaFX

We look back at the same default example and see how the button is created and displayed in the scene of the interface.

There are basically 3 sequence of actions involved.

1. We first set up the button by putting the text “Click Me” inside the button.

btn.setText("Click Me");

2. We put the button inside a Stackpane by using Stackpane’s getChildren() and add() methods.

root.getChildren().add(btn);

3.  We display the button in the scene.

primaryStage.setScene(scene);

This really shows why many of us took a long time to master Java Swing or Microsoft Foundation Class.  It is easy to be overwhelmed by these sequence of procedures that we need to set up just to display a button!

Take note that in the program below, I have made a slight modification to display a different button text when it is clicked.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javafxapplication5;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author daryl
 */
public class JavaFXApplication5 extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Click Me");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                btn.setText("Presto!");
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

button