Example #1
0
  public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {

    JFrame jf = new JFrame();

    AttributesPanel colpal = new AttributesPanel();
    colpal.setEntity(new FrameFact("hola"));
    colpal.setEntity(new FrameFact("hola"));
    jf.getContentPane().add(colpal);
    jf.pack();
    jf.show();
    jf.pack();
  }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
  private void initGUI() {

    JPanel pCommand = new JPanel();

    pResult = new JPanel();
    nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult);

    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new JTextArea(5, 40);

    txtCommand.setMargin(new Insets(5, 5, 5, 5));
    txtCommand.addKeyListener(this);

    txtCommandScroll = new JScrollPane(txtCommand);
    txtResult = new JTextArea(20, 40);

    txtResult.setMargin(new Insets(5, 5, 5, 5));

    txtResultScroll = new JScrollPane(txtResult);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
    /*
    // button replaced by toolbar
            butExecute = new JButton("Execute");

            butExecute.addActionListener(this);
            pCommand.add(butExecute, BorderLayout.EAST);
    */
    pCommand.add(txtCommandScroll, BorderLayout.CENTER);

    gResult = new GridSwing();
    gResultTable = new JTable(gResult);
    gScrollPane = new JScrollPane(gResultTable);

    // getContentPane().setLayout(new BorderLayout());
    pResult.add(gScrollPane, BorderLayout.CENTER);

    // Set up the tree
    rootNode = new DefaultMutableTreeNode("Connection");
    treeModel = new DefaultTreeModel(rootNode);
    tTree = new JTree(treeModel);
    tScrollPane = new JScrollPane(tTree);

    tScrollPane.setPreferredSize(new Dimension(120, 400));
    tScrollPane.setMinimumSize(new Dimension(70, 100));
    txtCommandScroll.setPreferredSize(new Dimension(360, 100));
    txtCommandScroll.setMinimumSize(new Dimension(180, 100));
    gScrollPane.setPreferredSize(new Dimension(460, 300));

    ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane);

    fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
    doLayout();
    fMain.pack();
  }
  public void launchTrajectoryRenderer() {

    Visualizer tv = this.getTrajectoryRenderLayerBase();
    List<EpisodeAnalysis> trajectories =
        EpisodeAnalysis.parseFilesIntoEAList(this.expertDir, this.domain, this.sp);
    TrajectoryRenderer tr =
        new TrajectoryRenderer(
            trajectories,
            GridWorldDomain.CLASSAGENT,
            GridWorldDomain.ATTX,
            GridWorldDomain.ATTY,
            new double[] {0, 30, .5},
            new double[] {0, 30, .5},
            3.f,
            10.f);
    tv.addRenderLayer(tr);

    tv.updateState(trajectories.get(0).getState(0));

    JFrame frame = new JFrame();
    frame.setPreferredSize(new Dimension(800, 800));
    frame.getContentPane().add(tv);
    frame.pack();
    frame.setVisible(true);
  }
  public static void main(String[] args) {
    ArrayList<Pattern> patterns = new ArrayList<Pattern>();
    ArrayList<Cut> cuts;
    ArrayList<Garment> garments;

    patterns.add(new Pattern(2, 2, 1, "Tie"));
    patterns.add(new Pattern(2, 6, 4, "Skirt"));
    patterns.add(new Pattern(4, 2, 3, "Blouse"));
    patterns.add(new Pattern(5, 3, 5, "Dress"));
    int width = 30;
    int height = 15;
    ClothCutter cutter = new ClothCutter(width, height, patterns);
    System.out.println("Optimized value: " + cutter.optimize());
    cuts = cutter.getCuts();
    garments = cutter.getGarments();

    ClothPanel panel = new ClothPanel(width, height);
    JFrame frame = new JFrame("A luxurious bolt of fabric");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
    sleep(1000);
    for (int i = 0; i < cuts.size(); i++) {
      panel.drawCut(cuts.get(i));
      sleep(100);
    }
    for (int i = 0; i < garments.size(); i++) {
      System.out.println(garments.get(i));
      panel.drawGarment(garments.get(i));
      sleep(100);
    }
  }
  /** Simple test program. */
  public static void main(String[] args) {
    final JFrame frame = new JFrame("Testing AddPersonDialog");
    JButton button = new JButton("Click me");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            FamilyTree tree = new FamilyTree();
            AddPersonDialog dialog = new AddPersonDialog(frame, tree);
            dialog.pack();
            dialog.setLocationRelativeTo(frame);
            dialog.setVisible(true);

            Person newPerson = dialog.getPerson();
            if (newPerson != null) {
              tree.addPerson(newPerson);
              PrettyPrinter pretty = new PrettyPrinter(new PrintWriter(System.out, true));
              pretty.dump(tree);
            }
          }
        });
    frame.getContentPane().add(button);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(1);
          }
        });
    frame.pack();
    frame.setVisible(true);
  }
  /**
   * Init JWhiteBoard interface
   *
   * @throws Exception
   */
  public void go() throws Exception {
    if (!noChannel && !useState) channel.connect(groupName);
    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    drawPanel = new DrawPanel(useState);
    drawPanel.setBackground(backgroundColor);
    subPanel = new JPanel();
    mainFrame.getContentPane().add("Center", drawPanel);
    clearButton = new JButton("Clean");
    clearButton.setFont(defaultFont);
    clearButton.addActionListener(this);
    leaveButton = new JButton("Exit");
    leaveButton.setFont(defaultFont);
    leaveButton.addActionListener(this);
    subPanel.add("South", clearButton);
    subPanel.add("South", leaveButton);
    mainFrame.getContentPane().add("South", subPanel);
    mainFrame.setBackground(backgroundColor);
    clearButton.setForeground(Color.blue);
    leaveButton.setForeground(Color.blue);
    mainFrame.pack();
    mainFrame.setLocation(15, 25);
    mainFrame.setBounds(new Rectangle(250, 250));

    if (!noChannel && useState) {
      channel.connect(groupName, null, stateTimeout);
    }
    mainFrame.setVisible(true);
  }
 public void create() {
   JFrame frame = new JFrame();
   frame.getContentPane().add(new JScrollPane(jgraph));
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Example #9
0
  private void _displayRespStrInFrame() {

    final JFrame frame = new JFrame("Google Static Map - Error");
    GUIUtils.setAppIcon(frame, "69.png");
    // frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JTextArea response = new JTextArea(_respStr, 25, 80);
    response.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {
            /*frame.dispose();*/
          }

          public void mouseReleased(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}
        });

    frame.setContentPane(new JScrollPane(response));
    frame.pack();

    GUIUtils.centerOnScreen(frame);
    frame.setVisible(true);
  }
