2019 ~ REVIEWS ALL PRODUCT JVZOO

12/29/2019

set position javafx

Rate this posting:

package uidagdrop;
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.Pane;import javafx.stage.Stage;
public class positionjava extends Application {

    public static void main(String[] args) {
        launch(args);    }
    @Override    public void start(Stage primaryStage) throws Exception {

   /* }    @Override    public void start(Stage primaryStage) {*/        primaryStage.setTitle("Hello World!");        Button btn = new Button();        btn.setText("'Hello World'");        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override            public void handle(ActionEvent event) {
                System.out.println("Hello World!");            }
        });
        Pane root = new Pane();        btn.setLayoutX(0);        btn.setLayoutY(100);////        root.getChildren().add(btn);        primaryStage.setScene(new Scene(root, 300, 250));        primaryStage.show();    }


}

get position javafx

Rate this posting:

package uidagdrop;
import javafx.application.Application;        import static javafx.application.Application.launch;        import javafx.event.*;        import javafx.scene.*;        import javafx.scene.control.*;        import javafx.scene.input.MouseEvent;        import javafx.scene.layout.VBox;        import javafx.stage.*;
public class getposition extends Application {
    private static final String OUTSIDE_TEXT = "Outside Label";
    public static void main(String[] args) { launch(args); }

    @Override public void start(final Stage stage) {
        final Label reporter = new Label(OUTSIDE_TEXT);        Label monitored = createMonitoredLabel(reporter);
        VBox layout = new VBox(10);        layout.setStyle("-fx-background-color: cornsilk; -fx-padding: 10px;");        layout.getChildren().setAll(
                monitored,                reporter
        );        layout.setPrefWidth(500);
        stage.setScene(
                new Scene(layout)
        );
        stage.show();    }

    private Label createMonitoredLabel(final Label reporter) {
        final Label monitored = new Label("Mouse Location Monitor");
        monitored.setStyle("-fx-background-color: forestgreen; -fx-text-fill: white; -fx-font-size: 20px;");
        monitored.setOnMouseMoved(new EventHandler<MouseEvent>() {
            @Override public void handle(MouseEvent event) {
                String msg =
                        "(x: "       + event.getX()      + ", y: "       + event.getY()       + ") -- " +
                                "(sceneX: "  + event.getSceneX() + ", sceneY: "  + event.getSceneY()  + ") -- " +
                                "(screenX: " + event.getScreenX()+ ", screenY: " + event.getScreenY() + ")";
                reporter.setText(msg);            }
        });
        monitored.setOnMouseExited(new EventHandler<MouseEvent>() {
            @Override public void handle(MouseEvent event) {
                reporter.setText(OUTSIDE_TEXT);            }
        });
        return monitored;    }
}

dropdrag item ListView

Rate this posting:

package uidagdrop;
import javafx.application.Application;import javafx.beans.property.ObjectProperty;import javafx.beans.property.SimpleObjectProperty;import javafx.scene.Scene;import javafx.scene.control.ListCell;import javafx.scene.control.ListView;import javafx.scene.input.ClipboardContent;import javafx.scene.input.Dragboard;import javafx.scene.input.TransferMode;import javafx.scene.layout.BorderPane;import javafx.stage.Stage;
public class demo extends Application {

    private int counter = 0 ;
    private final ObjectProperty<ListCell<String>> dragSource = new SimpleObjectProperty<>();
    @Override    public void start(Stage primaryStage) {
        populateStage(primaryStage);        primaryStage.show();
        Stage anotherStage = new Stage();        populateStage(anotherStage);        anotherStage.setX(primaryStage.getX() + 300);        anotherStage.show();    }

    private void populateStage(Stage stage) {

        ListView<String> listView = new ListView<>();
        // thêm list view/ showlistview        for (int i=0; i<5; i++ ) {
            listView.getItems().add("Item "+(++counter));        }


