Button: default button

This commit is contained in:
Karl Tauber
2019-08-20 12:21:22 +02:00
parent 2ef440a016
commit f2f4a451ac
7 changed files with 74 additions and 18 deletions

View File

@@ -55,12 +55,13 @@ public class FlatComponentsTest
JButton button2 = new JButton();
JButton button3 = new JButton();
JButton button4 = new JButton();
FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton();
//======== this ========
setLayout(new GridBagLayout());
((GridBagLayout)getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0, 0};
((GridBagLayout)getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0, 0, 0};
((GridBagLayout)getLayout()).rowHeights = new int[] {0, 0, 0};
((GridBagLayout)getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
((GridBagLayout)getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
((GridBagLayout)getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0E-4};
//---- labelLabel ----
@@ -117,6 +118,13 @@ public class FlatComponentsTest
button4.setSelected(true);
button4.setEnabled(false);
add(button4, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- button5 ----
button5.setText("default");
button5.setDisplayedMnemonicIndex(0);
add(button5, new GridBagConstraints(5, 1, 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
@@ -124,4 +132,15 @@ public class FlatComponentsTest
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class TestDefaultButton --------------------------------------------
private static class TestDefaultButton
extends JButton
{
@Override
public boolean isDefaultButton() {
return true;
}
}
}

View File

@@ -7,7 +7,7 @@ new FormModel {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.GridBagLayout ) {
"$columnSpecs": "0, 0, 0, 0, 0"
"$columnSpecs": "0, 0, 0, 0, 0, 0"
"$rowSpecs": "0, 0"
"$hGap": 5
"$vGap": 5
@@ -74,6 +74,14 @@ new FormModel {
"gridx": 4
"gridy": 1
} )
add( new FormComponent( "com.formdev.flatlaf.FlatComponentsTest$TestDefaultButton" ) {
name: "button5"
"text": "default"
"displayedMnemonicIndex": 0
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 5
"gridy": 1
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 580, 300 )

View File

@@ -29,6 +29,11 @@ Button.startBorderColor=ff0000
Button.endBorderColor=0000ff
Button.disabledBorderColor=000088
Button.default.background=dddddd
Button.default.foreground=880000
Button.default.startBorderColor=ff0000
Button.default.endBorderColor=ff0000
#---- Label ----