Example #10
0
 /** Builds a BarChartGenerator and attaches it as a display in a MASON simulation. */
 public static BarChartGenerator buildBarChartGenerator(GUIState state, String title) {
   BarChartGenerator chart = buildBarChartGenerator(title);
   JFrame frame = chart.createFrame();
   frame.setVisible(true);
   frame.pack();
   state.controller.registerFrame(frame);
   return chart;
 }
Example #11
0
 /** Builds a ScatterPlotGenerator and attaches it as a display in a MASON simulation. */
 public static ScatterPlotGenerator buildScatterPlotGenerator(
     GUIState state, String title, String rangeAxisLabel, String domainAxisLabel) {
   ScatterPlotGenerator chart = buildScatterPlotGenerator(title, rangeAxisLabel, domainAxisLabel);
   JFrame frame = chart.createFrame();
   frame.setVisible(true);
   frame.pack();
   state.controller.registerFrame(frame);
   return chart;
 }
Example #12
0
 public static void main(String[] argv) throws NoSuchMethodException {
   f = new JFrame();
   Container c = f.getContentPane();
   c.setLayout(new BorderLayout());
   c.add(new WordListScreen(null), BorderLayout.CENTER);
   f.pack();
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   showFrame(true);
 }
Example #13
0
 /** Builds a TimeSeriesChartGenerator and attaches it as a display in a MASON simulation. */
 public static TimeSeriesChartGenerator buildTimeSeriesChartGenerator(
     GUIState state, String title, String domainAxisLabel) {
   TimeSeriesChartGenerator chart = buildTimeSeriesChartGenerator(title, domainAxisLabel);
   JFrame frame = chart.createFrame();
   frame.setVisible(true);
   frame.pack();
   state.controller.registerFrame(frame);
   return chart;
 }
Example #14
0
 /**
  * You can ignore this method. This method gets called by the subclass's constructor when it has
  * finished initializing, but that call is already written in <code>MyGame.java</code>.
  */
 protected void ready() {
   if (applet) {
     add(canvas);
   } else {
     frame.add(canvas);
     frame.pack();
     frame.setLocationRelativeTo(null);
     frame.setResizable(false);
     frame.setVisible(true);
   }
 }
