use of java.awt.Dimension in project pcgen by PCGen.
the class OptionsPathDialog method initComponents.
private void initComponents() {
setResizable(false);
setTitle("Directory for options.ini location");
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints gridBagConstraints = new GridBagConstraints();
JLabel label = new JLabel("Select a directory to store PCGen options in:");
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.insets = new Insets(4, 4, 0, 4);
getContentPane().add(label, gridBagConstraints);
gridBagConstraints.insets = new Insets(2, 0, 2, 0);
getContentPane().add(new JSeparator(), gridBagConstraints);
label = new JLabel("If you have an existing options.ini file," + "then select the directory containing that file");
gridBagConstraints.insets = new Insets(4, 4, 4, 4);
getContentPane().add(label, gridBagConstraints);
ActionListener handler = new ActionHandler();
ButtonGroup group = new ButtonGroup();
gridBagConstraints.insets = new Insets(0, 4, 0, 4);
addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into", SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints);
// Remark: do mac user really need to be able to put the file either in a specific mac dir or home?
if (SystemUtils.IS_OS_MAC_OSX) {
addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler, gridBagConstraints);
} else if (SystemUtils.IS_OS_UNIX) {
// putting it the same way as mac. merging all and using a system config dir instead would be better IMHO.
addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD", SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints);
}
addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group, handler, gridBagConstraints);
addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints);
dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir));
dirField.setEditable(false);
gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
gridBagConstraints.weightx = 1;
gridBagConstraints.insets = new Insets(0, 4, 0, 0);
getContentPane().add(dirField, gridBagConstraints);
dirButton.setText("...");
dirButton.setEnabled(false);
dirButton.addActionListener(handler);
dirButton.setActionCommand("custom");
dirButton.setMargin(new Insets(2, 2, 2, 2));
GridBagConstraints bagConstraints = new GridBagConstraints();
bagConstraints.gridwidth = GridBagConstraints.REMAINDER;
bagConstraints.insets = new Insets(0, 0, 0, 4);
getContentPane().add(dirButton, bagConstraints);
JButton okButton = new JButton("OK");
okButton.setPreferredSize(new Dimension(75, 23));
okButton.setActionCommand("ok");
okButton.addActionListener(handler);
bagConstraints.insets = new Insets(4, 0, 4, 0);
getContentPane().add(okButton, bagConstraints);
getRootPane().setDefaultButton(okButton);
pack();
setLocationRelativeTo(null);
}
use of java.awt.Dimension in project voltdb by VoltDB.
the class ZaurusDatabaseManager method initGUI.
/**
* Method declaration
*
*/
private void initGUI() {
Panel pQuery = new Panel();
Panel pCommand = new Panel();
// define a Panel pCard which takes four different cards/views:
// tree of tables, command SQL text area, result window and an editor/input form
pCard = new Panel();
layoutCard = new CardLayout(2, 2);
pCard.setLayout(layoutCard);
// four buttons at the top to quickly switch between the four views
butTree = new Button("Tree");
butCommand = new Button("Command");
butResult = new Button("Result");
butEditor = new Button("Editor");
butTree.addActionListener(this);
butCommand.addActionListener(this);
butResult.addActionListener(this);
butEditor.addActionListener(this);
Panel pButtons = new Panel();
pButtons.setLayout(new GridLayout(1, 4, 8, 8));
pButtons.add(butTree);
pButtons.add(butCommand);
pButtons.add(butResult);
pButtons.add(butEditor);
pResult = new Panel();
pQuery.setLayout(new BorderLayout());
pCommand.setLayout(new BorderLayout());
pResult.setLayout(new BorderLayout());
Font fFont = new Font("Dialog", Font.PLAIN, 12);
txtCommand = new TextArea(5, 40);
txtCommand.addKeyListener(this);
txtResult = new TextArea(20, 40);
txtCommand.setFont(fFont);
txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
butExecute = new Button("Execute");
butExecute.addActionListener(this);
pCommand.add("South", butExecute);
pCommand.add("Center", txtCommand);
gResult = new Grid();
setLayout(new BorderLayout());
pResult.add("Center", gResult);
tTree = new Tree();
tTree.setMinimumSize(new Dimension(200, 100));
gResult.setMinimumSize(new Dimension(200, 300));
eEditor = new ZaurusEditor();
pCard.add("tree", tTree);
pCard.add("command", pCommand);
pCard.add("result", pResult);
pCard.add("editor", eEditor);
fMain.add("Center", pCard);
fMain.add("North", pButtons);
doLayout();
fMain.pack();
}
use of java.awt.Dimension in project voltdb by VoltDB.
the class FontDialogSwing method creatFontDialog.
/**
* Create and display FontDialogSwing Dialog.
*
*/
public static void creatFontDialog(DatabaseManagerSwing owner) {
if (isRunning) {
frame.setVisible(true);
} else {
CommonSwing.setSwingLAF(frame, CommonSwing.Native);
fOwner = owner;
frame.setIconImage(CommonSwing.getIcon("Frame"));
isRunning = true;
frame.setSize(600, 100);
CommonSwing.setFramePositon(frame);
ckbitalic = new JCheckBox(new ImageIcon(CommonSwing.getIcon("ItalicFont")));
ckbitalic.putClientProperty("is3DEnabled", Boolean.TRUE);
ckbitalic.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setStyle();
}
});
ckbbold = new JCheckBox(new ImageIcon(CommonSwing.getIcon("BoldFont")));
ckbbold.putClientProperty("is3DEnabled", Boolean.TRUE);
ckbbold.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setStyle();
}
});
fgColorButton = new JButton("Foreground", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
fgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
fgColorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColor(FOREGROUND);
}
});
bgColorButton = new JButton("Background", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
bgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
bgColorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColor(BACKGROUND);
}
});
closeButton = new JButton("Close", new ImageIcon(CommonSwing.getIcon("Close")));
closeButton.putClientProperty("is3DEnabled", Boolean.TRUE);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
}
});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames = ge.getAvailableFontFamilyNames();
Dimension fontsComboBoxDimension = new Dimension(160, 25);
fontsComboBox = new JComboBox(fontNames);
fontsComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
fontsComboBox.setMaximumSize(fontsComboBoxDimension);
fontsComboBox.setPreferredSize(fontsComboBoxDimension);
fontsComboBox.setMaximumSize(fontsComboBoxDimension);
fontsComboBox.setEditable(false);
fontsComboBox.setSelectedItem(defaultFont);
fontsComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setFont();
}
});
// weconsultants@users 20050215 - Added for Compatbilty fix for JDK 1.3
fontSizesComboBox = new JComboBox(fontSizes);
Dimension spinnerDimension = new Dimension(45, 25);
fontSizesComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
fontSizesComboBox.setMinimumSize(spinnerDimension);
fontSizesComboBox.setPreferredSize(spinnerDimension);
fontSizesComboBox.setMaximumSize(spinnerDimension);
fontSizesComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
if (evt.getStateChange() == ItemEvent.SELECTED) {
setFontSize((String) evt.getItem());
}
}
});
// weconsultants@users 20050215 - Commented out for Compatbilty fix for JDK 1.3
// Dimension spinnerDimension = new Dimension(50, 25);
// spinnerFontSizes = new JSpinner();
// spinnerFontSizes.putClientProperty("is3DEnabled", Boolean.TRUE);
// spinnerFontSizes.setMinimumSize(spinnerDimension);
// spinnerFontSizes.setPreferredSize(spinnerDimension);
// spinnerFontSizes.setMaximumSize(spinnerDimension);
// spinnerModelSizes = new SpinnerNumberModel(12, 8, 72, 1);
// spinnerFontSizes.setModel(spinnerModelSizes);
// spinnerFontSizes.addChangeListener(new ChangeListener() {
// public void stateChanged(ChangeEvent e) {
// setFontSize();
// }
// });
Container contentPane = frame.getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(fontsComboBox);
// weconsultants@users 20050215 - Commented out for Compatbilty fix for 1.3
// contentPane.add(spinnerFontSizes);
// weconsultants@users 20050215 - Added for Compatbilty fix for 1.3
contentPane.add(fontSizesComboBox);
contentPane.add(ckbbold);
contentPane.add(ckbitalic);
contentPane.add(fgColorButton);
contentPane.add(bgColorButton);
contentPane.add(closeButton);
frame.pack();
frame.setVisible(false);
}
}
use of java.awt.Dimension in project voltdb by VoltDB.
the class Transfer method _main.
/**
* @throws IllegalArgumentException for the obvious reason
*/
void _main(String[] arg) {
/*
** What function is asked from the transfer tool?
*/
iTransferMode = TRFM_TRANSFER;
if (arg != null) {
if (arg.length != 1) {
throw new IllegalArgumentException();
}
if ((arg[0].toLowerCase().equals("-r")) || (arg[0].toLowerCase().equals("--restore"))) {
iTransferMode = TRFM_RESTORE;
} else if ((arg[0].toLowerCase().equals("-d")) || (arg[0].toLowerCase().equals("--dump"))) {
iTransferMode = TRFM_DUMP;
} else if ((arg[0].toLowerCase().equals("-h")) || (arg[0].toLowerCase().equals("--help"))) {
System.out.println(Transfer.SYNTAX_MSG);
return;
} else {
throw new IllegalArgumentException();
}
}
fMain = new Frame("HSQL Transfer Tool");
imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
fMain.setIconImage(imgEmpty);
fMain.addWindowListener(this);
fMain.setSize(640, 480);
fMain.add("Center", this);
MenuBar bar = new MenuBar();
String[] extras = { "Insert 10 rows only", "Insert 1000 rows only", "Insert all rows", "-", "Load Settings...", "Save Settings...", "-", "Exit" };
Menu menu = new Menu("Options");
addMenuItems(menu, extras);
bar.add(menu);
fMain.setMenuBar(bar);
initGUI();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = fMain.getSize();
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
} else {
fMain.setLocation(0, 0);
fMain.setSize(d);
}
fMain.setVisible(true);
CurrentTransfer = CurrentAlter = 0;
try {
if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
sourceDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Source Database"), this);
if (!sourceDb.isConnected()) {
exit();
return;
}
} else {
FileDialog f = new FileDialog(fMain, "Restore FileName", FileDialog.LOAD);
f.show();
String sFileName = f.getFile();
String Path = f.getDirectory();
if ((sFileName == null) || (sFileName.equals(""))) {
exit();
return;
} else {
sourceDb = new TransferSQLText(Path + sFileName, this);
}
}
if ((iTransferMode == TRFM_RESTORE) || (iTransferMode == TRFM_TRANSFER)) {
targetDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Target Database"), this);
if (!targetDb.isConnected()) {
exit();
return;
}
} else {
FileDialog f = new FileDialog(fMain, "Dump FileName", FileDialog.SAVE);
f.show();
String sFileName = f.getFile();
String Path = f.getDirectory();
if ((sFileName == null) || (sFileName.equals(""))) {
exit();
return;
} else {
targetDb = new TransferSQLText(Path + sFileName, this);
}
}
} catch (Exception e) {
exit();
e.printStackTrace();
return;
}
if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
iSelectionStep = SELECT_SOURCE_CATALOG;
sSourceCatalog = null;
} else {
iSelectionStep = SELECT_DEST_CATALOG;
sDestCatalog = null;
}
ProcessNextStep();
fMain.show();
return;
}
use of java.awt.Dimension in project voltdb by VoltDB.
the class CommonSwing method setFramePositon.
// (weconsultants@users: Callable setFramePositon method
static void setFramePositon(JFrame inTargetFrame) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = inTargetFrame.getSize();
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
inTargetFrame.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
} else {
inTargetFrame.setLocation(0, 0);
inTargetFrame.setSize(d);
}
}
Aggregations