我正在使用包含一些按钮的网格窗格。当我们单击一个按钮时,它会更改样式,而我正在实现一个重置按钮。我想做的是当我们点击那个reset
按钮时应用一种特定的样式。
这是我的代码,我尝试在其中获取应用默认样式的按钮:
public void displayNewBoard(){
for (int row = 0; row < GRID_WIDTH; row++) {
for (int col = 0; col < GRID_HEIGHT; col++) {
gZone.getChildren().setBackground(new Background(new BackgroundFill(Color.LIGHTGRAY, new CornerRadii(0),new Insets(0))));
}
}
}
gZone
是我的网格窗格,我想获取每个按钮,但该行不正确。
我还尝试了另一种方法:
for (int row = 0; row < GRID_WIDTH; row++) {
for (int col = 0; col < GRID_HEIGHT; col++) {
for (Node node : gZone.getChildren()) {
if(gZone.getRowIndex(node) == row && gZone.getColumnIndex(node) == col) {
node.setBackground(new Background(new BackgroundFill(Color.LIGHTGRAY, new CornerRadii(0),new Insets(0))));
break;
}
}
}
}
答案 0 :(得分:0)
我终于在所有按钮上使用了一个数组,这样我就可以像这样更改它们:
import React from 'react';
import PropTypes from "prop-types";
import {Textfit} from 'react-textfit'; //This will fit the text how big or small it is.
class DisplayPanel extends React.Component {
render() {
return (
<Textfit className="calculator-display">{this.props.value}</Textfit>
);
}
}
DisplayPanel.propTypes = {
value: PropTypes.string,
};
export default DisplayPanel