Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package demoguicomsol;
- import com.comsol.model.Model;
- import com.comsol.model.util.*;
- import com.comsol.modelguiswing.SwingGraphicsPanel;
- import java.awt.*;
- import javax.swing.*;
- import java.lang.*;
- /**
- *
- * @author andres
- */
- public class DemoGuiComsol {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- DemoGuiComsol demo = new DemoGuiComsol();
- demo.init();
- demo.start();
- }
- private Model model;
- private JFrame frame;
- public void init() {
- try{
- ModelUtil.connect("localhost", 2036);
- }
- catch(java.lang.Throwable t) {
- System.out.println( t.getClass().getName() ); //this'll tell you what class has been thrown
- t.printStackTrace(); //get a stack trace
- }
- //ModelUtil.initStandalone(true);
- }
- public void start() {
- frame = new JFrame("Beam GUI - based on COMSOL Multiphysics");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(1000, 730);
- JPanel mainPanel = new JPanel();
- frame.getContentPane().add(mainPanel);
- mainPanel.setLayout(new BorderLayout());
- model = BeamModel.run();
- model.sol("sol1").runAll();
- model.result("pg1").set("window", "window1");
- model.result("pg1").run();
- try{
- SwingGraphicsPanel graphicsPanel =
- new SwingGraphicsPanel("window1", "Window1");
- mainPanel.add(graphicsPanel, BorderLayout.CENTER);
- }
- catch(java.lang.Throwable t) {
- System.out.println( t.getClass().getName() ); //this'll tell you what class has been thrown
- t.printStackTrace();
- }
- frame.setVisible(true);
- ModelUtil.disconnect();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment