Просмотр исходного кода

Converted Graphics Capabilities to be JFrame instead of JDialog

MeFisto94 7 лет назад
Родитель
Сommit
beb8381f2b

+ 13 - 11
jme3-core/src/com/jme3/gde/core/errorreport/RendererInfo.form

@@ -1,12 +1,6 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 
-<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="2"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-  </SyntheticProperties>
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
   <AuxValues>
     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
     <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@@ -22,12 +16,20 @@
   <Layout>
     <DimensionLayout dim="0">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Component id="jScrollPane2" alignment="0" pref="400" max="32767" attributes="0"/>
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane2" pref="400" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
       </Group>
     </DimensionLayout>
     <DimensionLayout dim="1">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Component id="jScrollPane2" alignment="0" pref="340" max="32767" attributes="0"/>
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane2" pref="340" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
       </Group>
     </DimensionLayout>
   </Layout>
@@ -45,8 +47,8 @@
           <SubComponents>
             <Component class="javax.swing.JTextArea" name="jTextArea1">
               <Properties>
-                <Property name="columns" type="int" value="20"/>
                 <Property name="editable" type="boolean" value="false"/>
+                <Property name="columns" type="int" value="20"/>
                 <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
                   <Font name="Courier" size="13" style="0"/>
                 </Property>

+ 22 - 24
jme3-core/src/com/jme3/gde/core/errorreport/RendererInfo.java

@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2009-2010 jMonkeyEngine
+ *  Copyright (c) 2009-2018 jMonkeyEngine
  *  All rights reserved.
  * 
  *  Redistribution and use in source and binary forms, with or without
@@ -30,31 +30,27 @@
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * RendererInfo.java
- *
- * Created on 27.02.2011, 06:17:27
- */
 package com.jme3.gde.core.errorreport;
 
 import com.jme3.gde.core.scene.SceneApplication;
 import com.jme3.renderer.Caps;
 import com.jme3.renderer.Renderer;
 import java.util.EnumSet;
-import java.util.Iterator;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
+import javax.swing.JPanel;
 import org.openide.util.Exceptions;
 
 /**
- *
+ * The RendererInfo is the Panel used to display the Graphics Capabilities.
+ * 
  * @author normenhansen
  */
-public class RendererInfo extends javax.swing.JDialog {
+public class RendererInfo extends JPanel {
 
     /** Creates new form RendererInfo */
-    public RendererInfo(java.awt.Frame parent, boolean modal) {
-        super(parent, modal);
+    public RendererInfo() {
+        super();
         initComponents();
         updateInfo();
     }
@@ -62,21 +58,21 @@ public class RendererInfo extends javax.swing.JDialog {
     private void updateInfo() {
         try {
             jTextArea1.setText(SceneApplication.getApplication().enqueue(new Callable<String>() {
-
+                @Override
                 public String call() throws Exception {
                     String out = "";
                     Renderer renderer = SceneApplication.getApplication().getRenderer();
                     EnumSet<Caps> caps = renderer.getCaps();
                     out = out + "Graphics Capabilities\n";
                     out = out + "---------------------\n";
-                    for (Iterator<Caps> it = caps.iterator(); it.hasNext();) {
-                        Caps caps1 = it.next();
+                    for (Caps caps1 : caps) {
                         out = out + caps1.name() + "\n";
                     }
                     return out;
                 }
             }).get());
         } catch (InterruptedException ex) {
+            // Warning: Do NOT call ExceptionUtils from here
             Exceptions.printStackTrace(ex);
         } catch (ExecutionException ex) {
             Exceptions.printStackTrace(ex);
@@ -96,29 +92,31 @@ public class RendererInfo extends javax.swing.JDialog {
         jScrollPane1 = new javax.swing.JScrollPane();
         jTextArea1 = new javax.swing.JTextArea();
 
-        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-
-        jTextArea1.setColumns(20);
         jTextArea1.setEditable(false);
-        jTextArea1.setFont(new java.awt.Font("Courier", 0, 13));
+        jTextArea1.setColumns(20);
+        jTextArea1.setFont(new java.awt.Font("Courier", 0, 13)); // NOI18N
         jTextArea1.setRows(5);
         jTextArea1.setDisabledTextColor(new java.awt.Color(0, 0, 0));
         jScrollPane1.setViewportView(jTextArea1);
 
         jScrollPane2.setViewportView(jScrollPane1);
 
-        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
-        getContentPane().setLayout(layout);
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
         layout.setHorizontalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
+                .addContainerGap())
         );
         layout.setVerticalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
+                .addContainerGap())
         );
-
-        pack();
     }// </editor-fold>//GEN-END:initComponents
 
 

+ 10 - 4
jme3-core/src/com/jme3/gde/core/errorreport/RendererInfoAction.java

@@ -34,6 +34,8 @@ package com.jme3.gde.core.errorreport;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import javax.swing.JFrame;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
 import org.openide.awt.ActionID;
 import org.openide.awt.ActionReference;
 import org.openide.awt.ActionRegistration;
@@ -42,14 +44,18 @@ import org.openide.awt.ActionRegistration;
 @ActionRegistration(displayName = "#CTL_RendererInfoAction", iconInMenu = true)
 @ActionReference(path = "Menu/Help", position = 1225)
 public final class RendererInfoAction implements ActionListener {
-
     RendererInfo info;
+    DialogDescriptor dialogInfo;
 
+    @Override
     public void actionPerformed(ActionEvent e) {
         if (info == null) {
-            info = new RendererInfo(new JFrame(), false);
+            info = new RendererInfo();
+        }
+        if (dialogInfo == null) {
+            dialogInfo = new DialogDescriptor(info, "Graphics Capabilities", true, new Object[] { DialogDescriptor.OK_OPTION }, DialogDescriptor.DEFAULT_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
         }
-        info.setLocationRelativeTo(null);
-        info.setVisible(true);
+        
+        DialogDisplayer.getDefault().notifyLater(dialogInfo);
     }
 }