Ejemplo n.º 1
0
  /**
   * 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);
  }
Ejemplo n.º 2
0
  /** Create the entire GUI from scratch */
  private void createGUI() {

    clientFrame = new JFrame("LeetFTP");

    // Allow program to exit gracefully

    clientFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    createTabs();
    createMenu();

    // Top Options Bar
    connectButton = new JButton("Connect");
    connectButton.addMouseListener(mouseHandler);

    optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    optionPanel.add(connectButton);
    optionPanel.add(new JLabel("Name Server Hostname"));
    optionPanel.add(serverTextField);
    optionPanel.add(new JLabel("Port #"));
    optionPanel.add(portTextField);
    optionPanel.add(new JLabel("UserName"));
    optionPanel.add(nameTextField);

    // Bottom Transfer Table

    transferTable = new JTable();
    transferPanel = new JPanel(new BorderLayout());
    transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH);
    transferPanel.add(transferTable);

    // Make the tab pane the GUI pane
    clientFrame.getContentPane().setLayout(new BorderLayout());
    clientFrame.getContentPane().add(mainPanel);
    clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH);
    clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH);

    // Set Client Window Properties
    clientFrame.setSize(800, 600);
    // clientFrame.setResizable(false);
    clientFrame.setLocationRelativeTo(null);
    clientFrame.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);
    }
  }
