gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src/gdxstudio/panel/TablePanel.java
| a9b2a64 | 1 | package gdxstudio.panel; |
| a9b2a64 | 2 | import gdxstudio.GdxStudio; |
| a9b2a64 | 3 | import gdxstudio.Style; |
| a9b2a64 | 4 | |
| a62d533 | 5 | import java.awt.Component; |
| a62d533 | 6 | import java.awt.Insets; |
| a62d533 | 7 | import java.awt.event.ActionEvent; |
| a62d533 | 8 | import java.awt.event.ActionListener; |
| a62d533 | 9 | import java.util.HashMap; |
| a62d533 | 10 | |
| a62d533 | 11 | import javax.swing.BorderFactory; |
| a62d533 | 12 | import javax.swing.JButton; |
| a62d533 | 13 | import javax.swing.JComponent; |
| a62d533 | 14 | import javax.swing.JPanel; |
| a62d533 | 15 | import javax.swing.JSpinner; |
| a62d533 | 16 | import javax.swing.JTextField; |
| a62d533 | 17 | import javax.swing.SpringLayout; |
| a62d533 | 18 | |
| a62d533 | 19 | import web.laf.lite.layout.VerticalFlowLayout; |
| a62d533 | 20 | import web.laf.lite.utils.SpringUtils; |
| a62d533 | 21 | import web.laf.lite.utils.UIUtils; |
| a62d533 | 22 | |
| a62d533 | 23 | |
| a62d533 | 24 | public class TablePanel extends JPanel implements ActionListener {
|
| a62d533 | 25 | private static final long serialVersionUID = 1L; |
| a62d533 | 26 | //protected final JScrollPane scrollPane; |
| a62d533 | 27 | public final JButton headerButton; |
| a62d533 | 28 | private static HashMap<String, JComponent> values = new HashMap<String, JComponent>(); |
| a62d533 | 29 | |
| a62d533 | 30 | public TablePanel(String title){
|
| a62d533 | 31 | super(new VerticalFlowLayout()); |
| a62d533 | 32 | UIUtils.setUndecorated(this, false); |
| 7c84877 | 33 | headerButton = new Style.TitleButton(title, this); |
| a62d533 | 34 | if(!title.isEmpty()){
|
| a62d533 | 35 | add(headerButton); |
| a62d533 | 36 | } |
| a62d533 | 37 | //scrollPane = new JScrollPane(this); |
| a62d533 | 38 | //scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); |
| a62d533 | 39 | //scrollPane.setPreferredSize(new Dimension(200, 500)); |
| a62d533 | 40 | //UIUtils.setDrawBorder(scrollPane, false); |
| a62d533 | 41 | //add(scrollPane); |
| a62d533 | 42 | createProperty("Name", createTextField());
|
| a62d533 | 43 | createProperty(" X ", createSpinner() , " Y ", createSpinner());
|
| a62d533 | 44 | //createProperty("OX ", createSpinner() , "OY ", createSpinner());
|
| a62d533 | 45 | createProperty("Width", createSpinner(), "Height", createSpinner());
|
| a62d533 | 46 | //createProperty("Height", createSpinner());
|
| a9b2a64 | 47 | GdxStudio.log("COMPK"+getProperty("Y"));
|
| a62d533 | 48 | setProperty("X", 500);
|
| a62d533 | 49 | } |
| a62d533 | 50 | |
| a62d533 | 51 | @Override |
| a62d533 | 52 | public void actionPerformed(ActionEvent e) {
|
| a62d533 | 53 | // TODO Auto-generated method stub |
| a62d533 | 54 | |
| a62d533 | 55 | } |
| a62d533 | 56 | |
| a62d533 | 57 | public void createProperty(String name, JComponent comp){
|
| a62d533 | 58 | JPanel hoz = new JPanel(new SpringLayout()); |
| a62d533 | 59 | UIUtils.setUndecorated(hoz, false); |
| a62d533 | 60 | UIUtils.setMargin(hoz, new Insets(0, 0, 0, 0)); |
| a62d533 | 61 | UIUtils.setShadeWidth(hoz, 0); |
| a62d533 | 62 | UIUtils.setRound(hoz, 0); |
| a62d533 | 63 | UIUtils.setDrawSides(hoz, false, false, true, false); |
| a62d533 | 64 | HeaderLabel x = new HeaderLabel(name); |
| a62d533 | 65 | UIUtils.setMargin(x, new Insets(0, 0, 0, 0)); |
| a62d533 | 66 | comp.setBorder(BorderFactory.createEmptyBorder()); |
| a62d533 | 67 | hoz.add(x); |
| a62d533 | 68 | hoz.add(comp); |
| a62d533 | 69 | values.put(name, comp); |
| a62d533 | 70 | SpringUtils.makeGrid(hoz, 1, 2, 0, 0, 0, 0); |
| a62d533 | 71 | add(hoz); |
| a62d533 | 72 | } |
| a62d533 | 73 | |
| a62d533 | 74 | public void createProperty(String name, JComponent comp, String name2, JComponent comp2){
|
| a62d533 | 75 | JPanel hoz = new JPanel(new SpringLayout()); |
| a62d533 | 76 | UIUtils.setUndecorated(hoz, false); |
| a62d533 | 77 | UIUtils.setMargin(hoz, new Insets(0, 0, 0, 0)); |
| a62d533 | 78 | UIUtils.setShadeWidth(hoz, 0); |
| a62d533 | 79 | UIUtils.setRound(hoz, 0); |
| a62d533 | 80 | UIUtils.setDrawSides(hoz, false, false, true, false); |
| a62d533 | 81 | HeaderLabel x = new HeaderLabel(name); |
| a62d533 | 82 | UIUtils.setMargin(x, new Insets(0, 0, 0, 0)); |
| a62d533 | 83 | HeaderLabel y = new HeaderLabel(name2); |
| a62d533 | 84 | hoz.add(x); |
| a62d533 | 85 | hoz.add(comp); |
| a62d533 | 86 | hoz.add(y); |
| a62d533 | 87 | hoz.add(comp2); |
| a62d533 | 88 | values.put(name, comp); |
| a62d533 | 89 | values.put(name2, comp2); |
| a62d533 | 90 | SpringUtils.makeGrid(hoz, 1, 4, 0, 0, 0, 0); |
| a62d533 | 91 | add(hoz); |
| a62d533 | 92 | } |
| a62d533 | 93 | |
| a62d533 | 94 | public void createProperty(String name, JComponent comp, String name2, JComponent comp2, |
| a62d533 | 95 | String name3, JComponent comp3){
|
| a62d533 | 96 | JPanel hoz = new JPanel(new SpringLayout()); |
| a62d533 | 97 | UIUtils.setUndecorated(hoz, false); |
| a62d533 | 98 | UIUtils.setMargin(hoz, new Insets(0, 0, 0, 0)); |
| a62d533 | 99 | UIUtils.setShadeWidth(hoz, 0); |
| a62d533 | 100 | UIUtils.setRound(hoz, 0); |
| a62d533 | 101 | UIUtils.setDrawSides(hoz, false, false, true, false); |
| a62d533 | 102 | |
| a62d533 | 103 | HeaderLabel x = new HeaderLabel(name);UIUtils.setMargin(x, new Insets(0, 0, 0, 0)); |
| a62d533 | 104 | HeaderLabel y = new HeaderLabel(name2);UIUtils.setMargin(y, new Insets(0, 0, 0, 0)); |
| a62d533 | 105 | HeaderLabel z = new HeaderLabel(name3);UIUtils.setMargin(z, new Insets(0, 0, 0, 0)); |
| a62d533 | 106 | |
| a62d533 | 107 | hoz.add(x); |
| a62d533 | 108 | hoz.add(comp); |
| a62d533 | 109 | hoz.add(y); |
| a62d533 | 110 | hoz.add(comp2); |
| a62d533 | 111 | hoz.add(z); |
| a62d533 | 112 | hoz.add(comp3); |
| a62d533 | 113 | values.put(name, comp); |
| a62d533 | 114 | values.put(name2, comp2); |
| a62d533 | 115 | values.put(name3, comp3); |
| a62d533 | 116 | SpringUtils.makeCompactGrid(hoz, 1, 6, 0, 0, 0, 0); |
| a62d533 | 117 | add(hoz); |
| a62d533 | 118 | } |
| a62d533 | 119 | |
| a62d533 | 120 | public JSpinner createSpinner(){
|
| a62d533 | 121 | JSpinner spinner = new JSpinner(); |
| a62d533 | 122 | UIUtils.setDrawBorder(spinner, false); |
| a62d533 | 123 | UIUtils.setShadeWidth(spinner, 0); |
| a62d533 | 124 | UIUtils.setRound(spinner, 0); |
| a62d533 | 125 | UIUtils.setDrawFocus(spinner, false); |
| a62d533 | 126 | return spinner; |
| a62d533 | 127 | } |
| a62d533 | 128 | |
| a62d533 | 129 | public JTextField createTextField(){
|
| a62d533 | 130 | JTextField tf = new JTextField(); |
| a62d533 | 131 | UIUtils.setShadeWidth(tf, 0); |
| a62d533 | 132 | UIUtils.setRound(tf, 0); |
| a62d533 | 133 | UIUtils.setDrawFocus(tf, false); |
| a62d533 | 134 | return tf; |
| a62d533 | 135 | } |
| a62d533 | 136 | |
| a62d533 | 137 | public String getProperty(String name){
|
| a62d533 | 138 | Component c = values.get(name); |
| a62d533 | 139 | if(c instanceof JSpinner) |
| a62d533 | 140 | return ((JSpinner)c).getValue().toString(); |
| a62d533 | 141 | if(c instanceof JTextField){
|
| a62d533 | 142 | return ((JTextField)c).getText(); |
| a62d533 | 143 | } |
| a62d533 | 144 | return ""; |
| a62d533 | 145 | } |
| a62d533 | 146 | |
| a62d533 | 147 | public void setProperty(String name, String value){
|
| a62d533 | 148 | Component c = values.get(name); |
| a62d533 | 149 | if(c instanceof JTextField) |
| a62d533 | 150 | ((JTextField)c).setText(value); |
| a62d533 | 151 | } |
| a62d533 | 152 | |
| a62d533 | 153 | public void setProperty(String name, int value){
|
| a62d533 | 154 | Component c = values.get(name); |
| a62d533 | 155 | if(c instanceof JSpinner) |
| a62d533 | 156 | ((JSpinner)c).setValue(value); |
| a62d533 | 157 | } |
| a62d533 | 158 | } |