1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package museumsimulator;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author carlino
*/
public class FrameImport {
public FrameImport() {
JFrame frame = new JFrame("Map import");
//Initialization of container
frame.setLayout(new GridBagLayout());
//Initialization of components
JLabel connection = new JLabel("Map connection");
JLabel distance = new JLabel("Map distance");
JTextField connection_pane = new JTextField();
JTextField distance_pane = new JTextField();
JButton connection_button = new JButton("Select");
connection_button.setPreferredSize(new Dimension (25,6));
JButton distance_button = new JButton("Select");
distance_button.setPreferredSize(connection_button.getPreferredSize());
JButton submit_button = new JButton("Submit");
submit_button.setPreferredSize(connection_button.getPreferredSize());
//Labels insertion
GridBagConstraints label = new GridBagConstraints();
label.gridx = 1;
label.gridy = 2;
label.gridwidth = 1;
label.insets = new Insets(10,10,10,10);
label.anchor = GridBagConstraints.BASELINE_LEADING;
frame.add(connection, label);
label.gridy = 4;
frame.add(distance, label);
//TextPane creation
GridBagConstraints textpane = new GridBagConstraints();
textpane.gridx = 2;
textpane.gridy = 2;
textpane.gridwidth = GridBagConstraints.RELATIVE;
textpane.insets = new Insets(10,10,10,10);
textpane.anchor = GridBagConstraints.BASELINE_LEADING;
frame.add(connection_pane, textpane);
textpane.gridy = 4;
frame.add(distance_pane, textpane);
//Button select creation
GridBagConstraints select = new GridBagConstraints();
select.gridx = 3;
select.gridy = 2;
select.gridwidth = GridBagConstraints.REMAINDER;
select.insets = new Insets(10,10,10,10);
select.anchor = GridBagConstraints.BASELINE_LEADING;
frame.add(connection_button, select);
select.gridy = 4;
frame.add(distance_button, select);
//Button submit creation
GridBagConstraints submit = new GridBagConstraints();
submit.gridy = 6;
submit.insets = new Insets(10,10,10,10);
submit.anchor = GridBagConstraints.BASELINE_LEADING;
frame.add(submit_button, submit);
//Creation of the frame
frame.setMinimumSize(new Dimension(600,500));
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main (String args[]) {
FrameImport frameImport = new FrameImport();
}
} |
Partager