java.awt.HeadlessException Java Examples

The following examples show how to use java.awt.HeadlessException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MutualAuthenticationSettingsPanel.java    From Spark with Apache License 2.0 6 votes vote down vote up
private void createSelfSignedCertificate() {
idControll.setUpData(commonNameField.getText(), organizationUnitField.getText(), organizationField.getText(), countryField.getText(),
	cityField.getText());
try {
    KeyPair keyPair = idControll.createKeyPair();

    X509Certificate cert = idControll.createSelfSignedCertificate(keyPair);
           if (saveCertToFile.isSelected()) {
               PemBuilder pemBuilder = new PemHelper().new PemBuilder();
               pemBuilder.add(keyPair.getPrivate());
               pemBuilder.add(cert);
               pemBuilder.saveToPemFile(IdentityController.CERT_FILE);
               JOptionPane.showMessageDialog(null,
                       Res.getString("dialog.self.signed.certificate.has.been.created") + IdentityController.SECURITY_DIRECTORY.toString());
           } else {
               try {
                   idControll.addEntryToKeyStore(cert, keyPair.getPrivate());
               } catch (HeadlessException | InvalidNameException | KeyStoreException e) {
                       Log.error("Couldn't save entry to IdentityStore", e);
               }
           }
} catch (NoSuchAlgorithmException | NoSuchProviderException | IOException | OperatorCreationException | CertificateException e1) {
    Log.error("Couldn't create Self Signed Certificate", e1);
}
   }
 
Example #2
Source File: SparkTrustManager.java    From Spark with Apache License 2.0 6 votes vote down vote up
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
    try {
        doTheChecks(chain, authType);
    } catch (CertPathValidatorException e) {
        try {
            SwingUtilities.invokeLater(new Runnable() {
                
                @Override
                public void run() {
                certControll.addChain(chain);
                }
            });

        } catch (HeadlessException e1) {
            Log.error("Couldn't add certificate from presented chain");
        }
        throw new CertificateException(e);
    }
}
 
Example #3
Source File: TestImprovedFileChooser.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testStuff()
    throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {
  try {
    if (ImprovedFileChooser.isMacOs) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
    } else {
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    }
    ImprovedFileChooser fileChooser = new ImprovedFileChooser();
    fileChooser.setPreferredSize(new Dimension(1000, 750));
    fileChooser.showDialog(null, "Choose");
  } catch (HeadlessException e) {
    // ok to fail if there is no display
  }
}
 
Example #4
Source File: PlayerCharacterTest.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Test the processing of modFeat. Checks that when in select single and
 * close mode, only one instance of a feat with a sub-choice is added.
 */
@Test
public void testModFeat()
{
	readyToRun();
	final PlayerCharacter character = new PlayerCharacter();
	character.setRace(human);
	character.incrementClassLevel(1, pcClass, true);

	UIPropertyContext.setSingleChoiceAction(Constants.CHOOSER_SINGLE_CHOICE_METHOD_SELECT_EXIT);
	ChooserFactory.useRandomChooser();

	assertEquals(
			2, (int)character.getRemainingFeatPoints(true),
			"Start with 2 feats"
	);
	try
	{
		AbstractCharacterTestCase.applyAbility(character, BuildUtilities.getFeatCat(), toughness, "");
	}
	catch (HeadlessException e)
	{
		Logging.debugPrint("Ignoring Headless exception.");
	}
	assertEquals(1, (int)character.getRemainingFeatPoints(true), "Only 1 feat used");
}
 
Example #5
Source File: R2303044ListSelection.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws HeadlessException {
    final Frame frame = new Frame("Test Frame");
    final List list = new List();
    frame.setSize(300, 200);
    list.add(ITEM_NAME);
    list.select(0);
    frame.add(list);
    frame.validate();
    frame.setVisible(true);
    sleep();
    if (!ITEM_NAME.equals(list.getSelectedItem())) {
        throw new RuntimeException("List item not selected item.");
    }
    list.removeAll();
    frame.dispose();
}
 
