mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
Demo: DataComponentsPanel added
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* 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.demo;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
/**
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
class DataComponentsPanel
|
||||
extends JPanel
|
||||
{
|
||||
DataComponentsPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
JLabel listLabel = new JLabel();
|
||||
JScrollPane scrollPane1 = new JScrollPane();
|
||||
JList<String> list1 = new JList<>();
|
||||
JScrollPane scrollPane2 = new JScrollPane();
|
||||
JList<String> list2 = new JList<>();
|
||||
JLabel treeLabel = new JLabel();
|
||||
JScrollPane scrollPane3 = new JScrollPane();
|
||||
JTree tree1 = new JTree();
|
||||
JScrollPane scrollPane4 = new JScrollPane();
|
||||
JTree tree2 = new JTree();
|
||||
JLabel tableLabel = new JLabel();
|
||||
JScrollPane scrollPane5 = new JScrollPane();
|
||||
JTable table1 = new JTable();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
"ltr,hidemode 3",
|
||||
// columns
|
||||
"[]" +
|
||||
"[200]" +
|
||||
"[200]",
|
||||
// rows
|
||||
"[]" +
|
||||
"[::200]" +
|
||||
"[::150]"));
|
||||
|
||||
//---- listLabel ----
|
||||
listLabel.setText("JList:");
|
||||
add(listLabel, "cell 0 0");
|
||||
|
||||
//======== scrollPane1 ========
|
||||
{
|
||||
scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
//---- list1 ----
|
||||
list1.setModel(new AbstractListModel<String>() {
|
||||
String[] values = {
|
||||
"abc",
|
||||
"de",
|
||||
"f"
|
||||
};
|
||||
@Override
|
||||
public int getSize() { return values.length; }
|
||||
@Override
|
||||
public String getElementAt(int i) { return values[i]; }
|
||||
});
|
||||
scrollPane1.setViewportView(list1);
|
||||
}
|
||||
add(scrollPane1, "cell 1 0,growx");
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
//---- list2 ----
|
||||
list2.setModel(new AbstractListModel<String>() {
|
||||
String[] values = {
|
||||
"abc",
|
||||
"de",
|
||||
"f"
|
||||
};
|
||||
@Override
|
||||
public int getSize() { return values.length; }
|
||||
@Override
|
||||
public String getElementAt(int i) { return values[i]; }
|
||||
});
|
||||
list2.setEnabled(false);
|
||||
scrollPane2.setViewportView(list2);
|
||||
}
|
||||
add(scrollPane2, "cell 2 0,growx");
|
||||
|
||||
//---- treeLabel ----
|
||||
treeLabel.setText("JTree:");
|
||||
add(treeLabel, "cell 0 1");
|
||||
|
||||
//======== scrollPane3 ========
|
||||
{
|
||||
|
||||
//---- tree1 ----
|
||||
tree1.setShowsRootHandles(true);
|
||||
scrollPane3.setViewportView(tree1);
|
||||
}
|
||||
add(scrollPane3, "cell 1 1,growx");
|
||||
|
||||
//======== scrollPane4 ========
|
||||
{
|
||||
|
||||
//---- tree2 ----
|
||||
tree2.setEnabled(false);
|
||||
scrollPane4.setViewportView(tree2);
|
||||
}
|
||||
add(scrollPane4, "cell 2 1,growx");
|
||||
|
||||
//---- tableLabel ----
|
||||
tableLabel.setText("JTable:");
|
||||
add(tableLabel, "cell 0 2");
|
||||
|
||||
//======== scrollPane5 ========
|
||||
{
|
||||
|
||||
//---- table1 ----
|
||||
table1.setModel(new DefaultTableModel(
|
||||
new Object[][] {
|
||||
{"Item 1a", "Item 2a", "January", "July", 123, null},
|
||||
{"Item 1b", "Item 2b", "February", "August", 456, true},
|
||||
},
|
||||
new String[] {
|
||||
"Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean"
|
||||
}
|
||||
) {
|
||||
Class<?>[] columnTypes = new Class<?>[] {
|
||||
Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class
|
||||
};
|
||||
boolean[] columnEditable = new boolean[] {
|
||||
false, true, true, true, true, true
|
||||
};
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
return columnTypes[columnIndex];
|
||||
}
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnEditable[columnIndex];
|
||||
}
|
||||
});
|
||||
{
|
||||
TableColumnModel cm = table1.getColumnModel();
|
||||
cm.getColumn(2).setCellEditor(new DefaultCellEditor(
|
||||
new JComboBox(new DefaultComboBoxModel(new String[] {
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
}))));
|
||||
cm.getColumn(3).setCellEditor(new DefaultCellEditor(
|
||||
new JComboBox(new DefaultComboBoxModel(new String[] {
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
}))));
|
||||
}
|
||||
table1.setAutoCreateRowSorter(true);
|
||||
scrollPane5.setViewportView(table1);
|
||||
}
|
||||
add(scrollPane5, "cell 1 2 2 1,growx,width 300");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
|
||||
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
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 net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "ltr,hidemode 3"
|
||||
"$columnConstraints": "[][200][200]"
|
||||
"$rowConstraints": "[][::200][::150]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "listLabel"
|
||||
"text": "JList:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane1"
|
||||
"verticalScrollBarPolicy": 21
|
||||
"horizontalScrollBarPolicy": 31
|
||||
add( new FormComponent( "javax.swing.JList" ) {
|
||||
name: "list1"
|
||||
"model": &DefaultListModel0 new javax.swing.DefaultListModel {
|
||||
addElement( "abc" )
|
||||
addElement( "de" )
|
||||
addElement( "f" )
|
||||
}
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.typeParameters": "String"
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0,growx"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane2"
|
||||
"verticalScrollBarPolicy": 21
|
||||
"horizontalScrollBarPolicy": 31
|
||||
add( new FormComponent( "javax.swing.JList" ) {
|
||||
name: "list2"
|
||||
"model": #DefaultListModel0
|
||||
"enabled": false
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.typeParameters": "String"
|
||||
}
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "treeLabel"
|
||||
"text": "JTree:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane3"
|
||||
add( new FormComponent( "javax.swing.JTree" ) {
|
||||
name: "tree1"
|
||||
"showsRootHandles": true
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1,growx"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane4"
|
||||
add( new FormComponent( "javax.swing.JTree" ) {
|
||||
name: "tree2"
|
||||
"enabled": false
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 1,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "tableLabel"
|
||||
"text": "JTable:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane5"
|
||||
add( new FormComponent( "javax.swing.JTable" ) {
|
||||
name: "table1"
|
||||
"model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector {
|
||||
add( new java.util.Vector {
|
||||
add( "Item 1a" )
|
||||
add( "Item 2a" )
|
||||
add( "January" )
|
||||
add( "July" )
|
||||
add( 123 )
|
||||
add( null )
|
||||
} )
|
||||
add( new java.util.Vector {
|
||||
add( "Item 1b" )
|
||||
add( "Item 2b" )
|
||||
add( "February" )
|
||||
add( "August" )
|
||||
add( 456 )
|
||||
add( true )
|
||||
} )
|
||||
}, new java.util.Vector {
|
||||
add( "Not editable" )
|
||||
add( "Text" )
|
||||
add( "Combo" )
|
||||
add( "Combo Editable" )
|
||||
add( "Integer" )
|
||||
add( "Boolean" )
|
||||
}, new java.util.Vector {
|
||||
add( null )
|
||||
add( null )
|
||||
add( class java.lang.String )
|
||||
add( class java.lang.String )
|
||||
add( class java.lang.Integer )
|
||||
add( class java.lang.Boolean )
|
||||
}, new java.util.Vector {
|
||||
add( false )
|
||||
add( null )
|
||||
add( null )
|
||||
add( null )
|
||||
add( null )
|
||||
add( null )
|
||||
}, new java.util.Vector {
|
||||
add( null )
|
||||
add( null )
|
||||
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
|
||||
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
|
||||
add( null )
|
||||
add( null )
|
||||
} )
|
||||
"autoCreateRowSorter": true
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2 2 1,growx,width 300"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 715 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ class DemoFrame
|
||||
tabbedPane = new JTabbedPane();
|
||||
BasicComponentsPanel basicComponentsPanel = new BasicComponentsPanel();
|
||||
MoreComponentsPanel moreComponentsPanel = new MoreComponentsPanel();
|
||||
DataComponentsPanel dataComponentsPanel = new DataComponentsPanel();
|
||||
controlBar = new ControlBar();
|
||||
|
||||
//======== this ========
|
||||
@@ -59,6 +60,7 @@ class DemoFrame
|
||||
{
|
||||
tabbedPane.addTab("Basic Components", basicComponentsPanel);
|
||||
tabbedPane.addTab("More Components", moreComponentsPanel);
|
||||
tabbedPane.addTab("Data Components", dataComponentsPanel);
|
||||
}
|
||||
contentPanel.add(tabbedPane, "cell 0 0");
|
||||
contentPanel.add(controlBar, "cell 0 1");
|
||||
|
||||
@@ -33,6 +33,11 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"title": "More Components"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.demo.DataComponentsPanel" ) {
|
||||
name: "dataComponentsPanel"
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"title": "Data Components"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
|
||||
Reference in New Issue
Block a user