Ejemplo n.º 4
0
 public void create() {
   JFrame frame = new JFrame();
   frame.getContentPane().add(new JScrollPane(jgraph));
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Ejemplo n.º 5
0
  public void pdfRead() {
    try {
      String INPUTFILE = "example_2.pdf";
      File file = new File(INPUTFILE);
      RandomAccessFile raf = new RandomAccessFile(file, "r");
      FileChannel channel = raf.getChannel();
      ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
      PDFFile pdffile = new PDFFile(buf);

      // draw the first page to an image
      PDFPage page = pdffile.getPage(0);

      // get the width and height for the doc at the default zoom
      Rectangle rect =
          new Rectangle(0, 0, (int) page.getBBox().getWidth(), (int) page.getBBox().getHeight());

      // generate the image
      Image img =
          page.getImage(
              rect.width,
              rect.height, // width & height
              rect, // clip rect
              null, // null for the ImageObserver
              true, // fill background with white
              true // block until drawing is done
              );

      frame.getContentPane().add(new JLabel(new ImageIcon(img)));

      frame.pack();
      frame.setSize(600, 700);
    } catch (Exception e) {
      System.out.println(e);
    }
  }
  /** 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);
  }
Ejemplo n.º 7
0
  public void mustMakeChoice() {
    final JFrame frame = new JFrame("Must specify one option");

    JPanel panel = new JPanel();
    JLabel exitLabel = new JLabel("Must specify one option");
    JButton okButton = new JButton("Continue");
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            frame.dispose();
          }
        });

    panel.setBorder(
        BorderFactory.createEmptyBorder(
            30, // top
            30, // left
            10, // bottom
            30) // right
        );
    panel.setLayout(new GridLayout(0, 1));

    panel.add(exitLabel);
    panel.add(okButton);
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
  }
  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);
  }
Ejemplo n.º 9
0
  // Add a test case to testBox and tests array.
  private void addTest() {

    // Set up the frame for the file chooser.
    final JFrame appframe = new JFrame("Select Application");
    appframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Container contentPane = appframe.getContentPane();
    JFileChooser fileChooser = new JFileChooser(".");

    // Only let you select directories and add chooser to pane.
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    contentPane.add(fileChooser, BorderLayout.CENTER);

    // Make a new action listener for the file chooser.
    ActionListener actionListener =
        new ActionListener() {

          public void actionPerformed(ActionEvent actionEvent) {

            // Get the information to check if the file chosen is valid.
            JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource();
            String command = actionEvent.getActionCommand();

            // If the user cancels selecting a program.
            if (command.equals(JFileChooser.CANCEL_SELECTION)) {
              appframe.setVisible(false);
              appframe.dispose();
              return;
            }

            // If the file chosen is valid.
            if (command.equals(JFileChooser.APPROVE_SELECTION)) {
              // Retrieve the selected file and ask for the main class name.
              File f = theFileChooser.getSelectedFile();

              // Obtain the file URL.
              String fileURL = null;
              fileURL = f.getAbsolutePath();

              // Add a checkbox to the testing check pane.
              JCheckBox newTest = new JCheckBox(fileURL, true);
              testBox.setEditable(true);
              testBox.add(newTest);
              testBox.repaint();
              testBox.setEditable(false);
              // Add the test to the list of tests.
              tests.add(newTest);

              // Make the file chooser disappear.
              appframe.setVisible(false);
              appframe.dispose();
            }
          }
        };

    // Add the action listener created above to file chooser, display it.
    fileChooser.addActionListener(actionListener);
    appframe.pack();
    appframe.setVisible(true);
  }
Ejemplo n.º 10
0
 GraphPanel(JFrame newFrame) {
   frame = newFrame;
   panel = new GraphicPanel();
   panel.setDisplayPlot(false);
   datapanel = new DataPanel(frame);
   panel.setDataPanel(datapanel);
   frame.getContentPane().add(panel, "Center");
 }
Ejemplo n.º 11
0
  // Constructor
  public FileWindow() {

    myWindow = new JFrame("New File");
    myWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Container contentPane = myWindow.getContentPane();
    contentPane.setLayout(new BorderLayout());

    saveButton = new JButton("Save File");
    saveButton.setSelected(false);
    saveButton.setActionCommand("save");
    saveButton.setMnemonic('S');
    // saveButton.addActionListener(new ScriptWindowButtonListener());

    clearButton = new JButton("Clear Contents");
    clearButton.setSelected(false);
    clearButton.setActionCommand("clear");
    clearButton.setMnemonic('B');
    clearButton.addActionListener(new ScriptWindowButtonListener());

    cancelButton = new JButton("Quit");
    cancelButton.setSelected(false);
    cancelButton.setActionCommand("quit");
    cancelButton.setMnemonic('Q');
    cancelButton.addActionListener(new ScriptWindowButtonListener());

    //		loadButton = new JButton("Load Script");
    //		loadButton.setSelected(false);
    //		loadButton.setActionCommand("load");
    //		loadButton.setMnemonic('L');
    //		loadButton.addActionListener(new ScriptWindowButtonListener());
    //
    //		runButton = new JButton("Run Script");
    //		runButton.setSelected(false);
    //		runButton.setActionCommand("run");
    //		runButton.setMnemonic('L');
    //		runButton.addActionListener(new ScriptWindowButtonListener());

    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(1, 0));
    // buttonPanel.add(runButton);
    buttonPanel.add(saveButton);
    // buttonPanel.add(loadButton);
    buttonPanel.add(clearButton);
    // buttonPanel.add(cancelButton);

    fileChooser = new JFileChooser();

    scriptArea = new JTextArea(35, 30);
    JScrollPane scroller = new JScrollPane(scriptArea);

    textHolder = new JPanel();
    textHolder.setLayout(new BorderLayout());
    textHolder.add(scroller, BorderLayout.CENTER);

    contentPane.add(buttonPanel, BorderLayout.NORTH);
    contentPane.add(textHolder, BorderLayout.CENTER);
    myWindow.pack();
  }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
  public static void main(String[] args) {
    Chart shc = new Chart("C:/TEMP/table.csv");

    JFrame frame = new JFrame("Stock History Chart for " + shc.getSymbol());
    frame.getContentPane().add(shc, BorderLayout.CENTER);
    frame.setSize(640, 480);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Ejemplo n.º 14
0
 // creates the JFrame, and puts first room onto panel
 public static void main(String[] s) throws IOException {
   JFrame f = new JFrame();
   f.getContentPane().add(new Adventure());
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.pack();
   f.setVisible(true);
   Environment Layout = new Environment();
   wallLayout = Layout.walls(mapX, mapY);
 }
Ejemplo n.º 15
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Plot");
    frame.getContentPane().setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel commandPanel = new JPanel(new FlowLayout());
    JButton openButton = new JButton("Open  Ctrl-O");
    JButton plotButton = new JButton("Plot  Ctrl-P");
    JButton quitButton = new JButton("Quit  Ctrl-Q");
    quitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    commandPanel.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        },
        KeyStroke.getKeyStroke("control Q"),
        JComponent.WHEN_IN_FOCUSED_WINDOW);
    commandPanel.add(openButton);
    commandPanel.add(plotButton);
    commandPanel.add(quitButton);
    frame.getContentPane().add(commandPanel, "North");

    GraphPanel graphpanel = new GraphPanel(frame);
    plotButton.addActionListener(graphpanel);
    commandPanel.registerKeyboardAction(
        graphpanel, KeyStroke.getKeyStroke("control P"), JComponent.WHEN_IN_FOCUSED_WINDOW);

    openButton.addActionListener(graphpanel.getDataPanel());
    commandPanel.registerKeyboardAction(
        graphpanel.getDataPanel(),
        KeyStroke.getKeyStroke("control O"),
        JComponent.WHEN_IN_FOCUSED_WINDOW);

    frame.setVisible(true);
    frame.pack();
  }
Ejemplo n.º 16
0
  /** EdiDialog constructor comment. */
  public static void test() {
    JFrame frame = new JFrame();
    frame.addWindowListener(new CloseSaveWindowsListener());
    frame.setBackground(ConfigurableSystemSettings.backgroundColor.getAWTColor());
    frame.getContentPane().setLayout(new java.awt.BorderLayout());
    frame.setBounds(50, 50, 400, 400);
    frame.show();

    DialogNewElement dialog = new DialogNewElement(frame);
    dialog.show();
  }
Ejemplo n.º 17
0
 /** This method sets up the window and displays it. */
 private void setupFrame() {
   JFrame window = new JFrame("Dungeon of Dooom");
   window.setIconImage(Toolkit.getDefaultToolkit().getImage("graphics/icon.png"));
   window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   populateFrame(window.getContentPane());
   window.pack();
   window.setLocationByPlatform(true);
   window.setVisible(true);
   Dimension windowSize = new Dimension(608, 606);
   window.setSize(windowSize);
   window.setResizable(false);
 }
Ejemplo n.º 18
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();
  }
