Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation and basic operation #282

Closed
AlexAzarXYZ opened this issue Mar 24, 2021 · 6 comments
Closed

Animation and basic operation #282

AlexAzarXYZ opened this issue Mar 24, 2021 · 6 comments
Labels
custom window decorations Related to using FlatLaf custom window decorations
Milestone

Comments

@AlexAzarXYZ
Copy link

Hello I am new To Flat LAf and I didn't know where to leave an issue. I cannot figure how to use basic animation like when reducing windows? Also When dragging using the laf decoration to an end of a screen it doesn't not resize it ? Can someone help ?

@DevCharly
Copy link
Collaborator

I cannot figure how to use basic animation like when reducing windows?

Indeed, the Windows 10 minimize/maximize/restore window animations are missing when clicking one of the buttons in the title bar. On the other hand, when right-clicking on title bar and selecting those commands from context menu, the animations are there. The difference is that when clicking the buttons, FlatLaf uses Java API to minimize/maximize/restore window. The context menu comes from Windows 10.

Also When dragging using the laf decoration to an end of a screen it doesn't not resize it ?

Hmm, this works for me.

  • When I resize drag the top or bottom border to the edge of the screen, then top AND bottom snap to screen size.
  • When I drag the window title bar to the top side of the screen edge, it maximizes the window.
  • When I drag the window title bar to the left or right screen edge, the window is resized to half screen and on the other half I can choose another window.

Could you please describe in more detail what you do and what you expect?
Please also compare behavior with Windows Explorer window.

@AlexAzarXYZ
Copy link
Author

AlexAzarXYZ commented Mar 24, 2021

Hey First of all Thanks for this super quick response I am impressed how involved you all are and its amazing !! I have made a very small test application would you be able to guide me throught ? here is the code
Main Class:

public class Main {
    
    public static void main(String[] args) {
        //Invoke menu
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                //Install flat laf Look and Feel
                FlatArcDarkOrangeIJTheme.install();
                
                //Set the UI Look and Feel
                try {
                    System.setProperty("flatlaf.useWindowDecorations", "true");
                    System.setProperty( "flatlaf.uiScale", "1.25x" );
                    System.setProperty( "flatlaf.animatedLafChange", "true" );
                    UIManager.setLookAndFeel(new FlatArcDarkOrangeIJTheme());
                    UIManager.put( "Button.arc", 999 );
                    

                } catch (Exception ex) {
                    System.err.println("Failed to initialize LaF");
                    JOptionPane.showMessageDialog(new JFrame(), "Eggs are not supposed to be green. (Laf error)");
                }
                
                
                Menu menu = new Menu();
                menu.setLocationRelativeTo(null);
                menu.setVisible(true);
                
            }
        });
    }
}

and here is the Menu:

public class Menu extends javax.swing.JFrame {

    
    public Menu() {
        initComponents();
        loadFonts();
        
    }

    
    public final void loadFonts() {
        
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jButton1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Bond");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1186, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 566, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Home", jPanel3);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1186, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("TableView", jPanel2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1186, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 566, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("GraphsView", jPanel1);

        jButton1.setText("RUN");

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9))
        );

        pack();
    }// </editor-fold>                        

    
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration                   
}

Im using netbeans but you should easily be able to copy and recreate the classes?
Let me know If I can be any more help and Thanks again !!!

@DevCharly
Copy link
Collaborator

Code works perfectly.

System.setProperty("flatlaf.useWindowDecorations", "true");
is not necessary because in FlatLaf 1.1 it is enabled by default.

System.setProperty( "flatlaf.animatedLafChange", "true" );
is also not necessary because its default value is already true. And animated Laf switching is not part of the core library. You need the flatlaf-extras library and use the class FlatAnimatedLafChange as described in the javadoc.

Have you seen this: #282 (comment)

@AlexAzarXYZ
Copy link
Author

Oh I see, I was on 1.0 I just changed and yes you're correct it works all perfect!! Thanks a lot again I'm going to continue to learn it but its defo an amazing tool !!!

@AlexAzarXYZ
Copy link
Author

I have read #282 (comment) and it makes a lot of sense. I will apply it to my code! :D Thanks for the time taken

DevCharly added a commit that referenced this issue Mar 25, 2021
…maximizing or restoring a window using window title bar buttons (issue #282)
@DevCharly
Copy link
Collaborator

The missing animations when maximizing/minimizing a frame are now fixed in main branch.

@DevCharly DevCharly added this to the 1.1.1 milestone Mar 25, 2021
@DevCharly DevCharly added the custom window decorations Related to using FlatLaf custom window decorations label Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom window decorations Related to using FlatLaf custom window decorations
Projects
None yet
Development

No branches or pull requests

2 participants