2014-10-13 12 views

उत्तर

13

इस ब्लॉग पोस्ट यह सब बताते हैं: के बाद से 8.0.6 29 मई को जारी किया गया था

http://fxexperience.com/2014/09/announcing-controlsfx-8-20-7/

यह रिलीज चल गया है - चार महीने तो मूल रूप से। यह हमारे लिए सामान्य नहीं है (हम आमतौर पर बहुत तेज रिलीज़ होते हैं), लेकिन यूजीन और मैं दोनों एक प्रमुख उपक्रम पर विचलित थे - नियंत्रण एफएक्स संवाद एपीआई को बढ़ाकर और जावाएफएक्स की अगली रिलीज में कार्यान्वयन (यह जावाएफएक्स 8u40 में दिखाई देगा , हालांकि एपीआई कंट्रोलएफएक्स 8.0.6 में जो कुछ भी आप देखते हैं उससे काफी अलग है। अंत परिणाम यह है कि हमने एपीआई डिज़ाइन कार्य के समूह के माध्यम से पुनरावृत्ति की है (आरटी -12643 देखें) और इनमें से कोई भी नियंत्रण नियंत्रण FX को लाभ नहीं पहुंचा, लेकिन यह हमारे पूरे समय तक उठा।

एक बार जावाएफएक्स 8u40 संवाद एपीआई पूर्ण (जो केवल मध्य अगस्त था), हमने कंट्रोलएफएक्स संवादों के साथ आगे बढ़ने के लिए एक योजना विकसित की। संक्षेप में हमें यह नहीं लगता था कि नियंत्रण एफएक्स में एक संवाद एपीआई बनाए रखना बुद्धिमान था जो कि जावाएफएक्स 8u40 में जहाज के मुकाबले इतना अलग था। इसलिए, हमने जिस योजना को विकसित किया था वह पुरानी कंट्रोलएफएक्स एपीआई को हटाना था, जावाएफएक्स संवाद एपीआई को ओपनजेएफएक्स-डायलॉग नामक एक नई परियोजना में फोर्क करना था, और नई सुविधाओं का उपयोग करते हुए कंट्रोलएफएक्स में अतिरिक्त सुविधाओं को फिर से बनाने के लिए (लेकिन जावाएफएक्स में कमी है) (इसमें प्रगति, फ़ॉन्ट चयनकर्ता, कमांड लिंक, लॉगिन इत्यादि जैसे संवाद शामिल हैं)।

+3

लिंक के लिए धन्यवाद। वास्तव में controlfx का एक बुरा निर्णय। नया मुक्ति जीपीएल है और अधिकांश अनुप्रयोगों में इसका उपयोग नहीं किया जा सकता है। इन दो एपीआई के लिए एक अलग फोकस है और पुरानी एपीआई वास्तव में बहिष्कृत नहीं की जानी चाहिए ... –

+1

https://bitbucket.org/controlsfx/openjfx-dialogs के अनुसार लाइसेंस जीपीएल प्लस क्लासपाथ-अपवाद है जिसका अर्थ है कि यह हो सकता है वाणिज्यिक अनुप्रयोगों में प्रयोग किया जाता है। (अस्वीकरण: IANAL) – rli

+0

@ArtjomB। हाँ, लेकिन संपादन से 3 महीने पहले आपकी टिप्पणी एक व्यवहार्य उत्तर बनाने के लिए थी। आह ठीक है, अब हल किया गया है, जवाब ठीक है जो अंतिम लक्ष्य है – James

11

अब जावा 8 अपडेट 60 के साथ, controlfx के पुराने गैर-बहिष्कृत संस्करण का उपयोग भी काम नहीं करता है। तो, समाधान जावा 8 अपडेट 40 में शामिल javafx से देशी संवाद API का उपयोग कर रहा है (तृतीय पक्ष libs की आवश्यकता नहीं है)। वे नियंत्रण एफएक्स के रूप में सीधे आगे और सुविधाओं से भरा नहीं हैं। लेकिन तेजी से कोडिंग के लिए, आप एक आवरण वर्ग, यह एक मैंने बनाया की तरह बना सकते हैं:

package br.atualy.devolucaodevenda.util; 

import javafx.scene.control.*; 
import javafx.scene.control.Label; 
import javafx.scene.control.TextArea; 
import javafx.scene.input.KeyCode; 
import javafx.scene.input.KeyEvent; 
import javafx.scene.layout.GridPane; 
import javafx.scene.layout.Priority; 
import javafx.stage.StageStyle; 

import java.awt.*; 
import java.io.PrintWriter; 
import java.io.StringWriter; 
import java.util.ArrayList; 
import java.util.List; 
import java.util.Optional; 

public class FxDialogs { 

    public static void showInformation(String title, String message) { 
     Alert alert = new Alert(Alert.AlertType.INFORMATION); 
     alert.initStyle(StageStyle.UTILITY); 
     alert.setTitle("Information"); 
     alert.setHeaderText(title); 
     alert.setContentText(message); 

     alert.showAndWait(); 
    } 

    public static void showWarning(String title, String message) { 
     Alert alert = new Alert(Alert.AlertType.WARNING); 
     alert.initStyle(StageStyle.UTILITY); 
     alert.setTitle("Warning"); 
     alert.setHeaderText(title); 
     alert.setContentText(message); 

     alert.showAndWait(); 
    } 

    public static void showError(String title, String message) { 
     Alert alert = new Alert(Alert.AlertType.ERROR); 
     alert.initStyle(StageStyle.UTILITY); 
     alert.setTitle("Error"); 
     alert.setHeaderText(title); 
     alert.setContentText(message); 

     alert.showAndWait(); 
    } 

    public static void showException(String title, String message, Exception exception) { 
     Alert alert = new Alert(Alert.AlertType.ERROR); 
     alert.initStyle(StageStyle.UTILITY); 
     alert.setTitle("Exception"); 
     alert.setHeaderText(title); 
     alert.setContentText(message); 

     StringWriter sw = new StringWriter(); 
     PrintWriter pw = new PrintWriter(sw); 
     exception.printStackTrace(pw); 
     String exceptionText = sw.toString(); 

     Label label = new Label("Details:"); 

     TextArea textArea = new TextArea(exceptionText); 
     textArea.setEditable(false); 
     textArea.setWrapText(true); 

     textArea.setMaxWidth(Double.MAX_VALUE); 
     textArea.setMaxHeight(Double.MAX_VALUE); 
     GridPane.setVgrow(textArea, Priority.ALWAYS); 
     GridPane.setHgrow(textArea, Priority.ALWAYS); 

     GridPane expContent = new GridPane(); 
     expContent.setMaxWidth(Double.MAX_VALUE); 
     expContent.add(label, 0, 0); 
     expContent.add(textArea, 0, 1); 

     alert.getDialogPane().setExpandableContent(expContent); 

     alert.showAndWait(); 
    } 

    public static final String YES = "Yes"; 
    public static final String NO = "No"; 
    public static final String OK = "OK"; 
    public static final String CANCEL = "Cancel"; 

    public static String showConfirm(String title, String message, String... options) { 
     Alert alert = new Alert(Alert.AlertType.CONFIRMATION); 
     alert.initStyle(StageStyle.UTILITY); 
     alert.setTitle("Choose an option"); 
     alert.setHeaderText(title); 
     alert.setContentText(message); 

     //To make enter key press the actual focused button, not the first one. Just like pressing "space". 
     alert.getDialogPane().addEventFilter(KeyEvent.KEY_PRESSED, event -> { 
      if (event.getCode().equals(KeyCode.ENTER)) { 
       event.consume(); 
       try { 
        Robot r = new Robot(); 
        r.keyPress(java.awt.event.KeyEvent.VK_SPACE); 
        r.keyRelease(java.awt.event.KeyEvent.VK_SPACE); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 

     if (options == null || options.length == 0) { 
      options = new String[]{OK, CANCEL}; 
     } 

     List<ButtonType> buttons = new ArrayList<>(); 
     for (String option : options) { 
      buttons.add(new ButtonType(option)); 
     } 

     alert.getButtonTypes().setAll(buttons); 

     Optional<ButtonType> result = alert.showAndWait(); 
     if (!result.isPresent()) { 
      return CANCEL; 
     } else { 
      return result.get().getText(); 
     } 
    } 

    public static String showTextInput(String title, String message, String defaultValue) { 
     TextInputDialog dialog = new TextInputDialog(defaultValue); 
     dialog.initStyle(StageStyle.UTILITY); 
     dialog.setTitle("Input"); 
     dialog.setHeaderText(title); 
     dialog.setContentText(message); 

     Optional<String> result = dialog.showAndWait(); 
     if (result.isPresent()) { 
      return result.get(); 
     } else { 
      return null; 
     } 

    } 

} 

संवाद का उपयोग करें:

FxDialogs.showInformation("Hi", "Good Morning y'all!"); 
if (FxDialogs.showConfirm("Choose one baby!", "Can i ask you a question?", FxDialogs.YES, FxDialogs.NO).equals(FxDialogs.YES)) { 
    FxDialogs.showWarning(null, "Pay attention to my next question!"); 
    String answer = FxDialogs.showTextInput("Are you a pink elephant disguised as a flying pig?", "Tell me!", "No"); 
    FxDialogs.showError(null, "You should not have said " + answer + "!"); 
    FxDialogs.showException("Now i'm angry", "I'm going home...", new RuntimeException("Exception caused by angry dinossaurs")); 
} 
+0

क्या आपने इसे देखा और कोशिश की? "जावाएफएक्स 8u60 और अधिक के उपयोगकर्ताओं के लिए, नियंत्रण नियंत्रण FX 8.40.10-SNAPSHOT बनाता है।" – mipa

+0

नए संस्करण (कम से कम कुछ समय पहले) डायलॉग क्लास को बहिष्कृत किया गया है, क्या उन्होंने इसे इस संस्करण पर ठीक किया है? मुझे मैवेन पर वह संस्करण नहीं मिल रहा है, आखिरी बार मेवेन सेंट्रल पर 8.40.9 है। हालांकि मुझे जार मिल सकता है, क्या मुझे इसे अपने स्थानीय भंडार पर मैन्युअल रूप से स्थापित करने की आवश्यकता है? –

+0

फ़ाइल के नाम से पता चलता है कि यह एक स्नैपशॉट रिलीज है और इसलिए यह संभव नहीं है कि आप इसे मैवेन सेंट्रल पर पाएंगे। तो आपको इसे किसी भी तरह मैन्युअल रूप से इंस्टॉल करना होगा। मुझे नहीं पता कि परिवर्तन क्या हैं लेकिन कम से कम यह 8u60 के लिए जरूरी प्रतीत होता है अन्यथा वे अपनी वेबसाइट पर इसका उल्लेख नहीं करेंगे। – mipa

संबंधित मुद्दे