📄 requiredialog.java
字号:
jComboBox1.addItem("球体" ); // jComboBox2.addItem(""); jComboBox2.addItem("长方体"); jComboBox2.addItem("立方体"); jComboBox2.addItem("圆柱体"); jComboBox2.addItem("圆锥体"); jComboBox2.addItem("球体" ); } /*userInit() 数据表格的初始化*/ public void userInit() { SolidDtm=new DefaultTableModel(); //定义模式 SolidVCdata.add("序号"); SolidVCdata.add("OID"); SolidVCdata.add("类型"); SolidVCdata.add("表面积"); SolidVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i<SolidVCdata.size();i++) SolidDtm.addColumn((String)SolidVCdata.elementAt(i)); cuboidDtm=new DefaultTableModel(); //定义模式 cuboidVCdata.add("序号"); cuboidVCdata.add("OID"); cuboidVCdata.add("名字"); cuboidVCdata.add("长度"); cuboidVCdata.add("高度"); cuboidVCdata.add("宽度"); cuboidVCdata.add("表面积"); cuboidVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i<cuboidVCdata.size();i++) cuboidDtm.addColumn((String)cuboidVCdata.elementAt(i)); squareDtm=new DefaultTableModel(); //定义模式 squareVCdata.add("序号"); squareVCdata.add("OID"); squareVCdata.add("名字"); squareVCdata.add("边长"); squareVCdata.add("表面积"); squareVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i<squareVCdata.size();i++) squareDtm.addColumn((String)squareVCdata.elementAt(i)); cylinderDtm=new DefaultTableModel(); //定义模式 cylinderVCdata.add("序号"); cylinderVCdata.add("OID"); cylinderVCdata.add("名字"); cylinderVCdata.add("底面半径"); cylinderVCdata.add("高度"); cylinderVCdata.add("表面积"); cylinderVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i<cylinderVCdata.size();i++) cylinderDtm.addColumn((String)cylinderVCdata.elementAt(i)); coneDtm=new DefaultTableModel(); //定义模式 coneVCdata.add("序号"); coneVCdata.add("OID"); coneVCdata.add("名字"); coneVCdata.add("底面半径"); coneVCdata.add("高度"); coneVCdata.add("表面积"); coneVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i<coneVCdata.size();i++) coneDtm.addColumn((String)coneVCdata.elementAt(i)); SphereDtm=new DefaultTableModel(); //定义模式 sphereVCdata.add("序号"); sphereVCdata.add("OID"); sphereVCdata.add("名字"); sphereVCdata.add("半径"); sphereVCdata.add("表面积"); sphereVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i< sphereVCdata.size();i++) SphereDtm.addColumn((String) sphereVCdata.elementAt(i)); edgeDtm=new DefaultTableModel(); //定义bian模式 edgeVCdata.add("序号"); edgeVCdata.add("OID"); edgeVCdata.add("类型"); edgeVCdata.add("长度"); //edgeVCdata.add("表面积"); // edgeVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i< edgeVCdata.size();i++) edgeDtm.addColumn((String)edgeVCdata.elementAt(i)); faceDtm=new DefaultTableModel(); //定义模式 faceVCdata.add("序号"); faceVCdata.add("OID"); faceVCdata.add("类型"); faceVCdata.add("面积"); /**for 列出标题烂**/ for(int i=0;i< faceVCdata.size();i++) faceDtm.addColumn((String) faceVCdata.elementAt(i)); verticeDtm=new DefaultTableModel(); //定义模式 verticeVCdata.add("序号"); verticeVCdata.add("OID"); verticeVCdata.add("X轴坐标"); verticeVCdata.add("Y轴坐标"); verticeVCdata.add("Z轴坐标"); //edgeVCdata.add("表面积"); // edgeVCdata.add("体积"); /**for 列出标题烂**/ for(int i=0;i< verticeVCdata.size();i++) verticeDtm.addColumn((String) verticeVCdata.elementAt(i)); } void jButton3_actionPerformed(ActionEvent e) { this.dispose(); } void jButton4_actionPerformed(ActionEvent e) { TransSession session = new TransSession("mydb"); VEnumeration result=null; RequireMan require = new RequireMan(session); if (jRadioButton1.isSelected()) { jTable1.setModel(SolidDtm); result = require.showSolid(); if (!result.hasMoreElements()) { JOptionPane.showMessageDialog(this,"对不起, 现在还没有体","confirm",JOptionPane.PLAIN_MESSAGE); SolidDtm.setRowCount(0); session.endSession(); } else { SolidDtm.setRowCount(0); SolidDtm.addRow(SolidVCdata); int j=0; while (result.hasMoreElements()) { Solid solid = (Solid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<SolidVCdata.size();i++) { vRdata.addElement(new Integer(j)); vRdata.addElement(session.getOidAsString(solid)); vRdata.addElement(solid.getClass()); vRdata.addElement(new Float (solid .getSurface())); vRdata.addElement(new Float (solid .getVolume())); } SolidDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } } else if(jRadioButton2.isSelected()) { jTable1.setModel(SolidDtm); result = require.showPlaneSolid(); System.out.println(result.size()); if (result.size()==0) { SolidDtm.setRowCount(0); JOptionPane.showMessageDialog(this,"对不起,没有平面体","confirm",JOptionPane.PLAIN_MESSAGE); session.endSession(); } else { SolidDtm.setRowCount(0); SolidDtm.addRow(SolidVCdata); int j=0; while (result.hasMoreElements()) { PlaneSolid solid = (PlaneSolid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<SolidVCdata.size();i++) { vRdata.addElement(new Integer(j)); // vRdata.addElement(""+i); vRdata.addElement(session.getOidAsString(solid)); vRdata.addElement(solid.getClass()); vRdata.addElement(new Float(solid .getSurface())); vRdata.addElement(new Float (solid .getVolume())); } SolidDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } } else if(jRadioButton3.isSelected()) { jTable1.setModel(SolidDtm); result = require.showCurveSolid(); if (!result.hasMoreElements()) { JOptionPane.showMessageDialog(this,"对不起,没有曲面体","confirm",JOptionPane.PLAIN_MESSAGE); SolidDtm.setRowCount(0); session.endSession(); } else { SolidDtm.setRowCount(0); SolidDtm.addRow(SolidVCdata); int j=0; while (result.hasMoreElements()) { CurveSolid solid = (CurveSolid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<SolidVCdata.size();i++) { vRdata.addElement(new Integer(j)); //vRdata.addElement(""+i); vRdata.addElement(session.getOidAsString(solid)); vRdata.addElement(solid.getClass()); vRdata.addElement(new Float(solid .getSurface())); vRdata.addElement(new Float (solid .getVolume())); } SolidDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } } else if(jRadioButton4.isSelected()){ jTable1.setModel(cuboidDtm); String s; s=jComboBox1.getSelectedItem().toString(); if (s.equals("长方体")){ result = require.showCoboidPlaneSolid(); if (!result.hasMoreElements()) { cuboidDtm.setRowCount(0); JOptionPane.showMessageDialog(this,"对不起,没有这个体","confirm",JOptionPane.PLAIN_MESSAGE); session.endSession(); } else { cuboidDtm.setRowCount(0); cuboidDtm.addRow(cuboidVCdata); int j=0; while (result.hasMoreElements()) { CuboidPlaneSolid cuboidPlaneSolid = (CuboidPlaneSolid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<cuboidVCdata.size();i++) { vRdata.addElement(new Integer(j)); // vRdata.addElement(""+i); vRdata.addElement(session.getOidAsString(cuboidPlaneSolid)); vRdata.addElement(cuboidPlaneSolid.getName()); vRdata.addElement(new Float (cuboidPlaneSolid .getLength())); vRdata.addElement(new Float (cuboidPlaneSolid .getWidth())); vRdata.addElement(new Float (cuboidPlaneSolid .getHigh())); vRdata.addElement(new Float (cuboidPlaneSolid .getSurface())); vRdata.addElement(new Float (cuboidPlaneSolid .getVolume())); } cuboidDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } } else if(s.equals("立方体")){ jTable1.setModel(squareDtm); jTable1.setModel(squareDtm); //设定表模式 result = require.showSquarePlaneSolid(); if (!result.hasMoreElements()) { squareDtm.setRowCount(0); JOptionPane.showMessageDialog(this,"对不起, 现在还没有立方体","confirm",JOptionPane.PLAIN_MESSAGE); session.endSession(); } else { squareDtm.setRowCount(0); squareDtm.addRow(squareVCdata); int j=0; while (result.hasMoreElements()) { SquarePlaneSolid squarePlaneSolid = (SquarePlaneSolid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<squareVCdata.size();i++) { vRdata.addElement(new Integer(j)); //vRdata.addElement(""+i); vRdata.addElement(session.getOidAsString(squarePlaneSolid)); vRdata.addElement(squarePlaneSolid .getName()); vRdata.addElement(new Float (squarePlaneSolid .getLength())); vRdata.addElement(new Float (squarePlaneSolid .getSurface())); vRdata.addElement(new Float (squarePlaneSolid .getVolume())); } squareDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } } else if (s.equals("圆柱体")){ jTable1.setModel(cylinderDtm); result = require.showCylinderCurveSolid(); if (!result.hasMoreElements()) { cylinderDtm.setRowCount(0); JOptionPane.showMessageDialog(this,"对不起,没有这个体","confirm",JOptionPane.PLAIN_MESSAGE); session.endSession(); } else { cylinderDtm.setRowCount(0); cylinderDtm.addRow(cylinderVCdata); int j=0; while (result.hasMoreElements()) { CylinderCurveSolid cylinderCurveSolid = (CylinderCurveSolid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<cylinderVCdata.size();i++) { vRdata.addElement(new Integer(j)); //vRdata.addElement(""+i); vRdata.addElement(session.getOidAsString(cylinderCurveSolid)); vRdata.addElement(cylinderCurveSolid .getName()); vRdata.addElement(new Float (cylinderCurveSolid .getHigh())); vRdata.addElement(new Float (cylinderCurveSolid .getRadius())); vRdata.addElement(new Float (cylinderCurveSolid .getSurface())); vRdata.addElement(new Float (cylinderCurveSolid .getVolume())); } cylinderDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } }else if (s.equals("圆锥体")){ jTable1.setModel(coneDtm); result = require.showConeCurveSolid(); if (!result.hasMoreElements()) { coneDtm.setRowCount(0); JOptionPane.showMessageDialog(this,"对不起,没有这个体","confirm",JOptionPane.PLAIN_MESSAGE); session.endSession(); } else { coneDtm.setRowCount(0); coneDtm.addRow(coneVCdata); int j=0; while (result.hasMoreElements()) { ConeCurveSolid coneCurveSolid = (ConeCurveSolid) result.nextElement(); Vector vRdata=new Vector(); for(int i=0;i<coneVCdata.size();i++) { vRdata.addElement(new Integer(j)); // vRdata.addElement(""+i); vRdata.addElement(session.getOidAsString(coneCurveSolid)); vRdata.addElement(coneCurveSolid.getName()); vRdata.addElement(new Float (coneCurveSolid .getHigh())); vRdata.addElement(new Float(coneCurveSolid .getRadius())); vRdata.addElement(new Float (coneCurveSolid .getSurface())); vRdata.addElement(new Float (coneCurveSolid .getVolume())); } coneDtm.addRow(vRdata); //向表中添家数据 j++; } session.endSession(); } }else if (s.equals("球体")){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -