Add graphical user interface
parent
1e5f800c26
commit
a62112bbfa
|
|
@ -18,12 +18,12 @@ public class config_editor {
|
||||||
verify_config_file();
|
verify_config_file();
|
||||||
config_file_type();
|
config_file_type();
|
||||||
parse_config_file();
|
parse_config_file();
|
||||||
if (args.length > 1 && args[1].equals("--Gui")) {
|
if (args.length > 1 && args[1].equals("--gui")) {
|
||||||
|
graphical_user_interface.run(config_data);
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
config_data_edited = user_interface.run(config_data);
|
config_data_edited = user_interface.run(config_data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void verify_config_file() {
|
static void verify_config_file() {
|
||||||
if (config_file_path == null || config_file_path.isEmpty()) {
|
if (config_file_path == null || config_file_path.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class graphical_user_interface {
|
||||||
|
|
||||||
|
public static void run(Map<String, Object> config_data) {
|
||||||
|
final int LABEL_HEIGHT = 30;
|
||||||
|
final int LABEL_WIDTH = 200;
|
||||||
|
final int SPACING_VERTICAL = 10;
|
||||||
|
final int SPACING_HORIZONTAL = 10;
|
||||||
|
int last_vertical_position = 10;
|
||||||
|
|
||||||
|
JFrame frame = new JFrame("Config Editor");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.setLayout(null);
|
||||||
|
frame.setSize(440, 600);
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
scrollPane.setLayout(null);
|
||||||
|
scrollPane.setBounds(0, 0, frame.getWidth(), frame.getHeight());
|
||||||
|
for (Map.Entry<String, Object> entry : config_data.entrySet()) {
|
||||||
|
for (Map.Entry<String, Object> subEntry : ((Map<String, Object>) entry.getValue()).entrySet()) {
|
||||||
|
JLabel label = new JLabel(subEntry.getKey());
|
||||||
|
label.setBounds(10, last_vertical_position, LABEL_WIDTH, LABEL_HEIGHT);
|
||||||
|
scrollPane.add(label);
|
||||||
|
JTextField textField = new JTextField(subEntry.getValue().toString());
|
||||||
|
textField.setBounds(10 + LABEL_WIDTH + SPACING_HORIZONTAL, last_vertical_position + SPACING_VERTICAL,
|
||||||
|
LABEL_WIDTH, LABEL_HEIGHT);
|
||||||
|
scrollPane.add(textField);
|
||||||
|
last_vertical_position += LABEL_HEIGHT + SPACING_VERTICAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frame.add(scrollPane);
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue