@@ -45,33 +45,35 @@ This file is part of the iText (R) project.
4545import com .itextpdf .kernel .actions .data .ITextCoreProductData ;
4646import com .itextpdf .rups .controller .IRupsController ;
4747import com .itextpdf .rups .controller .RupsController ;
48+ import com .itextpdf .rups .model .LoggerHelper ;
4849import com .itextpdf .rups .view .Language ;
4950import com .itextpdf .rups .view .RupsDropTarget ;
5051import com .itextpdf .rups .view .RupsMenuBar ;
5152import com .itextpdf .rups .view .RupsTabbedPane ;
5253import com .itextpdf .rups .view .icons .FrameIconUtil ;
5354
55+ import com .formdev .flatlaf .FlatLightLaf ;
5456import java .awt .BorderLayout ;
5557import java .awt .Dimension ;
5658import java .awt .Toolkit ;
5759import java .io .File ;
5860import javax .swing .JFrame ;
5961import javax .swing .SwingUtilities ;
6062import javax .swing .UIManager ;
63+ import javax .swing .UnsupportedLookAndFeelException ;
6164
6265public class Rups {
6366
6467 /**
6568 * Initializes the main components of the Rups application.
6669 *
67- * @param f a file that should be opened on launch
68- * @param onCloseOperation the close operation
70+ * @param f a file that should be opened on launch
6971 */
70- public static void startNewApplication (final File f , final int onCloseOperation ) {
72+ public static void startNewApplication (final File f ) {
7173 SwingUtilities .invokeLater (() -> {
7274 setLookandFeel ();
73- IRupsController rupsController = initApplication (new JFrame (), onCloseOperation );
74- if ( f != null ) {
75+ final IRupsController rupsController = initApplication (new JFrame ());
76+ if (f != null ) {
7577 loadDocumentFromFile (rupsController , f );
7678 }
7779 });
@@ -83,17 +85,17 @@ static void loadDocumentFromFile(IRupsController rupsController, File f) {
8385
8486 static void setLookandFeel () {
8587 try {
86- UIManager .setLookAndFeel (UIManager .getSystemLookAndFeelClassName ());
87- } catch (Exception e ) {
88- try {
89- UIManager .setLookAndFeel (UIManager .getCrossPlatformLookAndFeelClassName ());
90- } catch (Exception ex ) {
91- // WELP IDK
88+ if ( !FlatLightLaf .setup ()) {
89+ UIManager .setLookAndFeel (RupsConfiguration .INSTANCE .getLookAndFeel ());
9290 }
91+ } catch (
92+ ClassNotFoundException | InstantiationException |
93+ IllegalAccessException | UnsupportedLookAndFeelException e ) {
94+ LoggerHelper .error (Language .ERROR_LOOK_AND_FEEL .getString (), e , Rups .class );
9395 }
9496 }
9597
96- static IRupsController initApplication (JFrame frame , final int onCloseOperation ) {
98+ static IRupsController initApplication (JFrame frame ) {
9799 Dimension screen = Toolkit .getDefaultToolkit ().getScreenSize ();
98100 frame .setSize ((int ) (screen .getWidth () * .90 ), (int ) (screen .getHeight () * .90 ));
99101 frame .setLocation ((int ) (screen .getWidth () * .05 ), (int ) (screen .getHeight () * .05 ));
@@ -103,7 +105,7 @@ static IRupsController initApplication(JFrame frame, final int onCloseOperation)
103105 frame .setTitle (
104106 String .format (Language .TITLE .getString (), ITextCoreProductData .getInstance ().getVersion ()));
105107 frame .setIconImages (FrameIconUtil .loadFrameIcons ());
106- frame .setDefaultCloseOperation (onCloseOperation );
108+ frame .setDefaultCloseOperation (RupsConfiguration . INSTANCE . getCloseOperation () );
107109
108110 final RupsTabbedPane rupsTabbedPane = new RupsTabbedPane ();
109111 final RupsController rupsController = new RupsController (screen , rupsTabbedPane );
0 commit comments