|
31 | 31 |
|
32 | 32 | import javafx.beans.value.ChangeListener; |
33 | 33 | import javafx.beans.value.ObservableValue; |
| 34 | +import javafx.collections.ListChangeListener; |
34 | 35 | import javafx.collections.ObservableList; |
35 | 36 | import javafx.event.EventHandler; |
36 | 37 | import javafx.event.Event; |
@@ -115,7 +116,7 @@ public void setTitle(String newtitle, String otpstatus) { |
115 | 116 | logger.warning(" --- ---- Starting setting title "); |
116 | 117 | Tab tab = this.tabpane.getTabs().get(activedisplayindex); |
117 | 118 | if (otpstatus.equals("NONE")) { |
118 | | - tab.setText((newtitle.length() > 20 ? newtitle.substring(0, 20) + "..." : newtitle)); |
| 119 | + tab.setText(newtitle); |
119 | 120 | tab.setTooltip(new Tooltip(newtitle)); |
120 | 121 | return; |
121 | 122 | } |
@@ -148,6 +149,7 @@ public void handle(MouseEvent event) { |
148 | 149 | BorderPane.setAlignment(dot, Pos.CENTER); |
149 | 150 | tab.setText(""); |
150 | 151 | tab.setGraphic(borderpane); |
| 152 | + tab.setTooltip(new Tooltip(newtitle)); |
151 | 153 | } |
152 | 154 |
|
153 | 155 | /** |
@@ -202,6 +204,24 @@ private void setupDisplay(ClientDisplay clientdisplay) { |
202 | 204 | // initiates the tabpane if called for the first time |
203 | 205 | if (this.tabpane == null) { |
204 | 206 | this.tabpane = new TabPane(); |
| 207 | + this.tabpane.getTabs().addListener(new ListChangeListener<Tab>() { |
| 208 | + |
| 209 | + @Override |
| 210 | + public void onChanged(@SuppressWarnings("rawtypes") Change change) { |
| 211 | + TabPane localtabpane = tabpane; |
| 212 | + double tabpanewidth = localtabpane.getWidth()*0.9f; |
| 213 | + if (tabpanewidth<10) tabpanewidth=1000; |
| 214 | + int tabnumber = localtabpane.getTabs().size(); |
| 215 | + if (tabnumber==0) tabnumber=1; |
| 216 | + double maxtabwidth = tabpanewidth/tabnumber; |
| 217 | + if (maxtabwidth<90) maxtabwidth=90; |
| 218 | + localtabpane.setTabMaxWidth(maxtabwidth); |
| 219 | + |
| 220 | + |
| 221 | + } |
| 222 | + |
| 223 | + |
| 224 | + }); |
205 | 225 | this.tabpane.setBackground(new Background(new BackgroundFill(Color.WHITE, null, null))); |
206 | 226 | this.tabpane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); |
207 | 227 | this.tabpane.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { |
|
0 commit comments