OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.ui;
15
 
180 ilm 16
import java.awt.Component;
17 ilm 17
import java.awt.Dimension;
18
import java.awt.GridBagConstraints;
19
import java.awt.Insets;
20
 
151 ilm 21
import javax.swing.UIManager;
17 ilm 22
 
23
public class DefaultGridBagConstraints extends GridBagConstraints {
24
 
25
    /**
26
     * Contraintes par défaut pour les UI
27
     */
28
    private static final long serialVersionUID = 3654011883969624207L;
29
 
30
    public DefaultGridBagConstraints() {
31
        this.gridx = 0;
32
        this.gridy = 0;
33
        this.insets = getDefaultInsets();
34
        this.fill = GridBagConstraints.HORIZONTAL;
35
        this.anchor = GridBagConstraints.WEST;
36
    }
37
 
38
    public static Insets getDefaultInsets() {
151 ilm 39
        if (UIManager.get("dpi.scale") != null) {
40
            float f = (Float) UIManager.get("dpi.scale");
41
            return new Insets((int) (2 * f), (int) (3 * f), (int) (2 * f), (int) (2 * f));
42
        }
17 ilm 43
        return new Insets(2, 3, 2, 2);
44
    }
45
 
180 ilm 46
    public static void lockMinimumSize(Component c) {
17 ilm 47
        c.setMinimumSize(new Dimension(c.getPreferredSize()));
48
    }
49
 
180 ilm 50
    public static void lockMaximumSize(Component c) {
17 ilm 51
        c.setMaximumSize(new Dimension(c.getPreferredSize()));
52
    }
53
}