        listView.setCellFactory(lv -> {
            //update item in listview            ListCell<String> cell = new ListCell<String>(){
                @Override                public void updateItem(String item , boolean empty) {
                    super.updateItem(item, empty);                    setText(item);                }
            };
            //set even ondragdetected            cell.setOnDragDetected(event -> {
                if (! cell.isEmpty()) {
                    //Dragboard db = cell.startDragAndDrop(TransferMode.MOVE);                    Dragboard db = cell.startDragAndDrop(TransferMode.MOVE);                    ClipboardContent cc = new ClipboardContent();                    cc.putString(cell.getItem());                    db.setContent(cc);                    dragSource.set(cell);                }
            });
            cell.setOnDragOver(event -> {
                Dragboard db = event.getDragboard();                if (db.hasString()) {
                    event.acceptTransferModes(TransferMode.MOVE);                }
            });
            //cell.setOnDragDone(event -> listView.getItems().remove(cell.getItem()));
            cell.setOnDragDropped(event -> {
                Dragboard db = event.getDragboard();                if (db.hasString() && dragSource.get() != null) {
                    // in this example you could just do                    // listView.getItems().add(db.getString());                    // but more generally:                    double x = event.getX();                    double y = event.getY();                    System.out.println("position:"+x+","+y);                    double x1 = event.getSceneX();                    double y2 = event.getSceneY();                    System.out.println("scense:"+x1+","+y2);
                    ListCell<String> dragSourceCell = dragSource.get();                    listView.getItems().add(dragSourceCell.getItem());                    event.setDropCompleted(true);                    dragSource.set(null);                } else {
                    event.setDropCompleted(false);                }
            });
            return cell ;        });
        BorderPane root = new BorderPane(listView);        Scene scene = new Scene(root, 250, 450);        stage.setScene(scene);
    }

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

12/19/2019

Rate this posting:

https://gist.github.com/abhinayagarwal/9735744

System.out.println(ButtonCell.this.getIndex());


or


Supplier supplier = getTableView().getItems().get(getIndex());

12/17/2019

Aclass

Rate this posting:

package testtableview;
import javafx.scene.control.Button;import javafx.scene.control.ComboBox;import javafx.scene.control.TextField;
public class AClass {
    private String id;    private ComboBox<String> comboBox;    private String object;
    public AClass(String id, ComboBox<String> comboBox, String object) {
        this.id = id;        this.comboBox = comboBox;        this.object = object;    }

    public String getId() {
        return id;    }

    public void setId(String id) {
        this.id = id;    }

    public ComboBox<String> getComboBox() {
        return comboBox;    }

    public void setComboBox(ComboBox<String> comboBox) {
        this.comboBox = comboBox;    }

    public String getObject() {
        return object;    }

    public void setObject(String object) {
        this.object = object;    }
}

tableviewCombobox

Rate this posting:

package testtableview;
import javafx.application.Application;import javafx.collections.FXCollections;import javafx.collections.ObservableList;import javafx.geometry.Insets;import javafx.scene.Scene;import javafx.scene.control.*;import javafx.scene.control.cell.PropertyValueFactory;import javafx.scene.layout.StackPane;import javafx.stage.Stage;
public class TableViewMain extends Application {
    @Override    public void start(Stage primaryStage) {
        TableView<AClass> table = new TableView<AClass>();        TableColumn<AClass, String> idCol  = new TableColumn<AClass, String>("ID");        TableColumn<AClass, ComboBox> optionCol = new TableColumn<AClass, ComboBox>("OPTION");        TableColumn<AClass, Object> valuesCol = new TableColumn<AClass, Object>("VALUES");

        table.setEditable(true);
        //        idCol.setCellValueFactory(new PropertyValueFactory<>("id"));        optionCol.setCellValueFactory(new PropertyValueFactory<>("comboBox"));        valuesCol.setCellValueFactory(new PropertyValueFactory<>("object"));
        table.setItems(initLoad());        table.getColumns().addAll(idCol,optionCol, valuesCol);
        StackPane root = new StackPane();        root.setPadding(new Insets(5));        root.getChildren().add(table);
        primaryStage.setTitle("TableView (o7planning.org)");
        Scene scene = new Scene(root, 450, 300);        primaryStage.setScene(scene);        primaryStage.show();    }

