private ScrollPane createMatchingUsersPane() { ScrollPane matchingUsersPane = new ScrollPane(); matchingUsersPane.setMaxHeight(200); matchingUsersPane.setMinHeight(200); matchingUsersPane.setContent(matchingUsersBox); return matchingUsersPane; }
protected Node getContentNode() { Node taskView = getTaskView(); if (SettingsUtil.loadSettings().isShowStatistics()) { LOGGER.debug("Statistics enabled in settings"); statisticsView = new VBox(20); // wrap statistics in scrollpane ScrollPane scrollPane = new ScrollPane(statisticsView); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setFitToWidth(true); scrollPane.setPadding(new Insets(7)); // both statistics and task view present // show both in a split pane SplitPane splitPane = new SplitPane(); splitPane.setOrientation(Orientation.HORIZONTAL); splitPane.setDividerPosition(0, 0.8); splitPane.getItems().addAll(taskView, scrollPane); return splitPane; } else { LOGGER.debug("Statistics disabled in settings"); return taskView; } }
public void displayPane() throws IOException { addStationsToCB(); paneTop.getColumnConstraints().add(new ColumnConstraints(60)); paneTop.getColumnConstraints().add(new ColumnConstraints(200)); paneTop.getColumnConstraints().add(new ColumnConstraints(100)); paneBot.getColumnConstraints().add(new ColumnConstraints(60)); paneBot.getColumnConstraints().add(new ColumnConstraints(200)); paneBot.getColumnConstraints().add(new ColumnConstraints(100)); paneCenter.getColumnConstraints().add(new ColumnConstraints(300)); paneTop.setPadding(new Insets(10, 10, 10, 10)); paneTop.setAlignment(Pos.CENTER); paneTop.setHgap(5); paneTop.setVgap(5); paneBot.setPadding(new Insets(10, 10, 10, 10)); paneBot.setAlignment(Pos.CENTER); paneBot.setHgap(5); paneBot.setVgap(5); paneTop.add(new Label("Station :"), 0, 0); paneTop.add(cbStations, 1, 0); paneTop.add(btOpen, 2, 0); paneBot.add(new Label("Quantity :"), 0, 0); paneBot.add(cbQuantity, 1, 0); paneBot.add(btShow, 2, 0); paneTop.setHalignment(btOpen, HPos.RIGHT); paneBot.setHalignment(btShow, HPos.RIGHT); paneCenter.setHgap(5); paneCenter.setVgap(5); paneCenter.setAlignment(Pos.CENTER); sp.setContent(paneCenter); sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); bp.setMargin(sp, new Insets(20, 50, 40, 50)); bp.setTop(paneTop); bp.setCenter(sp); bp.setBottom(paneBot); btOpen.setOnAction( e -> { try { open(); } catch (IOException er) { er.printStackTrace(); } }); btShow.setOnAction(e -> showGraph()); }
private Component getScrollChild() { ScrollPane sp = (ScrollPane) target; Component child = null; try { child = sp.getComponent(0); } catch (ArrayIndexOutOfBoundsException e) { // do nothing. in this case we return null } return child; }
public void addImageTab(Path imagePath) { TabPane previewTabPane = controller.getPreviewTabPane(); ImageTab tab = new ImageTab(); tab.setPath(imagePath); tab.setText(imagePath.getFileName().toString()); if (previewTabPane.getTabs().contains(tab)) { previewTabPane.getSelectionModel().select(tab); return; } Image image = new Image(IOHelper.pathToUrl(imagePath)); ImageView imageView = new ImageView(image); imageView.setPreserveRatio(true); imageView.setFitWidth(previewTabPane.getWidth()); previewTabPane .widthProperty() .addListener( (observable, oldValue, newValue) -> { imageView.setFitWidth(previewTabPane.getWidth()); }); Tooltip tip = new Tooltip(imagePath.toString()); Tooltip.install(tab.getGraphic(), tip); ScrollPane scrollPane = new ScrollPane(); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); scrollPane.setContent(imageView); scrollPane.addEventFilter( ScrollEvent.SCROLL, e -> { if (e.isControlDown() && e.getDeltaY() > 0) { // zoom in imageView.setFitWidth(imageView.getFitWidth() + 16.0); } else if (e.isControlDown() && e.getDeltaY() < 0) { // zoom out imageView.setFitWidth(imageView.getFitWidth() - 16.0); } }); tab.setContent(scrollPane); TabPane tabPane = previewTabPane; tabPane.getTabs().add(tab); tabPane.getSelectionModel().select(tab); }
public ImageFrame(int width, int height) throws HeadlessException { main = new JPanel(); main.setLayout(new BoxLayout(main, BoxLayout.X_AXIS)); ScrollPane scroll = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); getContentPane().add(scroll); scroll.add(main); setPreferredSize(new Dimension(width, height)); pack(); setVisible(true); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
@FXML private void customersButtonClicked(ActionEvent event) { configureButtons(); customersButton.setGraphic(customersSelectedIMV); // Clear old content contentPane.getChildren().clear(); titleLabel.setText("Customer Information"); ScrollPane scrollPane = new ScrollPane(); contentPane.getChildren().add(scrollPane); VBox box = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // set up for ALL CUSTOMERS Text cHeader = new Text("All Customers"); cHeader.setFont(new Font("System", 24)); ObservableList<Customer> data = FXCollections.observableArrayList(operation.getAllCustomers()); TableView cTable = new TableView(); TableColumn cfnCol = new TableColumn("First Name"); cfnCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn clnCol = new TableColumn("Last Name"); clnCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn cEmailCol = new TableColumn("Email"); cEmailCol.setCellValueFactory(new PropertyValueFactory<>("email")); TableColumn cUpdatedAtCol = new TableColumn("Updated At"); cUpdatedAtCol.setCellValueFactory(new PropertyValueFactory<>("updatedAt")); TableColumn cDiscountCol = new TableColumn("Discount"); cDiscountCol.setCellValueFactory(new PropertyValueFactory<>("discount")); cTable.getColumns().addAll(cfnCol, clnCol, cEmailCol, cUpdatedAtCol, cDiscountCol); cTable.setItems(data); cTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); box.getChildren().addAll(cHeader, cTable); scrollPane.setContent(box); }
public void doLayout() { super.doLayout(); if (getScrollbarDisplayPolicy() == SCROLLBARS_NEVER) { // Use this class's calculateChildSize() and re-do layout of child Component c = getComponent(0); Dimension cs = calculateChildSize(); Insets i = getInsets(); c.setBounds(i.left, i.top, cs.width, cs.height); } }
public PrenotaViaggioView( Stage stage, PrenotaViaggioControl prenotaViaggioControl, GpMediator gpimpl) { this.prenotaViaggioControl = prenotaViaggioControl; this.gpMediator = gpimpl; gpimpl.addColleague(this); this.tg = new ToggleGroup(); this.gridCredential = new GridPane(); double percentageWidth = 0.50; double percentageHeight = 0.50; layout = new SplitPane(); layout.setPadding(new Insets(20, 0, 20, 20)); layout.setOrientation(Orientation.HORIZONTAL); Rectangle2D screenSize = Screen.getPrimary().getBounds(); percentageWidth *= screenSize.getWidth(); percentageHeight *= screenSize.getHeight(); sp1 = buildLeft(); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(sp1); sp2 = new StackPane(); layout.getItems().addAll(scrollPane, sp2); layout.setDividerPositions(0.5f, 0.5f); this.scene = new Scene(layout, percentageWidth, percentageHeight); scene.getStylesheets().add("JMetroLightTheme.css"); stage.getIcons().add(new Image("icon.png")); stage.setTitle("Creazione Viaggio Gruppo"); stage.setScene(scene); stage.show(); }
private void initDialog() { dialog.initOwner(mainApp.getPrimaryStage()); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initStyle(StageStyle.DECORATED); dialog.setResizable(true); dialog.setTitle("Recordings Already Exist"); dialog.setHeaderText("Replace or rename recordings?"); dialog.getDialogPane().setPadding(new Insets(10)); VBox vbox = new VBox(); vbox.setSpacing(10); dialog.getDialogPane().setContent(vbox); Label label = new Label( "Archiving the following recordings will replace files on your computer unless you rename them:"); vbox.getChildren().add(label); VBox recordingBox = new VBox(); recordingBox.setSpacing(20); for (Recording recording : recordingsToDisplay) { recording.setFileExistsAction(Recording.FileExistsAction.REPLACE); recordingBox.getChildren().add(buildRecordingGrid(recording)); } ScrollPane scrollPane = new ScrollPane(); scrollPane.getStyleClass().add("recording-exists-list"); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setContent(recordingBox); scrollPane.setPadding(new Insets(10)); vbox.getChildren().add(scrollPane); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); }
private void buildUserCredentials(ActionEvent event) { // System.out.println("Valore di numreserved " + Integer.toString(numreserved)); GridPane gp = ((GridPane) ((Button) event.getSource()).getParent()); int numreserved = ((Spinner<Integer>) gp.getChildren().get(0)).getValue(); gridCredential.getChildren().clear(); /* int j =0; for(int i=0; i<numreserved*3;i = i + 3){ Label nameL = new Label("Nome partecipante"); Label surnameL = new Label("Cognome partecipante"); Label birthdayL = new Label("Data Nascita"); TextField txname = new TextField(); TextField txsurname = new TextField(); TextField txbirthday = new TextField(); gridCredential.add(nameL,j,i); gridCredential.add(txname,j+1,i); gridCredential.add(surnameL,j,i+1); gridCredential.add(txsurname,j+1,i+1); gridCredential.add(birthdayL,j,i+2); gridCredential.add(txbirthday,j+1,i+2); gridCredential.setVgap(20); gridCredential.setHgap(3); }*/ for (int i = 0; i < numreserved; i++) { GridPane grd = new GridPane(); Label lblL = new Label("Inserire credenziali partecipante"); Label nameL = new Label("Nome partecipante"); Label surnameL = new Label("Cognome partecipante"); Label birthdayL = new Label("Data Nascita"); TextField txname = new TextField(); TextField txsurname = new TextField(); TextField txbirthday = new TextField(); grd.add(lblL, 0, 0); grd.addRow(1); grd.add(nameL, 0, 2); grd.add(txname, 1, 2); grd.add(surnameL, 0, 3); grd.add(txsurname, 1, 3); grd.add(birthdayL, 0, 4); grd.add(txbirthday, 1, 4); grd.addRow(5); grd.setVgap(10); grd.setHgap(3); gridCredential.add(grd, 0, i); } Button okButton = new Button("OK"); gridCredential.add(okButton, 0, numreserved); okButton.setId(((RadioButton) tg.getSelectedToggle()).getId()); okButton.setOnAction(prenotaViaggioControl::reserveTrip); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(gridCredential); gp.add(scrollPane, 0, 1); gpMediator.send(gridCredential, this); }
private void showWindow(boolean showCharacterList, boolean showAddCharacterPanel) { scrollPane.setVisible(showCharacterList); addCharacterBox.setVisible(showAddCharacterPanel); }
public ConfigurationsDialogBuilder create( DependencyDotFileGenerator dependencyDotFileGenerator, GradleScriptPreferences preferences, Os os, String outputFileName) { this.outputFileName = outputFileName; this.dependencyDotFileGenerator = dependencyDotFileGenerator; this.preferences = preferences; this.os = os; dialog = new ConfigurationChoiceDialog(this); dialog.setResizable(true); dialog.initStyle(UTILITY); dialog.initModality(APPLICATION_MODAL); dialog.setIconified(false); dialog.centerOnScreen(); dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build(); dialog.stackPane = new StackPane(); StackPane stackPane = dialog.stackPane; dialog.log = new TextArea(); TextArea log = dialog.log; BorderPane borderPanel = dialog.borderPanel; // message dialog.configurationsBox = new VBox(); VBox configurationsBox = dialog.configurationsBox; dialog.configurationsBox = configurationsBox; dialog.progressIndicator = new ProgressIndicator(); ProgressIndicator progressIndicator = dialog.progressIndicator; stackPane.getChildren().add(log); stackPane.getChildren().add(progressIndicator); progressIndicator.setPrefSize(50, 50); progressIndicator.setMaxSize(50, 50); configurationsBox.setSpacing(15); configurationsBox.setAlignment(CENTER_LEFT); dialog.scrollPane = new ScrollPane(); ScrollPane scrollPane = dialog.scrollPane; scrollPane.setContent(configurationsBox); dialog.borderPanel.setCenter(stackPane); BorderPane.setAlignment(configurationsBox, CENTER_LEFT); BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN)); // buttons dialog.buttonsPanel = new HBox(); final HBox buttonsPanel = dialog.buttonsPanel; buttonsPanel.setSpacing(MARGIN); buttonsPanel.setAlignment(BOTTOM_CENTER); BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0)); borderPanel.setBottom(buttonsPanel); borderPanel .widthProperty() .addListener( new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { buttonsPanel.layout(); } }); dialog.scene = new Scene(borderPanel); dialog.setScene(dialog.scene); URL resource = ConfigurationsDialogBuilder.class.getResource( "/com/nurflugel/gradle/ui/dialogservice/dialog.css"); String externalForm = resource.toExternalForm(); // dialog.borderPanel.styleClass("dialog"); dialog.getScene().getStylesheets().add(externalForm); return this; }
@FXML private void ratingButtonClicked(ActionEvent event) throws SQLException { configureButtons(); ratingButton.setGraphic(ratingSelectedIMV); // clear old content contentPane.getChildren().clear(); // set up titleLabel.setText("Rating and Feedback"); // rating box HBox ratingBox = new HBox(); ratingBox.setAlignment(Pos.CENTER); ratingBox.setSpacing(20); ratingBox.setPadding(new Insets(10, 0, 10, 0)); // Rating label Label ratingTitle = new Label("Average Rating: "); ratingTitle.setFont(new Font("System", 24)); // 5 stars String yellowStarURL = "Graphics/StarYellow.png"; String blankStarURL = "Graphics/StarBlank.png"; ImageView starBlank1 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank2 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank3 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank4 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank5 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); Button star1 = new Button(); star1.setGraphic(starBlank1); star1.setStyle("-fx-background-color: transparent"); Button star2 = new Button(); star2.setGraphic(starBlank2); star2.setStyle("-fx-background-color: transparent"); Button star3 = new Button(); star3.setGraphic(starBlank3); star3.setStyle("-fx-background-color: transparent"); Button star4 = new Button(); star4.setGraphic(starBlank4); star4.setStyle("-fx-background-color: transparent"); Button star5 = new Button(); star5.setGraphic(starBlank5); star5.setStyle("-fx-background-color: transparent"); // get average rating double avgRating = 0; try { avgRating = operation.getAverageRating(); } catch (SQLException e) { e.printStackTrace(); ratingTitle.setText("Error! Can't get average rating"); } Button[] buttonlist = new Button[5]; buttonlist[0] = star1; buttonlist[1] = star2; buttonlist[2] = star3; buttonlist[3] = star4; buttonlist[4] = star5; for (int i = 0; i < Math.floor(avgRating); i++) { ImageView image = new ImageView(new Image(getClass().getResourceAsStream(yellowStarURL))); buttonlist[i].setGraphic(image); } // feedback box VBox feedBackBox = new VBox(); feedBackBox.setAlignment(Pos.CENTER); feedBackBox.setSpacing(20); // Feedback title Label feedBackLabel = new Label("Feedback:"); feedBackLabel.setFont(new Font("System", 24)); // get feedback string String feedback = ""; ArrayList<Rating> list = operation.getRatingsAndFeedbacks(); for (Rating r : list) { feedback += r.getFeedback() + "\n\n"; } Text feedbackText = new Text(feedback); feedbackText.setFont(new Font("System", 14)); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(feedbackText); // Add children nodes to appropriate boxes ratingBox.getChildren().addAll(ratingTitle, star1, star2, star3, star4, star5); feedBackBox.getChildren().addAll(feedBackLabel, scrollPane); // main box VBox mainBox = new VBox(); mainBox.setSpacing(40); mainBox.getChildren().addAll(ratingBox, feedBackBox); contentPane.getChildren().add(mainBox); }
public void run() { if (getScrollChild() == null) { return; } ScrollPane sp = (ScrollPane) WScrollPanePeer.this.target; ScrollPaneAdjustable adj = null; // ScrollPaneAdjustable made public in 1.4, but // get[HV]Adjustable can't be declared to return // ScrollPaneAdjustable because it would break backward // compatibility -- hence the cast if (orient == Adjustable.VERTICAL) { adj = (ScrollPaneAdjustable) sp.getVAdjustable(); } else if (orient == Adjustable.HORIZONTAL) { adj = (ScrollPaneAdjustable) sp.getHAdjustable(); } else { if (dbg.on) dbg.assertion(false); } if (adj == null) { return; } int newpos = adj.getValue(); switch (type) { case AdjustmentEvent.UNIT_DECREMENT: newpos -= adj.getUnitIncrement(); break; case AdjustmentEvent.UNIT_INCREMENT: newpos += adj.getUnitIncrement(); break; case AdjustmentEvent.BLOCK_DECREMENT: newpos -= adj.getBlockIncrement(); break; case AdjustmentEvent.BLOCK_INCREMENT: newpos += adj.getBlockIncrement(); break; case AdjustmentEvent.TRACK: newpos = this.pos; break; default: if (dbg.on) dbg.assertion(false); return; } // keep scroll position in acceptable range newpos = Math.max(adj.getMinimum(), newpos); newpos = Math.min(adj.getMaximum(), newpos); // set value, this will synchronously fire an AdjustmentEvent adj.setValueIsAdjusting(isAdjusting); // Fix for 4075484 - consider type information when creating AdjustmentEvent // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK // Instead, we call private method setTypedValue of ScrollPaneAdjustable. // Because ScrollPaneAdjustable is in another package we should call it through native code. setTypedValue(adj, newpos, type); // Paint the exposed area right away. To do this - find // the heavyweight ancestor of the scroll child. Component hwAncestor = getScrollChild(); while (hwAncestor != null && !(hwAncestor.getPeer() instanceof WComponentPeer)) { hwAncestor = hwAncestor.getParent(); } if (dbg.on) { dbg.assertion( hwAncestor != null, "couldn't find heavyweight ancestor of scroll pane child"); } WComponentPeer hwPeer = (WComponentPeer) hwAncestor.getPeer(); hwPeer.paintDamagedAreaImmediately(); }
private void erzeugeDetailAnsicht(PolizistDaten SpaltenDaten) { Label LabelA = new Label("PersonenID"); Label LabelAWert = new Label(Integer.toString(SpaltenDaten.getPersonenID())); Label LabelB = new Label("Name"); Label LabelBWert = new Label(SpaltenDaten.getName()); Label LabelC = new Label("Geburtsdatum"); Label LabelCWert = new Label(SpaltenDaten.getGebDatum()); Label LabelD = new Label("Nationalität"); Label LabelDWert = new Label(SpaltenDaten.getNation()); Label LabelE = new Label("Geschlecht"); Label LabelEWert = new Label(SpaltenDaten.getGeschlecht()); Label LabelF = new Label("Todesdatum"); Label LabelFWert = new Label(SpaltenDaten.getTodDatum()); Label LabelG = new Label("Dienstgrad"); Label LabelGWert = new Label(SpaltenDaten.getDienstgrad()); Button ButtonBearbeiten = new Button("Bearbeiten..."); Button ButtonLoeschen = new Button("Löschen"); Button ButtonSuchePerson = new Button("Suche nach Person"); Button ButtonSucheArbeit = new Button("Suche nach Arbeitsverhältnissen"); Button ButtonSucheArbeitAn = new Button("Suche nach zugewiesenen Fällen"); Button ButtonSucheNotizen = new Button("Suche nach erstellten Notizen"); Button ButtonSucheIndizien = new Button("Suche nach eingestellten Indizien"); Button ButtonClose = new Button("Detailansicht verlassen"); ButtonBearbeiten.setOnAction( event -> { Tabelle.getSelectionModel().clearSelection(); Tabelle.getSelectionModel().select(SpaltenDaten); updateSelectedEntry(); Hauptprogramm.setRechteAnsicht(null); }); ButtonLoeschen.setOnAction( event -> { Tabelle.getSelectionModel().clearSelection(); Tabelle.getSelectionModel().select(SpaltenDaten); deleteSelectedEntrys(); Hauptprogramm.setRechteAnsicht(null); }); ButtonSuchePerson.setOnAction( event -> { Hauptprogramm.setRechteAnsicht(null); PersonenAM.PersonenSuchAnsicht(SpaltenDaten.getPersonenID()); }); ButtonSucheArbeit.setOnAction( event -> { Hauptprogramm.setRechteAnsicht(null); ArbeitenAM.SucheNachPersonenID(SpaltenDaten.getPersonenID()); }); ButtonSucheArbeitAn.setOnAction( event -> { Hauptprogramm.setRechteAnsicht(null); ArbeitenAnAM.SucheNachPersonenID(SpaltenDaten.getPersonenID()); }); ButtonSucheNotizen.setOnAction( event -> { Hauptprogramm.setRechteAnsicht(null); NotizAM.SucheNachAnlegendem(SpaltenDaten.getPersonenID()); }); ButtonSucheIndizien.setOnAction( event -> { Hauptprogramm.setRechteAnsicht(null); IndizAM.SucheNachAnlegendem(SpaltenDaten.getPersonenID()); }); ButtonClose.setOnAction(event -> Hauptprogramm.setRechteAnsicht(null)); ButtonBearbeiten.setMaxWidth(Double.MAX_VALUE); ButtonBearbeiten.setMinWidth(150); ButtonLoeschen.setMaxWidth(Double.MAX_VALUE); ButtonLoeschen.setMinWidth(150); ButtonSuchePerson.setMaxWidth(Double.MAX_VALUE); ButtonSucheArbeit.setMaxWidth(Double.MAX_VALUE); ButtonSucheArbeitAn.setMaxWidth(Double.MAX_VALUE); ButtonSucheNotizen.setMaxWidth(Double.MAX_VALUE); ButtonSucheIndizien.setMaxWidth(Double.MAX_VALUE); ButtonClose.setMaxWidth(Double.MAX_VALUE); // Wir haben ein Gridpane oben, eine HBox unten in einer VBox in einem ScrollPane GridPane Oben = new GridPane(); Oben.setHgap(10); Oben.setVgap(10); Oben.addColumn(0, LabelA, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG); Oben.addColumn( 1, LabelAWert, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert); Oben.getColumnConstraints().add(new ColumnConstraints(100)); Oben.getColumnConstraints().add(new ColumnConstraints(200)); HBox Unten = new HBox(10); Unten.getChildren().addAll(ButtonBearbeiten, ButtonLoeschen); Unten.setMaxWidth(300); Unten.alignmentProperty().setValue(Pos.CENTER); VBox Mittelteil = new VBox(10); Mittelteil.setPadding(new Insets(10, 20, 10, 10)); Mittelteil.getChildren() .addAll( Oben, Unten, ButtonSuchePerson, ButtonSucheArbeit, ButtonSucheArbeitAn, ButtonSucheNotizen, ButtonSucheIndizien, ButtonClose); ScrollPane Aussen = new ScrollPane(); Aussen.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); Aussen.setContent(Mittelteil); Hauptprogramm.setRechteAnsicht(Aussen); }
/** * The child component has been resized. The scrollbars must be updated with the new sizes. At the * native level the sizes of the actual windows may not have changed yet, so the size information * from the java-level is passed down and used. */ public void childResized(int width, int height) { ScrollPane sp = (ScrollPane) target; Dimension vs = sp.getSize(); setSpans(vs.width, vs.height, width, height); setInsets(); }
public dbfShow(String title, String fname) throws Exception { super(title); String dbname; addWindowListener(this); sp = new ScrollPane(); viewPane = new Panel(); sp.add(viewPane); this.add(sp); if (fname == null || fname.length() == 0) { FileDialog fd = new FileDialog(this, "dbfShow", FileDialog.LOAD); fd.setFile("*.DBF"); fd.pack(); fd.setVisible(true); String DBFname = fd.getFile(); String dirname = fd.getDirectory(); if (DBFname == null) { System.exit(0); } if (DBFname.length() < 1) { System.exit(0); } dbname = new String(dirname + DBFname); } else { dbname = new String(fname); } MenuBar mb = new MenuBar(); this.setMenuBar(mb); Menu file = new Menu("File"); opener = new MenuItem("Open.."); file.add(opener); opener.addActionListener(this); packer = new MenuItem("Pack"); packer.addActionListener(this); file.add(packer); quiter = new MenuItem("Quit"); file.add(quiter); quiter.addActionListener(this); mb.add(file); Menu record = new Menu("Record"); firstRecord = new MenuItem("First"); firstRecord.addActionListener(this); record.add(firstRecord); nextRecord = new MenuItem("Next"); nextRecord.addActionListener(this); record.add(nextRecord); prevRecord = new MenuItem("Prev"); prevRecord.addActionListener(this); record.add(prevRecord); lastRecord = new MenuItem("Last"); lastRecord.addActionListener(this); record.add(lastRecord); addRecord = new MenuItem("Add"); addRecord.addActionListener(this); record.add(addRecord); updateRecord = new MenuItem("Update"); updateRecord.addActionListener(this); record.add(updateRecord); clearRecord = new MenuItem("Clear"); clearRecord.addActionListener(this); record.add(clearRecord); mb.add(record); crl = new Label("Record", Label.RIGHT); trl = new Label(" of ", Label.LEFT); SBrecpos = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 0, 0); SBrecpos.addAdjustmentListener(this); delCB = new Checkbox("Deleted"); delCB.addItemListener(this); Prev = new Button("<<Prev"); Prev.addActionListener(this); Next = new Button("Next>>"); Next.addActionListener(this); Add = new Button("Add"); Add.addActionListener(this); Update = new Button("Update"); Update.addActionListener(this); Clear = new Button("Clear"); Clear.addActionListener(this); setupDBFields(dbname); setTitle(dbname + ", org.xBaseJ Version:" + org.xBaseJ.DBF.xBaseJVersion); pack(); setVisible(true); }
/** Create the whole GUI, and set up event listeners */ public AllComponents(String title) { super(title); // set frame title. // Arrange to detect window close events this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // Set a default font this.setFont(new Font("SansSerif", Font.PLAIN, 12)); // Create the menubar. Tell the frame about it. MenuBar menubar = new MenuBar(); this.setMenuBar(menubar); // Create the file menu. Add to menubar. Menu file = new Menu("File"); menubar.add(file); // Create two items for the file menu, setting their label, shortcut, // action command and listener. Add them to File menu. // Note that we use the frame itself as the action listener MenuItem open = new MenuItem("Open", new MenuShortcut(KeyEvent.VK_O)); open.setActionCommand("open"); open.addActionListener(this); file.add(open); MenuItem quit = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q)); quit.setActionCommand("quit"); quit.addActionListener(this); file.add(quit); // Create Help menu; add an item; add to menubar // Display the help menu in a special reserved place. Menu help = new Menu("Help"); menubar.add(help); menubar.setHelpMenu(help); // Create and add an item to the Help menu MenuItem about = new MenuItem("About", new MenuShortcut(KeyEvent.VK_A)); about.setActionCommand("about"); about.addActionListener(this); help.add(about); // Now that we've done the menu, we can begin work on the contents of // the frame. Assign a BorderLayout manager with margins for this frame. this.setLayout(new BorderLayout(10, 10)); // Create two panels to contain two columns of components. Use our custom // ColumnLayout layout manager for each. Add them on the west and // center of the frame's border layout Panel column1 = new Panel(); column1.setLayout(new ColumnLayout(5, 10, 2, ColumnLayout.LEFT)); this.add(column1, "West"); Panel column2 = new Panel(); column2.setLayout(new ColumnLayout(5, 10, 2, ColumnLayout.LEFT)); this.add(column2, "Center"); // Create a panel to contain the buttons at the bottom of the window // Give it a FlowLayout layout manager, and add it along the south border Panel buttonbox = new Panel(); buttonbox.setLayout(new FlowLayout(FlowLayout.CENTER, 100, 10)); this.add(buttonbox, "South"); // Create pushbuttons and add them to the buttonbox Button okay = new Button("Okay"); Button cancel = new Button("Cancel"); buttonbox.add(okay); buttonbox.add(cancel); // Handle events on the buttons ActionListener buttonlistener = new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.append("You clicked: " + ((Button) e.getSource()).getLabel() + "\n"); } }; okay.addActionListener(buttonlistener); cancel.addActionListener(buttonlistener); // Now start filling the left column. // Create a 1-line text field and add to left column, with a label TextField textfield = new TextField(15); column1.add(new Label("Name:")); column1.add(textfield); // Handle events on the TextField textfield.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.append("Your name is: " + ((TextField) e.getSource()).getText() + "\n"); } }); textfield.addTextListener( new TextListener() { public void textValueChanged(TextEvent e) { textarea.append("You have typed: " + ((TextField) e.getSource()).getText() + "\n"); } }); // Create a dropdown list or option menu of choices Choice choice = new Choice(); choice.addItem("red"); choice.addItem("green"); choice.addItem("blue"); column1.add(new Label("Favorite color:")); column1.add(choice); // Handle events on this choice choice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { textarea.append("Your favorite color is: " + e.getItem() + "\n"); } }); // Create checkboxes, and group them in a CheckboxGroup to give them // "radio button" behavior. CheckboxGroup checkbox_group = new CheckboxGroup(); Checkbox[] checkboxes = new Checkbox[3]; checkboxes[0] = new Checkbox("vanilla", checkbox_group, false); checkboxes[1] = new Checkbox("chocolate", checkbox_group, true); checkboxes[2] = new Checkbox("strawberry", checkbox_group, false); column1.add(new Label("Favorite flavor:")); for (int i = 0; i < checkboxes.length; i++) column1.add(checkboxes[i]); // Handle events on the checkboxes ItemListener checkbox_listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { textarea.append( "Your favorite flavor is: " + ((Checkbox) e.getItemSelectable()).getLabel() + "\n"); } }; for (int i = 0; i < checkboxes.length; i++) checkboxes[i].addItemListener(checkbox_listener); // Create a list of choices. List list = new List(4, true); list.addItem("Java"); list.addItem("C"); list.addItem("C++"); list.addItem("Smalltalk"); list.addItem("Lisp"); list.addItem("Modula-3"); list.addItem("Forth"); column1.add(new Label("Favorite languages:")); column1.add(list); // Handle events on this list list.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { textarea.append("Your favorite languages are: "); String[] languages = ((List) e.getItemSelectable()).getSelectedItems(); for (int i = 0; i < languages.length; i++) { if (i > 0) textarea.append(","); textarea.append(languages[i]); } textarea.append("\n"); } }); // Create a multi-line text area in column 2 textarea = new TextArea(6, 40); textarea.setEditable(false); column2.add(new Label("Messages")); column2.add(textarea); // Create a scrollpane that displays portions of a larger component ScrollPane scrollpane = new ScrollPane(); scrollpane.setSize(300, 150); column2.add(new Label("Scrolling Window")); column2.add(scrollpane); // Create a custom MultiLineLabel with a really big font and make it // a child of the ScrollPane container String message = "/*************************************************\n" + " * AllComponents.java *\n" + " * Written by David Flanagan *\n" + " * Copyright (c) 1997 by O'Reilly & Associates *\n" + " * *\n" + " *************************************************/\n"; MultiLineLabel biglabel = new MultiLineLabel(message); biglabel.setFont(new Font("Monospaced", Font.BOLD + Font.ITALIC, 24)); scrollpane.add(biglabel); }
public void setupDBFields(String dbname) throws Exception { viewPane.setLayout(null); Dimension dimView = sp.getSize(); int height = 0, width = 50; viewPane.removeAll(); db = new DBF(dbname); setTitle(dbname); gb = new GridBagLayout(); gbc = new GridBagConstraints(); viewPane.setLayout(gb); int i, j; fldObjects = new Vector(db.getFieldCount()); for (i = 1; i <= db.getFieldCount(); i++) { j = i - 1; f = db.getField(i); if (f.isMemoField() || f.isPictureField()) { b = new Button(db.getField(i).getName()); b.addActionListener(this); addComponent( viewPane, b, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); fldObjects.addElement(b); } else if (f.getType() == 'L') { c = new Checkbox(db.getField(i).getName(), true); addComponent( viewPane, c, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); fldObjects.addElement(c); } else { l = new Label(db.getField(i).getName(), Label.RIGHT); addComponent( viewPane, l, 0, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); int ln = f.getLength(); if (ln > 100) { ln = 100; } t = new TextField(db.getField(i).getName(), ln); if (width < ln * 10) { width = ln * 10; } addComponent( viewPane, t, 1, j, ln, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); fldObjects.addElement(t); t.setEditable(true); } height += 10; } crl.setText("Record " + db.getCurrentRecordNumber()); trl.setText(" of " + db.getRecordCount()); SBrecpos.setMaximum(db.getRecordCount()); addComponent(viewPane, crl, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent(viewPane, trl, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); i++; addComponent( viewPane, SBrecpos, 0, i, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, delCB, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); i++; addComponent( viewPane, Prev, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, Next, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); i++; addComponent(viewPane, Add, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, Update, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, Clear, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); Prev.setEnabled(false); prevRecord.setEnabled(false); if (db.getRecordCount() == 0) { Update.setEnabled(false); updateRecord.setEnabled(false); Next.setEnabled(false); nextRecord.setEnabled(false); } dimView.setSize(width + 150, height + 150); sp.setSize(dimView); goTo(1); }
/** Create the panel. */ public JListFriendPanel(String name, String path, ChatPanel chatpanel) { super(name, path); temp = chatpanel; setLayout(null); txtSearch = new JTextField(); txtSearch.setBounds(10, 11, 151, 29); add(txtSearch); txtSearch.setColumns(10); JButton btnSearch = new JButton("Tìm"); btnSearch.addMouseListener( new MouseAdapter() { @Override /** Tìm kiếm keyword trong danh sách bạn bè */ public void mouseClicked(MouseEvent arg0) { String keyword = txtSearch.getText(); if (keyword.isEmpty()) copy2view(); else { list_view.clear(); for (int i = 0; i < list.size(); i++) if (list.get(i).contains(keyword)) { list_view.add(list.get(i)); } } list_fri.setListData(list_view.toArray()); } }); btnSearch.setBounds(171, 11, 69, 29); add(btnSearch); list_fri = new JList(); list_fri.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list_fri.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent arg0) {} }); list_fri.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { int n = list_fri.getSelectedIndex(); txtSearch.setText(list_view.get(n)); } }); // Khởi tạo danh sách bạn copy2view(); // Cap nhat danh sach ban ScrollPane scrollPane = new ScrollPane(); list_fri.setListData(list.toArray()); list_fri.setSelectedIndex(0); scrollPane.setBounds(10, 76, 230, 305); scrollPane.add(list_fri); add(scrollPane); JLabel lblTrcTuyn = new JLabel("Danh sách bạn bè"); lblTrcTuyn.setForeground(new Color(144, 238, 144)); lblTrcTuyn.setBounds(10, 51, 123, 14); add(lblTrcTuyn); JButton btnSearchServer = new JButton("Tìm kiếm tất cả"); btnSearchServer.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { change2searchserver(); } }); btnSearchServer.setBounds(127, 387, 113, 29); add(btnSearchServer); JButton btnChat = new JButton("Trò chuyện"); btnChat.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { temp.CreateTab(list_view.get(list_fri.getSelectedIndex())); } }); btnChat.setBounds(10, 387, 113, 29); add(btnChat); }
public IndividualLifeBarTitledPane(final IndividualLifeBar individualLifeBar) { this.individualLifeBar = individualLifeBar; setText("Configuração LifeBar de Objeto"); VBox layout = new VBox(); GridPane gridPane = new GridPane(); ColumnConstraints col1 = new ColumnConstraints(); col1.setPercentWidth(40); ColumnConstraints col2 = new ColumnConstraints(); col2.setPercentWidth(30); ColumnConstraints col3 = new ColumnConstraints(); col3.setPercentWidth(30); gridPane.getColumnConstraints().addAll(col1, col2, col3); Label label = new Label("Objeto"); gridPane.add(label, 0, 0); boxLabelObjects = new ComboBox<String>(); boxLabelObjects.getItems().addAll(individualLifeBar.getWorld().getObjectIds()); if (individualLifeBar.getOwnerId() != null) { boxLabelObjects.getSelectionModel().select(individualLifeBar.getOwnerId()); } boxLabelObjects.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { for (String label : individualLifeBar.getWorld().getObjectIds()) { if (!boxLabelObjects.getItems().contains(label)) { boxLabelObjects.getItems().add(label); } } } }); boxLabelObjects.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { individualLifeBar.setOwner(boxLabelObjects.getValue()); } }); gridPane.add(boxLabelObjects, 1, 0); layout.getChildren().add(gridPane); Separator separator = new Separator(Orientation.HORIZONTAL); separator.setPadding(new Insets(5, 0, 5, 0)); layout.getChildren().add(separator); layout.setPadding(new Insets(5)); lifeBarPane = new LifebarPane(individualLifeBar); layout.getChildren().add(lifeBarPane); ScrollPane scroll = new ScrollPane(layout); scroll.setFitToWidth(true); setContent(scroll); }
@FXML private void reservationsButtonClicked(ActionEvent event) { configureButtons(); reservationsButton.setGraphic(reservationsSelectedIMV); // Clear the content of contentPane contentPane.getChildren().clear(); // Set title titleLabel.setText("Reservations"); // Make box for weekly availability and reservations VBox box = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // box for availability VBox abox = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // box for reservations VBox resbox = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // set up for weekly table availability Text aHeader = new Text("Tables still available"); aHeader.setFont(new Font("System", 24)); TableView aTable = new TableView(); TableColumn aDateCol = new TableColumn("Date"); aDateCol.setCellValueFactory(new PropertyValueFactory<>("date")); TableColumn tablesCol = new TableColumn("Tables Available"); tablesCol.setCellValueFactory(new PropertyValueFactory<>("tablesAvailable")); // add table and title to availability box abox.getChildren().addAll(aHeader, aTable); abox.setSpacing(5); // set width for all cols aDateCol.setMinWidth(100); tablesCol.setMinWidth(100); aTable.getColumns().addAll(aDateCol, tablesCol); // Populate data to the table view operation.callDates(); ObservableList<Availability> adata = FXCollections.observableArrayList(operation.getWeeklyAvailability()); aTable.setItems(adata); aTable.setMaxHeight(235); aTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // set up for reservations Text resHeader = new Text("All Reservations"); resHeader.setFont(new Font("System", 24)); TableView resTable = new TableView(); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn tidCol = new TableColumn("tID"); tidCol.setCellValueFactory(new PropertyValueFactory<>("tID")); TableColumn partySizeCol = new TableColumn("Party Size"); partySizeCol.setCellValueFactory(new PropertyValueFactory<>("partySize")); TableColumn seatsCol = new TableColumn("Seats"); seatsCol.setCellValueFactory(new PropertyValueFactory<>("seats")); TableColumn dateCol = new TableColumn("Reservation Date"); dateCol.setCellValueFactory(new PropertyValueFactory<>("reservationDate")); // set width for all cols firstNameCol.setMinWidth(100); lastNameCol.setMinWidth(100); tidCol.setMinWidth(100); partySizeCol.setMinWidth(100); seatsCol.setMinWidth(100); dateCol.setMinWidth(300); // add table and title to availability box ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(resTable); scrollPane.setFitToWidth(true); resbox.getChildren().addAll(resHeader, scrollPane); resbox.setSpacing(5); resTable .getColumns() .addAll(firstNameCol, lastNameCol, tidCol, partySizeCol, seatsCol, dateCol); // Populate data to the table view ObservableList<ReservationInfo> resdata = FXCollections.observableArrayList(operation.getAllReservations()); resTable.setItems(resdata); resTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // add table view to content pane box.getChildren().addAll(abox, resbox); contentPane.getChildren().add(box); }