Ejemplo n.º 19
0
 private void showIDE(boolean show) {
   SikuliIDE.getInstance().setVisible(show);
   if (show) {
     addMinComponentsToPane(mainPane);
   } else {
     addMinComponentsToPane(minPane);
     Container con = minFrame.getContentPane();
     con.add(minPane);
     minFrame.doLayout();
   }
   minFrame.setVisible(!show);
 }
Ejemplo n.º 20
0
 public void go() {
   JFrame frame = new JFrame("JFrame");
   JPanel mainPanel = new JPanel();
   outgoing = new JTextField(20);
   JButton sendButton = new JButton("send");
   sendButton.addActionListener(new SendButtonListener());
   mainPanel.add(outgoing);
   mainPanel.add(sendButton);
   frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
   setUpNetworking();
   frame.setSize(400, 500);
   frame.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);
  }
Ejemplo n.º 22
0
  /**
   * opens the chosen file, reads in the file, and prints out a receipt
   *
   * @param chosenFile
   */
  private void readSource(File chosenFile) {
    String chosenFileName = chosenFile.getName();
    TextFileInput inFile = new TextFileInput(chosenFileName);
    Container myContentPane = jframe.getContentPane();
    // chosenFile TextArea myTextArea = new TextArea();
    myContentPane.add(myTextArea);

    int count = 0;
    float priceTotal = 0.0f;
    Database db = new Database("database2.txt");
    String[] transaction = new String[100];
    String line = inFile.readLine();
    DecimalFormat df = new DecimalFormat("#00.00");
    while (line != null) {
      StringTokenizer tokenized = new StringTokenizer(line, ",");
      String code = tokenized.nextToken();
      float weight = Float.parseFloat(tokenized.nextToken());
      String name;
      float price;

      try {
        name = db.getName(code);

      } catch (ItemNotFoundException e) {
        name = JOptionPane.showInputDialog(null, "Item " + code + " not found. Enter Name: ");
      }
      try {
        price = db.getPrice(code);
      } catch (ItemNotFoundException e) {
        price =
            Float.valueOf(
                JOptionPane.showInputDialog(
                    null, "Price for " + name + " not found. Enter price: "));
      }
      float itemTotal = weight * price;
      priceTotal += itemTotal;
      transaction[count] =
          name + "\t" + price + "\t" + df.format(weight) + "\t $" + df.format(itemTotal);
      count++;
      line = inFile.readLine();
    } // while
    myTextArea.setText("ITEM: \t PRICE\\LB: \t POUNDS: \t TOTAL:");
    myTextArea.append("\n");
    for (int i = 0; i < count; i++) {
      myTextArea.append(transaction[i]);
      myTextArea.append("\n");
    }
    myTextArea.append("\t\t   TOTAL: $" + df.format(priceTotal));
    jframe.setVisible(true);
  } // openFile
Ejemplo n.º 23
0
 public static void main(String[] args) {
   TableModelDemo applet = new TableModelDemo();
   JFrame frame = new JFrame();
   // EXIT_ON_CLOSE == 3
   frame.setDefaultCloseOperation(3);
   frame.setTitle("TableModelDemo");
   frame.getContentPane().add(applet, BorderLayout.CENTER);
   applet.init();
   applet.start();
   frame.setSize(500, 220);
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   frame.setLocation(
       (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
   frame.setVisible(true);
 }
Ejemplo n.º 24
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) {
   }
 }
