use of java.awt.Toolkit in project JSettlers2 by jdmonin.
the class SOCBoardPanel method loadImages.
/**
* Load the images for the board: {@link #hexes}, {@link #rotatHexes}, and {@link #dice}.
* Loads all hex types, up through {@link SOCBoardLarge#FOG_HEX},
* because {@link #hexes} is static for all boards and all game options.
* @param c Our component, to load image resource files with getToolkit and getResource
* @param wantsRotated True for the 6-player non-sea board
* (v2 encoding {@link SOCBoard#BOARD_ENCODING_6PLAYER}), false otherwise.
* The large board (v3 encoding)'s fog-hex and gold-hex images have no rotated version,
* because that board layout is never rotated.
*/
private static synchronized void loadImages(Component c, final boolean wantsRotated) {
if ((hexes != null) && ((rotatHexes != null) || !wantsRotated))
return;
Toolkit tk = c.getToolkit();
Class<?> clazz = c.getClass();
if (hexes == null) {
MediaTracker tracker = new MediaTracker(c);
// water, desert, 5 resources, gold, fog, hex border mask, 3:1 port
hexes = new Image[11];
dice = new Image[14];
loadHexesAndImages(hexes, IMAGEDIR, tracker, tk, clazz, false);
for (int i = 2; i < 13; i++) {
dice[i] = tk.getImage(clazz.getResource(IMAGEDIR + "/dice" + i + ".gif"));
tracker.addImage(dice[i], 0);
}
try {
tracker.waitForID(0);
} catch (InterruptedException e) {
}
if (tracker.isErrorID(0)) {
System.out.println("Error loading board images");
}
}
if (wantsRotated && (rotatHexes == null)) {
MediaTracker tracker = new MediaTracker(c);
// only 9, not 11: large board (gold,fog) is not rotated
rotatHexes = new Image[9];
loadHexesAndImages(rotatHexes, IMAGEDIR + "/rotat", tracker, tk, clazz, true);
try {
tracker.waitForID(0);
} catch (InterruptedException e) {
}
if (tracker.isErrorID(0)) {
System.out.println("Error loading rotated board images");
}
}
}
use of java.awt.Toolkit in project evosuite by EvoSuite.
the class MockJFileChooser method installShowFilesListener.
private void installShowFilesListener() {
// Track native setting for showing hidden files
Toolkit tk = Toolkit.getDefaultToolkit();
Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
if (showHiddenProperty instanceof Boolean) {
useFileHiding = !((Boolean) showHiddenProperty).booleanValue();
showFilesListener = new MockWeakPCL(this);
tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
}
}
use of java.awt.Toolkit in project opt4j by felixreimann.
the class Query method _addPair.
// /////////////////////////////////////////////////////////////////
// // protected methods ////
/**
* Add a label and a widget to the panel.
*
* @param name
* The name of the entry.
* @param label
* The label.
* @param widget
* The interactive entry to the right of the label.
* @param entry
* The object that contains user data.
*/
protected void _addPair(String name, JLabel label, Component widget, Object entry) {
// Surely there is a better layout manager in swing...
// Note that Box and BoxLayout do not work because they do not
// support gridded layout.
_constraints.gridwidth = 1;
_constraints.insets = _leftPadding;
_grid.setConstraints(label, _constraints);
_entryPanel.add(label);
_constraints.insets = _noPadding;
if ((_columns > 1) && (((_entries.size() + 1) % _columns) != 0)) {
_constraints.gridwidth = 1;
} else {
_constraints.gridwidth = GridBagConstraints.REMAINDER;
}
_grid.setConstraints(widget, _constraints);
_entryPanel.add(widget);
_entries.put(name, entry);
_labels.put(name, label);
_previous.put(name, getStringValue(name));
Dimension preferredSize = _entryPanel.getPreferredSize();
// Add some slop to the width to take in to account
// the width of the vertical scrollbar.
preferredSize.width += 25;
// Applets seem to need this, see CT/SigmaDelta
_widgetsHeight += widget.getPreferredSize().height;
preferredSize.height = _widgetsHeight;
Toolkit tk = Toolkit.getDefaultToolkit();
if (preferredSize.height > tk.getScreenSize().height) {
// Fudge factor to keep this window smaller than the screen
// height. CGSUnitBase and the Code Generator are good tests.
preferredSize.height = (int) (tk.getScreenSize().height * 0.75);
_entryScrollPane.setPreferredSize(preferredSize);
}
_entryScrollPane.setPreferredSize(preferredSize);
// Call revalidate for the scrollbar.
_entryPanel.revalidate();
}
use of java.awt.Toolkit in project java_Projects by listar2000.
the class CardGameGUI method signalError.
/**
* Deal with the user clicking on something other than a button or a card.
*/
private void signalError() {
Toolkit t = panel.getToolkit();
t.beep();
}
use of java.awt.Toolkit in project javatari by ppeccin.
the class DesktopConsolePanel method buildGUI.
private void buildGUI() {
loadImages();
setLayout(new BorderLayout());
setTitle(DesktopScreenWindow.BASE_TITLE + " - Console Panel");
setIconImages(Arrays.asList(new Image[] { masterWindow.icon64, masterWindow.icon32, masterWindow.favicon }));
addGlassPane();
setSize(desiredSize());
setResizable(false);
add(consolePanel, BorderLayout.CENTER);
Toolkit tk = Toolkit.getDefaultToolkit();
int x = (tk.getScreenSize().width - getWidth()) / 2;
int y = (tk.getScreenSize().height - getHeight()) / 2;
setLocation(x, y);
addMasterWindowListeners();
}
Aggregations