use of java.awt.HeadlessException in project bigbluebutton by bigbluebutton.
the class ScreenCapture method getMouseLocation.
private Point getMouseLocation() {
PointerInfo pInfo;
Point pointerLocation = new Point(0, 0);
try {
pInfo = MouseInfo.getPointerInfo();
} catch (HeadlessException e) {
pInfo = null;
} catch (SecurityException e) {
pInfo = null;
}
if (pInfo == null)
return pointerLocation;
return pInfo.getLocation();
}
use of java.awt.HeadlessException in project eweb4j-framework by laiweiwei.
the class FileUtil method toBufferedImage.
private static BufferedImage toBufferedImage(Image image) {
if (image instanceof BufferedImage) {
return (BufferedImage) image;
}
// This code ensures that all the pixels in the image are loaded
image = new ImageIcon(image).getImage();
// Determine if the image has transparent pixels; for this method's
// implementation, see e661 Determining If an Image Has Transparent
// Pixels
// boolean hasAlpha = hasAlpha(image);
// Create a buffered image with a format that's compatible with the
// screen
BufferedImage bimage = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
try {
// Determine the type of transparency of the new buffered image
int transparency = Transparency.OPAQUE;
/*
* if (hasAlpha) { transparency = Transparency.BITMASK; }
*/
// Create the buffered image
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
} catch (HeadlessException e) {
// The system does not have a screen
}
if (bimage == null) {
// Create a buffered image using the default color model
int type = BufferedImage.TYPE_INT_RGB;
// int type = BufferedImage.TYPE_3BYTE_BGR;//by wang
/*
* if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; }
*/
bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
}
// Copy image to buffered image
Graphics g = bimage.createGraphics();
// Paint the image onto the buffered image
g.drawImage(image, 0, 0, null);
g.dispose();
return bimage;
}
use of java.awt.HeadlessException in project GNS by MobilityFirst.
the class ReplicaLatencyTest method main.
/**
* The main routine run from the command line.
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
try {
CommandLine parser = initializeOptions(args);
if (parser.hasOption("help") || args.length == 0) {
printUsage();
System.exit(1);
}
String alias = parser.getOptionValue("alias");
String host = parser.getOptionValue("host");
String port = parser.getOptionValue("port");
boolean debug = parser.hasOption("debug");
String closeActiveReplica = parser.getOptionValue("closeAR");
ReplicaLatencyTest test = new ReplicaLatencyTest(alias, host, port);
// Need this on to read the which replica is responding
//client.setEnableInstrumentation(true);
test.findSlowGuid(closeActiveReplica);
// send the reads and writes
test.readsAndWrites(closeActiveReplica);
//test.removeSubGuid();
client.close();
System.exit(0);
} catch (HeadlessException e) {
System.out.println("When running headless you'll need to specify the host and port on the command line");
printUsage();
System.exit(1);
}
}
use of java.awt.HeadlessException in project GNS by MobilityFirst.
the class CreateGuidTest method main.
/**
* The main routine run from the command line.
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
try {
CommandLine parser = initializeOptions(args);
if (parser.hasOption("help") || args.length == 0) {
printUsage();
System.exit(1);
}
String alias = parser.getOptionValue("alias");
new CreateGuidTest(alias != null ? alias : ACCOUNT_ALIAS);
System.exit(0);
} catch (HeadlessException e) {
System.out.println("When running headless you'll need to specify the host and port on the command line");
printUsage();
System.exit(1);
}
}
use of java.awt.HeadlessException in project GNS by MobilityFirst.
the class UserAuthPubKey method main.
/**
*
* @param arg
*/
public static void main(String[] arg) {
try {
JSch jsch = new JSch();
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Choose your privatekey(ex. ~/.ssh/id_dsa)");
chooser.setFileHidingEnabled(false);
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose " + chooser.getSelectedFile().getAbsolutePath() + ".");
// , "passphrase"
jsch.addIdentity(// , "passphrase"
chooser.getSelectedFile().getAbsolutePath());
}
String host = null;
if (arg.length > 0) {
host = arg[0];
} else {
host = JOptionPane.showInputDialog("Enter username@hostname", System.getProperty("user.name") + "@localhost");
}
String user = host.substring(0, host.indexOf('@'));
host = host.substring(host.indexOf('@') + 1);
Session session = jsch.getSession(user, host, 22);
// username and passphrase will be given via UserInfo interface.
UserInfo ui = new UserInfoPrompted();
session.setUserInfo(ui);
session.connect();
Channel channel = session.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect();
} catch (HeadlessException | JSchException e) {
System.out.println(e);
}
}
Aggregations