Last active
March 19, 2019 02:05
-
-
Save uvlad7/58635c34de2f2c05a2768b8442361743 to your computer and use it in GitHub Desktop.
УП 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExcelController { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.collections.FXCollections; | |
import javafx.collections.ObservableList; | |
import org.controlsfx.control.spreadsheet.*; | |
public class ExcelModel extends GridBase { | |
private ExcelController controller; | |
public ExcelModel() { | |
super(99, 26); | |
ObservableList<ObservableList<SpreadsheetCell>> rows = FXCollections.observableArrayList(); | |
for (int row = 0; row < getRowCount(); ++row) { | |
final ObservableList<SpreadsheetCell> list = FXCollections.observableArrayList(); | |
for (int column = 0; column < getColumnCount(); ++column) { | |
list.add(SpreadsheetCellType.STRING.createCell(row, column, 1, 1, null)); | |
} | |
rows.add(list); | |
} | |
setRows(rows); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.collections.ObservableList; | |
import org.controlsfx.control.spreadsheet.SpreadsheetColumn; | |
import org.controlsfx.control.spreadsheet.SpreadsheetView; | |
public class ExcelTable extends SpreadsheetView { | |
private ExcelController controller; | |
public ExcelTable(ExcelModel model) { | |
super(model); | |
ObservableList<SpreadsheetColumn> columns = getColumns(); | |
for (int i = 0; i < columns.size(); i++) { | |
columns.get(i).setPrefWidth(50); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.image.Image; | |
import javafx.scene.layout.BorderPane; | |
import javafx.stage.Stage; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
/*File -> Project Structure -> Modules -> + Library -> New Library -> From Maven -> "org.controlsfx:controlsfx:8.40.14" | |
File -> Project Structure -> Project -> New SDK -> set JDK 8 or lower -> OK; | |
if import is highlighted as error, Alt+Enter on it -> Set SDK -> 8 or lower*/ | |
public class Main extends Application { | |
public static void main(String[] args) { | |
Application.launch(args); | |
} | |
@Override | |
public void start(Stage stage) { | |
ExcelModel model = new ExcelModel(); | |
ExcelTable table = new ExcelTable(model); | |
/*SwingNode swingNode = new SwingNode(); | |
createSwingContent(swingNode);*/ | |
BorderPane pane = new BorderPane(table); | |
Scene scene = new Scene(pane); | |
stage.setScene(scene); | |
stage.setTitle("Excel Date Lite"); | |
try (FileInputStream icon = new FileInputStream("src\\excel.png")) { | |
stage.getIcons().add(new Image(icon)); | |
} catch (IOException e) { | |
} | |
stage.setWidth(900); | |
stage.setHeight(600); | |
stage.show(); | |
} | |
/*private void createSwingContent(SwingNode swingNode) { | |
SwingUtilities.invokeLater(new Runnable() { | |
@Override | |
public void run() { | |
swingNode.setContent(new ExcelTable()); | |
} | |
}); | |
}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment