Button: basic border and background

This commit is contained in:
Karl Tauber
2019-08-20 11:13:03 +02:00
parent 85cfd9750c
commit 8ba5c9a39c
10 changed files with 390 additions and 8 deletions

View File

@@ -50,32 +50,73 @@ public class FlatComponentsTest
JLabel labelLabel = new JLabel();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
JLabel buttonLabel = new JLabel();
JButton button1 = new JButton();
JButton button2 = new JButton();
JButton button3 = new JButton();
JButton button4 = new JButton();
//======== 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};
((GridBagLayout)getLayout()).columnWidths = new int[] {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()).rowWeights = new double[] {0.0, 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));
new Insets(0, 0, 5, 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));
new Insets(0, 0, 5, 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, 5, 5), 0, 0));
//---- buttonLabel ----
buttonLabel.setText("JButton:");
add(buttonLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- button1 ----
button1.setText("enabled");
button1.setDisplayedMnemonicIndex(0);
add(button1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- button2 ----
button2.setText("disabled");
button2.setDisplayedMnemonicIndex(0);
button2.setEnabled(false);
add(button2, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- button3 ----
button3.setText("selected");
button3.setSelected(true);
add(button3, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- button4 ----
button4.setText("selected disabled");
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, 0), 0, 0));
// JFormDesigner - End of component initialization //GEN-END:initComponents

View File

@@ -7,8 +7,8 @@ new FormModel {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.GridBagLayout ) {
"$columnSpecs": "0, 0, 0"
"$rowSpecs": "0"
"$columnSpecs": "0, 0, 0, 0, 0"
"$rowSpecs": "0, 0"
"$hGap": 5
"$vGap": 5
"$alignLeft": true
@@ -34,6 +34,46 @@ new FormModel {
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 2
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "buttonLabel"
"text": "JButton:"
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridy": 1
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button1"
"text": "enabled"
"displayedMnemonicIndex": 0
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 1
"gridy": 1
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button2"
"text": "disabled"
"displayedMnemonicIndex": 0
"enabled": false
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 2
"gridy": 1
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button3"
"text": "selected"
"selected": true
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 3
"gridy": 1
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button4"
"text": "selected disabled"
"selected": true
"enabled": false
}, new FormLayoutConstraints( class com.jformdesigner.runtime.GridBagConstraintsEx ) {
"gridx": 4
"gridy": 1
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 580, 300 )

View File

@@ -20,6 +20,16 @@
*.foreground=ff0000
#---- Button ----
Button.background=ffffff
Button.startBorderColor=ff0000
Button.endBorderColor=0000ff
Button.disabledBorderColor=000088
#---- Label ----
Label.foreground=008800
Label.disabledForeground=000088