Example #15
0
 /**
  * Create a Canvas.
  *
  * @param title title to appear in Canvas Frame
  * @param width the desired width for the canvas
  * @param height the desired height for the canvas
  * @param bgClour the desired background colour of the canvas
  */
 private Canvas(String title, int width, int height, Color bgColour) {
   frame = new JFrame();
   canvas = new CanvasPane();
   frame.setContentPane(canvas);
   frame.setTitle(title);
   canvas.setPreferredSize(new Dimension(width, height));
   backgroundColour = bgColour;
   frame.pack();
   objects = new ArrayList<Object>();
   shapes = new HashMap<Object, ShapeDescription>();
 }
Example #16
0
  // creates a frame with a new TreeDisplay component.
  // (constructor returns the TreeDisplay component--not the frame).
  public TreeDisplay() {
    // create surrounding frame
    JFrame frame = new JFrame("Tree Display");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // add the TreeDisplay component to the frame
    frame.getContentPane().add(this);

    // show frame
    frame.pack();
    frame.setVisible(true);
  }
Example #17
0
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {

    // Create and set up the window.
    JFrame frame = new JFrame("SplitPaneDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    SplitPaneDemo splitPaneDemo = new SplitPaneDemo();
    frame.getContentPane().add(splitPaneDemo.getSplitPane());

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
Example #18
0
 public void add() {
   mainFrame.setDefaultCloseOperation(mainFrame.EXIT_ON_CLOSE);
   statusPanel.add(jl);
   menuBar.add(menu);
   menu.add(menuItem);
   menuItem.addActionListener(this);
   container.setLayout(new BorderLayout());
   container.add(menuBar, BorderLayout.NORTH);
   container.add(jl, BorderLayout.SOUTH);
   mainFrame.pack();
   mainFrame.setVisible(true);
 }
Example #19
0
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the event
   * dispatch thread.
   */
  private static void showGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("CaliKing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Add contents to the window.
    frame.add(new MakeReservation());

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
Example #20
0
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the event
   * dispatch thread.
   */
  private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("FileChooserDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Add content to the window.
    frame.add(new DirectorySize());

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
 public static void main(String[] args) {
   MojamComponent mc = new MojamComponent();
   JFrame frame = new JFrame();
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(mc);
   frame.setContentPane(panel);
   frame.pack();
   frame.setResizable(false);
   frame.setLocationRelativeTo(null);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
   mc.start();
 }
  public static void main(String[] args) throws Exception {
    JFrame f = new JFrame();

    CalModel cm = new CalModel(TimeZone.getDefault(), true);

    JCalendar jc = new JCalendarDateHHMM();
    jc.setModel(cm);
    f.getContentPane().add((javax.swing.JPanel) jc);

    f.setSize(400, 400);
    f.pack();
    f.setVisible(true);
  }
  public static void main(String s[]) {

    // Getting save directory
    String saveDir;
    if (s.length > 0) {
      saveDir = s[0];
    } else {
      saveDir =
          JOptionPane.showInputDialog(
              null,
              "Please enter directory where "
                  + "the images is/will be saved\n\n"
                  + "Also possible to specifiy as argument 1 when "
                  + "running this program.",
              "l:\\webcamtest");
    }

    String layout = "";
    if (s.length > 1) {
      layout = s[1];
    }

    // Move mouse to the point 5000,5000 px (out of the screen)
    Robot rob;
    try {
      rob = new Robot();
      rob.setAutoDelay(500); // 0,5 s
      rob.mouseMove(5000, 5000);
    } catch (AWTException e) {
      e.printStackTrace();
    }

    // Make the main window
    JFrame frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setTitle(
        "Webcam capture and imagefading - "
            + "Vitenfabrikken Jærmuseet - "
            + "made by Hallvard Nygård - "
            + "Vitenfabrikken.no / Jaermuseet.no");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setUndecorated(true);

    WebcamCaptureAndFadePanel panel = new WebcamCaptureAndFadePanel(saveDir, layout);
    frame.getContentPane().add(panel);
    frame.addKeyListener(panel);
    frame.pack();

    frame.setVisible(true);
  }
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("ListSelectionDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    ListSelectionDemo demo = new ListSelectionDemo();
    demo.setOpaque(true);
    frame.setContentPane(demo);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
Example #25
0
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("ComboBoxDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    JComponent newContentPane = new ComboBoxDemo2();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
  // Constructor
  public ProcessRentalView() {
    this.f = new JFrame("Process Rental");
    f.pack();
    p = new JPanel();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int height = screenSize.height;
    int width = screenSize.width;
    f.setSize(width / 2, height / 2);

    f.setLocationRelativeTo(null);
    fl = new FlowLayout(FlowLayout.CENTER);
    idLabel = new JLabel("Item ID: ");
    idTextField = new JTextField(5);
    quantityLabel = new JLabel("Quantity: ");
    quantityTextField = new JTextField(5);
    dateLabel = new JLabel("Date(MM/DD/YYYY): ");
    dateTextField = new JTextField(8);
    dateTextField.setText("");
    totalItemsLabel = new JLabel("Items:");
    totalItems = new JTextArea("");
    totalItems.setEditable(false);
    totalItems.setColumns(10);
    totalItems.setRows(12);
    totalCostLabel = new JLabel("Total Cost:");
    totalCost = new JTextField(10);
    totalCost.setEditable(false);

    addButton = new JButton("Add Item");
    exitButton = new JButton("Exit");
    checkoutButton = new JButton("Checkout");
    p.add(idLabel);
    p.add(idTextField);
    p.add(quantityLabel);
    p.add(quantityTextField);
    p.add(dateLabel);
    p.add(dateTextField);
    p.add(addButton);
    p.add(exitButton);
    p.add(totalItemsLabel);
    p.add(totalItems);
    p.add(totalCostLabel);
    p.add(totalCost);
    p.add(checkoutButton);
    p.setLayout(fl);

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(p);
    f.setVisible(true);
  }
Example #27
0
  public void play(int lv) {
    jl.setText("Level " + level);
    Game game = new Game(lv); // An object representing the game
    View view = new View(game); // An object representing the view of the game
    game.newGame();
    view.print();
    gameBoardPanel = view.mainPanel;
    ButtonPanel buttonPanel = new ButtonPanel(game);
    container.add(buttonPanel, BorderLayout.EAST);
    container.add(gameBoardPanel, BorderLayout.WEST);
    mainFrame.pack();

    // Main game loop
    while (true) {

      view.print();
      gameBoardPanel = view.mainPanel;

      // Win/lose conditions
      if (game.isWin()) {
        view.print();
        gameBoardPanel = view.mainPanel;
        int choice;
        choice = JOptionPane.showConfirmDialog(null, "You win!", "", JOptionPane.OK_OPTION);
        if (choice == JOptionPane.OK_OPTION) {
          level++;
          mainFrame.remove(buttonPanel);
          mainFrame.remove(gameBoardPanel);
          play(level);
        }
      }
      if (game.isLose()) {
        view.print();
        gameBoardPanel = view.mainPanel;
        int choice;
        choice =
            JOptionPane.showConfirmDialog(
                null, "You lose!", "Would you like to play again?", JOptionPane.YES_NO_OPTION);
        if (choice == JOptionPane.YES_OPTION) {
          level = 1;
          mainFrame.remove(buttonPanel);
          mainFrame.remove(gameBoardPanel);
          play(level);
        } else {
          System.exit(0);
        }
      }
    }
  }
Example #28
0
 private static void createAndShowGUI(int nbugs) {
   JFrame f = new JFrame("Swarm Demo");
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   double dt = 0.01;
   int ddt = 20;
   if (nbugs > 20) {
     dt = 0.1;
     ddt = 2;
   }
   Playfield p = new Playfield(nbugs, dt, ddt);
   f.add(p);
   f.pack();
   f.setVisible(true);
   p.start();
 }
Example #29
0
 public static void createAndShowGUI() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (ClassNotFoundException
       | InstantiationException
       | IllegalAccessException
       | UnsupportedLookAndFeelException ex) {
     ex.printStackTrace();
   }
   JFrame frame = new JFrame("@title@");
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.getContentPane().add(new MainPanel());
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
 public static void main(String args[]) {
   if (args.length != 1) {
     System.out.println("Need the name of a cff font.");
     System.exit(0);
   }
   JFrame jf = new JFrame("Font test: " + args[0]);
   try {
     FileInputStream fis = new FileInputStream(args[0]);
     TestType1CFont panel = new TestType1CFont(fis);
     jf.getContentPane().add(panel);
     jf.pack();
     jf.setVisible(true);
     panel.requestFocus();
   } catch (IOException ioe) {
   }
 }