嗨,我有javafx tableview问题。我试过解决办法,但没能解决这个问题。有行,可以在行之间切换,但数据没有显示。我不明白问题出在哪里。你能帮我一下吗?
public enum Task {
ADMINISTRATOR("Yetkili Dispeçer"),
DISPATCHER("Dispeçer"),
MAINTENANCE_PERSON("Bakim Sorumlusu"),
OBSERVER("Gözlemci");
private String taskEnumString;
Task(String aTaskEnumString){
this.taskEnumString = aTaskEnumString;
}
public String getTaskEnumString(){return taskEnumString;}
}
//Görev property tanimi
private SimpleStringProperty aTask;
public String getTask(){
return aTask.get();
}
public void setTask(String task){
aTask.set(task);
}
public StringProperty taskProperty(){
return aTask;
}
//Username property tanimi
private SimpleStringProperty aUsername;
public String getUsername(){
return aUsername.get();
}
public void setUsername(String username){
aUsername.set(username);
}
public StringProperty usernameProperty(){
return aUsername;
}
//Password property tanimi
private SimpleStringProperty aPassword;
public String getPassword(){
return aPassword.get();
}
public void setPassword(String password){
aPassword.set(password);
}
public StringProperty passwordProperty(){
return aPassword;
}
//Firstname property tanimi
private SimpleStringProperty aFirstname;
public String getFirstname(){
return aFirstname.get();
}
public void setFirstname(String firstname){
aFirstname.set(firstname);
}
public StringProperty firstnameProperty(){
return aFirstname;
}
//Lastname property tanimi
private SimpleStringProperty aLastname;
public String getLastname(){
return aLastname.get();
}
public void setLastname(String lastname){
aLastname.set(lastname);
}
public StringProperty lastnameProperty(){
return aLastname;
}
//Lastname property tanimi
private SimpleBooleanProperty anIsActive;
public boolean getIsActive(){
return anIsActive.get();
}
public void setIsActive(boolean isActive){
anIsActive.set(isActive);
}
public BooleanProperty isActiveProperty(){
return anIsActive;
}
public User(String taks, String username, String password, String firstName, String lastName, boolean isActive){
this.aTask = new SimpleStringProperty(taks);
this.aUsername = new SimpleStringProperty(username);
this.aPassword = new SimpleStringProperty(password);
this.aFirstname = new SimpleStringProperty(firstName);
this.aLastname = new SimpleStringProperty(lastName);
this.anIsActive = new SimpleBooleanProperty(isActive);
}
@FXML private javafx.scene.control.TableView<User> userTableView;
public void initialize() throws SQLException {
try {
addUsers();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void clickAddUser() throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/addUser.fxml"));
Parent root = fxmlLoader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
}
//tablewiev'e kullanici eklenmesi
public void addUsers() throws SQLException {
data = FXCollections.observableArrayList();
try {
List<User> userList = Main.dbManager.getUserList();
if(userList.size() != 0){
for (int i=0; i<userList.size(); i++){
User aUser = userList.get(i);
data.add(aUser);
}
}
if(userTableView != null)
userTableView.setItems(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.TableColumn?> <?import javafx.scene.control.TableView?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.Pane?> <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="525.0" prefWidth="792.0" style="-fx-background-color: linear-gradient(lightgray,gray);
-fx-padding: 10 10 10 10;" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.userManagementController"> <children>
<Pane layoutX="16.0" layoutY="14.0" prefHeight="56.0" prefWidth="759.0" style="-fx-border-color: #000000; -fx-border-width:
0.05px; -fx-padding: 10;" >
<children>
<Label layoutX="14.0" layoutY="6.0" prefHeight="17.0" prefWidth="114.0" text="KULLANICI ADI" />
<TextField layoutX="14.0" layoutY="23.0" prefHeight="25.0" prefWidth="361.0" />
<Label layoutX="399.0" layoutY="6.0" prefHeight="17.0" prefWidth="83.0" text="AKTIF/PASIF" />
<Button layoutX="399.0" layoutY="23.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="95.0" text="Aktif" />
<Button layoutX="493.0" layoutY="23.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="95.0" text="Pasif" />
<Button fx:id="addUser" layoutX="612.0" layoutY="23.0" mnemonicParsing="false" onAction="#clickAddUser" prefHeight="25.0" prefWidth="133.0" style="-fx-background-color: linear-gradient(dodgerblue,blue); -fx-padding: 3px 10px 3px 10px;
-fx-background-radius: 30,30,29,28;" text="Add User" textFill="#f8f6f6" />
</children>
</Pane>
<TableView fx:id="userTableView" layoutX="16.0" layoutY="77.0" prefHeight="433.0" prefWidth="759.0">
<columns>
<TableColumn fx:id="tbcProfile" prefWidth="75.0" />
<TableColumn fx:id="tbcUsername" prefWidth="175.0" text="Kullanici Adi" />
<TableColumn fx:id="tbcTask" prefWidth="123.0" text="Görev" />
<TableColumn fx:id="tbcName" minWidth="0.0" prefWidth="97.0" text="Adi" />
<TableColumn fx:id="tbcSurname" prefWidth="129.0" text="Soyadi" />
<TableColumn fx:id="tbcIsActive" prefWidth="79.0" text="Aktif/Pasif" />
<TableColumn fx:id="tbcEdit" prefWidth="79.0" />
</columns>
</TableView> </children> </Pane>
public ObservableList<UserTableListObject> data;
@FXML private javafx.scene.control.TableView<UserTableListObject> userTableView;
TableColumn<UserTableListObject, String> isActiveColumn;
TableColumn<UserTableListObject, String> userNameColumn;
TableColumn<UserTableListObject, String> taskColumn;
TableColumn<UserTableListObject, String> firstNameColumn;
TableColumn<UserTableListObject, String> lastNameColumn;
TableColumn<UserTableListObject, String> editDeleteColumn;
public void initialize() throws SQLException {
try {
initializeColumns();
addUsers();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void initializeColumns()
{
isActiveColumn = new TableColumn<UserTableListObject, String>("Aktif/Pasif");
isActiveColumn.setMinWidth(100);
isActiveColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("isActiveCol"));
userNameColumn = new TableColumn<UserTableListObject, String>("Kullanici Adi");
userNameColumn.setMinWidth(200);
userNameColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("userNameCol"));
taskColumn = new TableColumn<UserTableListObject, String>("Görev");
taskColumn.setMinWidth(200);
taskColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("taskCol"));
firstNameColumn = new TableColumn<UserTableListObject, String>("Adi");
firstNameColumn.setMinWidth(200);
firstNameColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("firstNameCol"));
lastNameColumn = new TableColumn<UserTableListObject, String>("Soyadi");
lastNameColumn.setMinWidth(200);
lastNameColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("lastNameCol"));
editDeleteColumn = new TableColumn<UserTableListObject, String>("Düzenle/Sil");
editDeleteColumn.setMinWidth(200);
editDeleteColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("editDeleteCol"));
}
public void clickAddUser() throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/addUser.fxml"));
Parent root = fxmlLoader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
}
//tablewiev'e kullanici eklenmesi
public void addUsers() throws SQLException {
data = FXCollections.observableArrayList();
try {
List<User> userList = Main.dbManager.getUserList();
if(userList.size() != 0){
for (int i=0; i<userList.size(); i++){
User aUser = userList.get(i);
data.add(new UserTableListObject( aUser.getIsActive(), aUser.getUsername(),aUser.getTask() ,aUser.getFirstname(), aUser.getLastname()));
}
}
userTableView.setItems(data);
userTableView.getColumns().addAll(isActiveColumn,userNameColumn,taskColumn,firstNameColumn,lastNameColumn, editDeleteColumn);
} catch (SQLException e) {
e.printStackTrace();
}
}
我解决了这个问题,这些是我的代码和fxml文件。
@FXML private javafx.scene.control.TableView<UserTableListObject> userTableView;
@FXML private TableColumn<UserTableListObject, String> isActiveColumn;
@FXML private TableColumn<UserTableListObject, String> userNameColumn;
@FXML private TableColumn<UserTableListObject, String> taskColumn;
@FXML private TableColumn<UserTableListObject, String> firstNameColumn;
@FXML private TableColumn<UserTableListObject, String> lastNameColumn;
public void initialize() throws SQLException {
try {
addUsers();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void clickAddUser() throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/addUser.fxml"));
Parent root = fxmlLoader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
}
//tablewiev'e kullanici eklenmesi
public void addUsers() throws SQLException {
ObservableList<UserTableListObject> data = FXCollections.observableArrayList();
try {
List<User> userList = Main.dbManager.getUserList();
if(userList.size() != 0){
for (int i=0; i<userList.size(); i++){
User aUser = userList.get(i);
data.add(new UserTableListObject(aUser.getIsActive(), aUser.getUsername(),aUser.getTask() ,aUser.getFirstname(), aUser.getLastname()));
}
}
isActiveColumn.setMinWidth(200);
isActiveColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("isActiveCol"){
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<UserTableListObject, String> param) {
return new ReadOnlyObjectWrapper(param.getValue().getIsActive());
}
});
userNameColumn.setMinWidth(200);
userNameColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("userNameCol"){
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<UserTableListObject, String> param) {
return new ReadOnlyObjectWrapper(param.getValue().getUsername());
}
});
taskColumn.setMinWidth(200);
taskColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("taskCol"){
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<UserTableListObject, String> param) {
return new ReadOnlyObjectWrapper(param.getValue().getTask());
}
});
firstNameColumn.setMinWidth(200);
firstNameColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("firstNameCol"){
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<UserTableListObject, String> param) {
return new ReadOnlyObjectWrapper(param.getValue().getFirstName());
}
});
lastNameColumn.setMinWidth(200);
lastNameColumn.setCellValueFactory(new PropertyValueFactory<UserTableListObject, String>("lastNameCol"){
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<UserTableListObject, String> param) {
return new ReadOnlyObjectWrapper(param.getValue().getLastName());
}
});
userTableView.setItems(data);
} catch (SQLException e) {
e.printStackTrace();
}
}
fxml文件:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <?import javafx.scene.control.Button?>
> <?import javafx.scene.control.Label?>
> <?import javafx.scene.control.TableColumn?>
> <?import javafx.scene.control.TableView?>
> <?import javafx.scene.control.TextField?>
> <?import javafx.scene.layout.Pane?>
>
> <Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="782.0"
> prefWidth="1174.0" style="-fx-background-color:
> linear-gradient(lightgray,gray); -fx-padding: 10 10 10 10;"
> xmlns="http://javafx.com/javafx/8.0.111"
> xmlns:fx="http://javafx.com/fxml/1"
> fx:controller="sample.UserManagementController">
> <children>
> <Pane layoutX="16.0" layoutY="14.0" prefHeight="56.0" prefWidth="1147.0" style="-fx-border-color: #000000; -fx-border-width:
> 0.05px; -fx-padding: 10;">
> <children>
> <Label layoutX="14.0" layoutY="6.0" prefHeight="17.0" prefWidth="114.0" text="KULLANICI ADI" />
> <TextField layoutX="14.0" layoutY="23.0" prefHeight="25.0" prefWidth="622.0" />
> <Label layoutX="774.0" layoutY="5.0" prefHeight="17.0" prefWidth="83.0" text="AKTIF/PASIF" />
> <Button layoutX="774.0" layoutY="23.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="95.0"
> text="Aktif" />
> <Button layoutX="869.0" layoutY="23.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="95.0"
> text="Pasif" />
> <Button fx:id="addUser" layoutX="1000.0" layoutY="23.0" mnemonicParsing="false" onAction="#clickAddUser"
> prefHeight="25.0" prefWidth="133.0" style="-fx-background-color:
> linear-gradient(dodgerblue,blue); -fx-padding: 3px 10px 3px 10px;
> -fx-background-radius: 30,30,29,28;" text="Add User" textFill="#f8f6f6" />
> </children>
> </Pane>
> <TableView fx:id="userTableView" layoutX="14.0" layoutY="78.0" prefHeight="690.0" prefWidth="1147.0">
> <columns>
> <TableColumn fx:id="isActiveColumn" prefWidth="75.0" text="Aktif/Pasif" />
> <TableColumn fx:id="userNameColumn" prefWidth="75.0" text="Kullanici Adi" />
> <TableColumn fx:id="taskColumn" prefWidth="75.0" text="Görev" />
> <TableColumn fx:id="firstNameColumn" prefWidth="75.0" text="Adi" />
> <TableColumn fx:id="lastNameColumn" prefWidth="75.0" text="Soyadi" />
> </columns></TableView>
> </children>
> </Pane>
数据库显示 show databases; mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | app_blogcurder | | auth_demo | | canzhieps
问题内容: 这是我学习AngularJS的第二天。我有一个我无法解决的问题。一切顺利,直到我创建了工厂。我了解工厂/服务用于重构代码。因此,我从控制器中获取了一些代码,并将其发送到工厂,以便可以加载一些数据,但是事实并非如此。这些是我的代码: index.html app.js customerController.js orders.html customerFactory.js 在Chrome
我已经在这里看了这个问题,但是我仍然找不到我做错了什么。Logcat中没有错误,并且肯定有数据被传递给它进行制作。这是我的设置: 这一切都发生在我在Android Studio中手动放置的元素下面。我有一个滚动视图。在这个滚动视图中,我有一个LinearLayout,即parentLayout,它被传递给这个类。此方法应添加另一个水平线性布局,
但我什么也得不到。当我试图回显setup_postdata之后的细节时,它只有一个回显“数组”。 当我var_dump$post时,它也会显示所有数据。 这是我时得到的结果 object(WP_Post)#614(24){[“id”]=>int(69)[“post_author”]=>string(1)“1”[“post_date”]=>string(19)“2017-08-22 02:26:43
有什么建议如何解决这个问题吗?
我试图在phpmyadmin中为我的服务器构建一个数据库,但是当我完成构建后,我无法使用PHP访问它,并且当我在MySQL中列出数据库时,它也不会显示出来。但当我在mySql中创建数据库时,它会显示在phpmyadmin中。另外,我正在运行phpmyadmin版本4.0.3,页面底部有一条声明说