    public ObservableList<AClass>  initLoad(){
        ObservableList<AClass> dataTable = FXCollections.observableArrayList();        for(int i = 0; i< 7 ; i++){
            ObservableList<String> listItem = FXCollections.observableArrayList("a","b","c");            ComboBox<String> comboBox = new ComboBox<String>();            comboBox.setItems(listItem);            comboBox.getSelectionModel().select(0);            dataTable.add(new AClass(""+i,comboBox,"a"));        }
        return dataTable;    }

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

}

12/09/2019

Paging withDdataTable in vbnet

Rate this posting:

//copy dataTale
Dim firstFiveRows As DataTable = dtb.AsEnumerable().Skip(page-1).Take(numRecordPage).CopyToDataTable()

//show message
MsgBox("The file is already closed", MsgBoxStyle.Information, "Murasalat")

fixed header scroll gridview

Rate this posting:

 <div style = " background-color:aqua">
        <div style="margin: auto; margin-top: 100px; width: 617px; background-color:forestgreen ">
            <div style="height: 30px; width: 600px; ">
                <table border="1" id="tblHeader"
                    style="                        font-family: Arial;
                        font-size: 10pt;
                        width: 600px;
                        color: white;
                        background-color: blue;
                        border-collapse: collapse;
                        height: 100%;">
                    <tr>
                        <td style="width: 150px; text-align: center">CustomerID</td>
                        <td style="width: 150px; text-align: center">City</td>
                        <td style="width: 150px; text-align: center">Country</td>
                    </tr>
                </table>
            </div>

            <div style="height: 200px; width: 617px; overflow: auto;">
                <asp:GridView ID="GridView1" runat="server"
                    AutoGenerateColumns="false" Font-Names="Arial" ShowHeader="false"
                    Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" Width="100%">
                    <Columns>
                        <asp:BoundField ItemStyle-Width="150px" DataField="CustomerId" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="Name" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="Country" />
                    </Columns>
                </asp:GridView>
            </div>
        </div>
    </div>

12/08/2019

vbnet_sqlserve

Rate this posting:

Imports System.Data
Imports System.Text
Imports System.Configuration
Imports System.Data.SqlClient

Public Class About
    Inherits Page

    Private Connection As SqlConnection
    Private myCmd As SqlCommand
    Private myReader As SqlDataReader
    Private results As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            'Populating a DataTable from database.
            Dim dt As DataTable = Me.GetData()

            'Building an HTML string.
            Dim html As New StringBuilder()

            'Table start.
            html.Append("<table border = '1'>")

            'Building the Header row.
            html.Append("<tr>")
            For Each column As DataColumn In dt.Columns
                html.Append("<th>")
                html.Append(column.ColumnName)
                html.Append("</th>")
            Next
            html.Append("</tr>")

            'Building the Data rows.
            For Each row As DataRow In dt.Rows
                html.Append("<tr>")
                For Each column As DataColumn In dt.Columns
                    html.Append("<td>")
                    html.Append(row(column.ColumnName))
                    html.Append("</td>")
                Next
                html.Append("</tr>")
            Next

            'Table end.
            html.Append("</table>")

            'Append the HTML string to Placeholder.
            PlaceHolder1.Controls.Add(New Literal() With {
               .Text = html.ToString()
             })
        End If
    End Sub

    Protected Sub Login1_Authenticate(sender As Object, e As AuthenticateEventArgs) Handles Login1.Authenticate

    End Sub


    Private Function GetData() As DataTable

        Dim connetionString As String
        'connetionString = "Server=localhost;Initial Catalog=acernis;User ID=root;Password=password"
        connetionString = "server=DESKTOP-MS7EE87\LETIEN; database=constr;trusted_connection=true"
        Dim strSql As String = "SELECT * FROM Customers"
        Dim dtb As New DataTable
        Using cnn As New SqlConnection(connetionString)
            cnn.Open()
            Using dad As New SqlDataAdapter(strSql, cnn)
                dad.Fill(dtb)
            End Using
            cnn.Close()
        End Using
        Return dtb
    End Function
End Class