basic implementation of FlatLaf and FlatLabelUI

This commit is contained in:
Karl Tauber
2019-08-19 17:13:47 +02:00
parent 840c3698ad
commit 91a3d64a8e
12 changed files with 606 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf;
import java.awt.*;
import javax.swing.*;
/**
* @author Karl Tauber
*/
public class FlatComponentsTest
extends JPanel
{
public static void main( String[] args ) {
try {
if( args.length > 0 )
UIManager.setLookAndFeel( args[0] );
else
UIManager.setLookAndFeel( new FlatTestLaf() );
} catch( Exception ex ) {
ex.printStackTrace();
}
JOptionPane.showMessageDialog( null,
new FlatComponentsTest(),
"FlatComponentsTest",
JOptionPane.PLAIN_MESSAGE );
}
public FlatComponentsTest() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel labelLabel = new JLabel();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
//======== this ========
setLayout(new GridBagLayout());
((GridBagLayout)getLayout()).columnWidths = new int[] {0, 0, 0, 0};
((GridBagLayout)getLayout()).rowHeights = new int[] {0, 0};
((GridBagLayout)getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 1.0E-4};
((GridBagLayout)getLayout()).rowWeights = new double[] {0.0, 1.0E-4};
//---- labelLabel ----
labelLabel.setText("JLabel:");
add(labelLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- label1 ----
label1.setText("enabled");
label1.setDisplayedMnemonic('E');
add(label1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- label2 ----
label2.setText("disabled");
label2.setDisplayedMnemonic('D');
label2.setEnabled(false);
add(label2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,42 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.GridBagLayout ) {
"$columnSpecs": "0, 0, 0"
"$rowSpecs": "0"
"$hGap": 5
"$vGap": 5
"$alignLeft": true
"$alignTop": true
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "labelLabel"
"text": "JLabel:"
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "enabled"
"displayedMnemonic": 69
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 1
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "disabled"
"displayedMnemonic": 68
"enabled": false
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 2
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 580, 300 )
} )
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2019 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf;
/**
* A Flat LaF that has a test color scheme.
*
* Used to develop Flat LaF.
*
* @author Karl Tauber
*/
public class FlatTestLaf
extends FlatLaf
{
@Override
public String getName() {
return "Flat Test";
}
@Override
public String getDescription() {
return "Flat Test Look and Feel";
}
}

View File

@@ -0,0 +1,20 @@
#
# Copyright 2019 FormDev Software GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#---- globals ----
*.background=ccffcc
*.foreground=ff0000