Ejemplo n.º 26
0
  private void showVideo() throws IOException {
    if (videoFrame == null) {
      videoFrame = new JFrame("Remote Car Video");
      video = new VideoPanel(car.getIp(), car.getCameraPort());
      videoFrame.getContentPane().add(video);
      videoFrame.setResizable(false);
      videoFrame.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
              System.out.println("closing");
              super.windowClosed(e);
              video.disconnect();
              btnCamera.setSelected(false);
            }

            @Override
            public void windowOpened(WindowEvent e) {
              System.out.println("opened");
              super.windowOpened(e);
              try {
                video.connect();
              } catch (MalformedURLException e1) {
                e1.printStackTrace();
              }
              video.play();
            }

            @Override
            public void windowActivated(WindowEvent e) {
              video.play();
            }

            @Override
            public void windowIconified(WindowEvent e) {
              video.pause();
            }
          });
    }
    Point location = this.getLocation();
    Dimension dim = this.getSize();
    videoFrame.setLocation(location.x + dim.width + 2, location.y);
    videoFrame.setVisible(true);
    videoFrame.pack();
    sendCommand(Command.TOGGLE_CAMERA);
  }
Ejemplo n.º 27
0
 public BSInterface() {
   mainFrame.setSize(960, 720);
   mainFrame.setResizable(false);
   mainFrame.setIconImage(Toolkit.getDefaultToolkit().createImage("pic/ticket_16.png"));
   Container contentPane = mainFrame.getContentPane();
   contentPane.setLayout(new BorderLayout());
   contentPane.add(toolPanel, BorderLayout.NORTH);
   contentPane.add(operPanel, BorderLayout.CENTER);
   mainFrame.setContentPane(contentPane);
   mainFrame.setVisible(true);
   mainFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
           // device_close();
           System.exit(0);
         }
       });
 }
Ejemplo n.º 28
0
 @Override
 public void actionPerformed(ActionEvent event) {
   JFrame frame = new JFrame();
   frame.setTitle(
       "The current best solution for " + optimizationParameters.getProblem().getName());
   frame.setSize(400, 300);
   frame.setLocation(450, 250);
   Population pop = optimizationParameters.getOptimizer().getPopulation();
   frame
       .getContentPane()
       .add(
           optimizationParameters
               .getProblem()
               .drawIndividual(
                   pop.getGeneration(), pop.getFunctionCalls(), pop.getBestEAIndividual()));
   frame.validate();
   frame.setVisible(true);
 }
Ejemplo n.º 29
-1
  public void go() {
    frame = new JFrame("Quiz Card Player");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);

    display = new JTextArea(10, 20);
    display.setFont(bigFont);
    display.setLineWrap(true);
    display.setEditable(false);

    JScrollPane qScroller = new JScrollPane(display);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    nextButton = new JButton("Show Questions");
    nextButton.addActionListener(new NextCardListener());

    mainPanel.add(qScroller);
    mainPanel.add(nextButton);

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem loadMenuItem = new JMenuItem("Load Card Set");
    loadMenuItem.addActionListener(new OpenMenuListener());
    fileMenu.add(loadMenuItem);
    menuBar.add(fileMenu);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(640, 500);
    frame.setVisible(true);
  }
Ejemplo n.º 30
-1
  public void go() {
    // build gui

    frame = new JFrame("Quiz Card Buider");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);
    question = new JTextArea(6, 20);
    question.setLineWrap(true);
    question.setWrapStyleWord(true);
    question.setFont(bigFont);

    JScrollPane qScroller = new JScrollPane(question);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    answer = new JTextArea(6, 20);
    answer.setLineWrap(true);
    answer.setWrapStyleWord(true);
    answer.setFont(bigFont);

    JScrollPane aScroller = new JScrollPane(question);
    aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    JButton nextButton = new JButton("Next Card");

    cardList = new ArrayList<QuizCard>();

    JLabel qLabel = new JLabel("Question");
    JLabel aLabel = new JLabel("Answer");

    mainPanel.add(qLabel);
    mainPanel.add(qScroller);
    mainPanel.add(aLabel);
    mainPanel.add(aScroller);
    mainPanel.add(nextButton);

    nextButton.addActionListener(new NextCardListener());

    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");

    JMenuItem newMenuItem = new JMenuItem("New");
    JMenuItem saveMenuItem = new JMenuItem("Save");
    newMenuItem.addActionListener(new NewMenuListener());
    saveMenuItem.addActionListener(new SaveMenuListener());

    fileMenu.add(newMenuItem);
    fileMenu.add(saveMenuItem);
    menuBar.add(fileMenu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(500, 600);
    frame.setVisible(true);
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  }