public ScaleMainFrame() {
    super(new BorderLayout());

    nameTF = new JTextField();
    JPanel top = new JPanel(new BorderLayout());
    top.add(new JLabel("Scale Name:"), BorderLayout.WEST);
    top.add(nameTF, BorderLayout.CENTER);

    PlayButton pb = new PlayButton("PLAY");
    tempoP = new IntSetPanel(1, 10000, "Tempo");
    tempoP.setValue(120);
    JPanel botL = new JPanel(new BorderLayout());
    botL.add(pb, BorderLayout.EAST);
    botL.add(tempoP, BorderLayout.CENTER);
    PianoKeyB kb = new PianoKeyB();
    kb.setPreferredSize(new Dimension(150, 40));
    // JPanel botTop = new JPanel(new GridLayout(1, 2));
    JPanel botTop = new JPanel(new FlowLayout());
    botTop.add(botL);
    botTop.add(kb);

    JButton newB = new JButton("New");
    saveB = new JButton("Save");
    JButton loadB = new JButton("Load");
    newB.addActionListener(this);
    saveB.addActionListener(this);
    loadB.addActionListener(this);
    pb.addActionListener(this);
    JPanel botBot = new JPanel(new GridLayout(1, 3));
    botBot.add(newB);
    botBot.add(saveB);
    botBot.add(loadB);
    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(botTop, BorderLayout.CENTER);
    bottom.add(botBot, BorderLayout.SOUTH);

    sp = new ScalePanel(this, kb);

    add(top, BorderLayout.NORTH);
    add(sp, BorderLayout.CENTER);
    add(bottom, BorderLayout.SOUTH);
    setPreferredSize(new Dimension(500, 300));

    fileChooser = new JFileChooser(new File("Features/Scales"));
    filter = new ScaleFilter();
    fileChooser.addChoosableFileFilter(filter);
    fileChooser.setFileFilter(filter);
  }
Exemplo n.º 2
0
  // creates a file open dialog. If you don't cancel it opens that file.
  public void OpenFileDialog() {
    // Note: source for ExampleFileFilter can be found in FileChooserDemo,
    // under the demo/jfc directory in the Java 2 SDK, Standard Edition.
    String filename = (recentFiles[0].length() > 0) ? filename = recentFiles[0] : "";

    FileFilter filterImage =
        new FileNameExtensionFilter(
            "Images (jpg/bmp/png/gif)", "jpg", "jpeg", "png", "wbmp", "bmp", "gif");
    FileFilter filterGCODE = new FileNameExtensionFilter("GCODE files (ngc)", "ngc");

    JFileChooser fc = new JFileChooser(new File(filename));
    fc.addChoosableFileFilter(filterImage);
    fc.addChoosableFileFilter(filterGCODE);
    if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      OpenFileOnDemand(fc.getSelectedFile().getAbsolutePath());
    }
  }