Example #1
0
 public void showContentDialog() {
   if (!locationSetContentDialog) {
     locationSetContentDialog = true;
     LocationUtil.positionTopAlignedToTheRightTo(frame, contentDialog);
   }
   contentDialog.setVisible(true);
 }
Example #2
0
  public void setup(boolean exitOnClose, Content content) {
    frame.setSize(800, 600);
    if (exitOnClose) {
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    frame.setTitle("Live CG");

    GeometryEditor geometryEditor = new GeometryEditor();
    Menu menu = new Menu(this, geometryEditor.getEditPane(), geometryEditor.getEditPane());
    Toolbar toolbar = new Toolbar(geometryEditor.getEditPane(), geometryEditor.getEditPane());

    toolbar.setFloatable(false);

    StatusBar statusBar = new StatusBar();
    StatusBarMouseListener statusBarMouseListener =
        new StatusBarMouseListener(geometryEditor.getEditPane(), statusBar);
    geometryEditor.getEditPane().addMouseListener(statusBarMouseListener);
    geometryEditor.getEditPane().addMouseMotionListener(statusBarMouseListener);

    GridBagConstraints c = new GridBagConstraints();

    JPanel mainPanel = new JPanel(new GridBagLayout());
    frame.setJMenuBar(menu);
    frame.setContentPane(mainPanel);

    c.weightx = 1.0;
    c.fill = GridBagConstraints.BOTH;

    c.gridy = 0;
    c.weighty = 0.0;
    mainPanel.add(toolbar, c);

    c.gridy = 1;
    c.weighty = 1.0;
    mainPanel.add(geometryEditor, c);

    c.gridy = 2;
    c.weighty = 0.0;
    mainPanel.add(statusBar, c);

    frame.setLocationByPlatform(true);
    frame.setVisible(true);

    objectDialog = new ObjectDialog(frame, geometryEditor.getEditPane());
    objectDialog.setSize(300, 300);

    contentDialog = new ContentDialog(frame, geometryEditor.getEditPane());
    contentDialog.setSize(300, 300);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            if (showObjectDialog) {
              showObjectDialog();
            }
            if (showContentDialog) {
              showContentDialog();
            }
          }
        });

    if (content != null) {
      geometryEditor.getEditPane().setContent(content);
    }
  }