Example #6
Source File: InputMethodContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
    if (isSwing) {
        return new InputMethodJFrame(title, context);
    } else {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if (toolkit instanceof InputMethodSupport) {
            return ((InputMethodSupport)toolkit).createInputMethodWindow(
                title, context);
        }
    }
    throw new InternalError("Input methods must be supported");
}
 
Example #7
Source File: InputMethodContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
    if (isSwing) {
        return new InputMethodJFrame(title, context);
    } else {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if (toolkit instanceof InputMethodSupport) {
            return ((InputMethodSupport)toolkit).createInputMethodWindow(
                title, context);
        }
    }
    throw new InternalError("Input methods must be supported");
}
 
Example #8
Source File: SpriteStore.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
protected SpriteStore() {
	try {
		gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
	} catch (HeadlessException e) {
		logger.warn("Cannot initialize graphic user interface: " + e);
	}
}
 
Example #9
Source File: InputMethodContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
    if (isSwing) {
        return new InputMethodJFrame(title, context);
    } else {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if (toolkit instanceof InputMethodSupport) {
            return ((InputMethodSupport)toolkit).createInputMethodWindow(
                title, context);
        }
    }
    throw new InternalError("Input methods must be supported");
}
 
Example #10
Source File: SupportRefillSourcePanel.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
private void pasteFromClipboard() {
    try {
        String data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
        List<Village> villages = PluginManager.getSingleton().executeVillageParser(data);
        if (!villages.isEmpty()) {
            addVillages(villages.toArray(new Village[villages.size()]));
        }
    } catch (HeadlessException | IOException | UnsupportedFlavorException ignored) {
    }
}
 
Example #11
Source File: DropTarget.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
Example #12
Source File: InputMethodContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
    if (isSwing) {
        return new InputMethodJFrame(title, context);
    } else {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if (toolkit instanceof InputMethodSupport) {
            return ((InputMethodSupport)toolkit).createInputMethodWindow(
                title, context);
        }
    }
    throw new InternalError("Input methods must be supported");
}
 
Example #13
Source File: InputMethodContext.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
    if (isSwing) {
        return new InputMethodJFrame(title, context);
    } else {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if (toolkit instanceof InputMethodSupport) {
            return ((InputMethodSupport)toolkit).createInputMethodWindow(
                title, context);
        }
    }
    throw new InternalError("Input methods must be supported");
}
 
Example #14
Source File: DropTarget.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
Example #15
Source File: DropTarget.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
Example #16
Source File: StyleAttribute.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
static public float convertUnitsToPixels(final int unitType, final float value) {
	if (unitType == NumberWithUnits.UT_UNITLESS || unitType == NumberWithUnits.UT_PERCENT) { return value; }

	float pixPerInch;
	try {
		pixPerInch = Toolkit.getDefaultToolkit().getScreenResolution();
	} catch (final HeadlessException ex) {
		// default to 72 dpi
		pixPerInch = 72;
	}
	final float inchesPerCm = .3936f;

	switch (unitType) {
		case NumberWithUnits.UT_IN:
			return value * pixPerInch;
		case NumberWithUnits.UT_CM:
			return value * inchesPerCm * pixPerInch;
		case NumberWithUnits.UT_MM:
			return value * .1f * inchesPerCm * pixPerInch;
		case NumberWithUnits.UT_PT:
			return value * (1f / 72f) * pixPerInch;
		case NumberWithUnits.UT_PC:
			return value * (1f / 6f) * pixPerInch;
	}

	return value;
}
 
Example #17
Source File: DropTarget.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
Example #18
Source File: R2303044ListSelection.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws HeadlessException {
    final Frame frame = new Frame("Test Frame");
    final List list = new List();
    frame.setSize(300, 200);
    list.add(ITEM_NAME);
    list.select(0);
    frame.add(list);
    frame.validate();
    frame.setVisible(true);
    sleep();
    if (!ITEM_NAME.equals(list.getSelectedItem())) {
        throw new RuntimeException("List item not selected item.");
    }
    list.removeAll();
    frame.dispose();
}
 
Example #19
Source File: TestPanel.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testPanel() {
  try {
    PrefPanel pp = new PrefPanel("title", (PreferencesExt) store.node("test"));
    pp.addTextField("name", "name", "defValue");
    Field.Text longF = pp.addTextField("Longname", "Longname",
        "defValue really long name for to be with starting value gotta adjust the thing");
    Field.Int iu = pp.addIntField("testIU", "number of times to barf", 2);
    pp.finish();
  } catch (HeadlessException e) {
    // ok to fail if there is no display
  }
}
 
Example #20
Source File: HeadlessModeUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenHeadlessmode_thenFrameThrowsHeadlessException() {
    assertThatExceptionOfType(HeadlessException.class).isThrownBy(() -> {
        Frame frame = new Frame();
        frame.setVisible(true);
        frame.setSize(120, 120);
    });
}
 
Example #21
Source File: DefenseSourcePanel.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
private void pasteFromClipboard() {
    String data = "";
    try {
        data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
        List<Village> villages = PluginManager.getSingleton().executeVillageParser(data);
        if (!villages.isEmpty()) {
            addVillages(villages.toArray(new Village[villages.size()]));
        }
    } catch (HeadlessException | IOException | UnsupportedFlavorException ignored) {
    }
}
 
Example #22
Source File: BaseDialog.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
public BaseDialog(Frame owner) throws HeadlessException {
  super(owner);
  buildUI();
}
 
Example #23
Source File: JFileChooser.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static void checkDragEnabled(boolean b) {
    if (b && GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
}
 
Example #24
Source File: UtilitiesTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public int getScreenResolution() throws HeadlessException {
    return Toolkit.getDefaultToolkit().getScreenResolution();
}
 
Example #25
Source File: Patient_Admit_Room.java    From Hospital-Management with GNU General Public License v3.0 4 votes vote down vote up
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
    try{
        con=Connect.ConnectDB();
        if (PatientID.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please retrieve Patient ID","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (txtPatientName.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please retrieve Patient Name","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (txtGender.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please retrieve Gender","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (txtBloodGroup.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please retrieve blood group","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (txtDisease.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please enter disease","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (txtAdmitDate.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please enter admit date","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (cmbRoomNo.getSelectedItem().equals("")) {
            JOptionPane.showMessageDialog( this, "Please select room no.","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (txtDoctorID.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please retrieve doctor id","Error", JOptionPane.ERROR_MESSAGE);
            return;

        }
        if (txtDoctorName.getText().equals("")) {
            JOptionPane.showMessageDialog( this, "Please enter retrieve doctor name","Error", JOptionPane.ERROR_MESSAGE);
            return;

        }
        Statement stmt1;
        stmt1= con.createStatement();
        String sql2="Select RoomNo from Room where RoomNo= '" + cmbRoomNo.getSelectedItem()+ "' and RoomStatus='Booked'";
        rs=stmt1.executeQuery(sql2);
        if(rs.next()){
            JOptionPane.showMessageDialog( this, "Room is already booked","Error", JOptionPane.ERROR_MESSAGE);
            cmbRoomNo.setSelectedItem("");
            cmbRoomNo.requestDefaultFocus();
            return;
        }
        Statement stmt;
        stmt= con.createStatement();
        String sql1="Select PatientID,AdmitDate from AdmitPatient_Room where PatientID= '" + PatientID.getText() + "' and AdmitDate='" + txtAdmitDate + "'";
        rs=stmt.executeQuery(sql1);
        if(rs.next()){
            JOptionPane.showMessageDialog( this, "Record already exists","Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        String sql= "insert into admitpatient_room(PatientID,Disease,AdmitDate,RoomNo,DoctorID,AP_Remarks)values('"+ PatientID.getText() + "','"+ txtDisease.getText() + "','"+ txtAdmitDate.getText() + "','"+ cmbRoomNo.getSelectedItem()+ "','" + txtDoctorID.getText() + "','"+ txtRemarks.getText() + "')";

        pst=con.prepareStatement(sql);
        pst.execute();
        String sql3= "update room set RoomStatus='Booked' where RoomNo='" + cmbRoomNo.getSelectedItem() + "'";
        pst=con.prepareStatement(sql3);
        pst.execute();
        JOptionPane.showMessageDialog(this,"Successfully admitted","Patient",JOptionPane.INFORMATION_MESSAGE);
        btnSave.setEnabled(false);

    }catch(HeadlessException | SQLException ex){
        JOptionPane.showMessageDialog(this,ex);
    }
}
 
Example #26
Source File: PropertySheetDialog.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public PropertySheetDialog(Frame owner, String title)
  throws HeadlessException {
  super(owner, title);
}
 
Example #27
Source File: MiscellaneousPrimitives.java    From trufflesqueak with MIT License 4 votes vote down vote up
private static String getSystemAttribute(final int index) {
    switch (index) {
        case 1001:  // this platform's operating system 'Mac OS', 'Win32', 'unix', ...
            return OSDetector.SINGLETON.getSqOSName();
        case 1002:  // operating system version
            if (OSDetector.SINGLETON.isMacOS()) {
                /* The image expects things like 1095, so convert 10.10.5 into 1010.5 */
                return System.getProperty("os.version", "unknown").replaceFirst("\\.", "");
            } else {
                return System.getProperty("os.version", "unknown");
            }
        case 1003:  // this platform's processor type
            final String osArch = System.getProperty("os.arch");
            if (osArch.equals("aarch64")) {
                return "armv8"; /* For `SmalltalkImage>>#isLowerPerformance`. */
            } else {
                return osArch;
            }
        case 1004:  // vm version
            /*
             * Start with "Croquet" to let `LanguageEnvironment win32VMUsesUnicode` return
             * `true`. Add fake VMMaker info to make `Smalltalk vmVMMakerVersion` work.
             */
            return "Croquet " + SqueakLanguageConfig.IMPLEMENTATION_NAME + " " + SqueakLanguageConfig.VERSION + " VMMaker.fn.9999";
        case 1005:  // window system name
            return "Aqua";
        case 1006:  // vm build id
            final String date = new SimpleDateFormat(VM_BUILD_ID_DATE_FORMAT, Locale.US).format(new Date(MiscUtils.getStartTime()));
            return String.format("%s %s (%s) built on %s", getOSName(), getOSVersion(), getOSArch(), date);
        case 1007: // Interpreter class (Cog VM only)
            return MiscUtils.getGraalVMInformation();
        case 1008: // Cogit class (Cog VM only)
            return MiscUtils.getSystemProperties();
        case 1009: // Platform source version
            return MiscUtils.getVMInformation();
        case 1201: // max filename length (Mac OS only)
            if (OSDetector.SINGLETON.isMacOS()) {
                return "255";
            }
            break;
        case 1202: // file last error (Mac OS only)
            if (OSDetector.SINGLETON.isMacOS()) {
                return "0";
            }
            break;
        case 10001: // hardware details (Win32 only)
            return "Hardware information: not supported";
        case 10002: // operating system details (Win32 only)
            return String.format("Operating System: %s (%s, %s)", getOSName(), getOSVersion(), getOSArch());
        case 10003: // graphics hardware details (Win32 only)
            int width = 0;
            int height = 0;
            try {
                final DisplayMode dm = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
                width = dm.getWidth();
                height = dm.getHeight();
            } catch (final HeadlessException e) {
                /* Report 0 x 0 in headless mode. */
            }
            return String.format("Display Information: \n" +
                            "\tPrimary monitor resolution: %d x %d\n", width, height);
        default:
            return null;
    }
    return null;
}
 
Example #28
Source File: UtilitiesTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) throws IndexOutOfBoundsException, HeadlessException {

            createCustomCursorCalled = true;
            return Toolkit.getDefaultToolkit().createCustomCursor(cursor, hotSpot, name);
        }
 
Example #29
Source File: HeadlessGraphicsEnvironment.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public Rectangle getMaximumWindowBounds() throws HeadlessException {
    throw new HeadlessException();
}
 
Example #30
Source File: HeadlessGraphicsEnvironment.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Point getCenterPoint() throws HeadlessException {
    throw new HeadlessException();
}