извлечь значение из списка после появления числа через определенное время

Что мне кажется: у вас есть

JMenuBar menuBar = new JMenuBar();

JMenu file = new JMenu("File");
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ev) {
            System.exit(0);
    }
});

JMenu headMenu = new JMenu("Heads");

вне определения какого-либо метода, и нет способа вызвать этот код.

Попробуйте следующее:

public class Main extends JFrame{

  //initialize integer height/width values along with declaring 
  //Swing component variables
  private final int W = 500,
                    H = 500;

  private JMenu file, headMenu, bgMenu;
  private JMenuBar menuBar;
  private JMenuItem exitItem;

  //constructor
  public Main(){
    setTitle("Move the Head");
    setSize(W, H);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);

    initializeElements();

  }

  //Initializes the elements, this part is missing from your code above.
  public void initializeElements(){

    menuBar = new JMenuBar();
    file = new JMenu("File");
    exitItem = new JMenuItem("Exit");

    exitItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        System.exit(0);
      }
    });

    headMenu = new JMenu("Heads");
    bgMenu = new JMenu("Backgrounds");

  }

  public static void main( String[] args ) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Main f = new Main();
            f.setVisible(true);
        }
    });
  }
}
-8
задан smci 4 September 2019 в 20:36
поделиться

1 ответ

Может использовать np.roll для нахождения последнего индекса трех последовательных значений.

import numpy as np

idx = ((l == np.roll(l, 1)) & (l == np.roll(l, 2))).cumsum().argmax()

l[idx:]
#[1, 2, 4, 1, 3, 5, 2, 2, 6, 4, 1, 6, 1, 1, 3, 5, 2, 2, 6, 4, 1, 6, 2, 7, 2, 6, 1, 1]
3
ответ дан ALollz 6 September 2019 в 06:13
поделиться
  • 1
    Пропавшие без вести запаздывания paren на первом добавляют, также выходит из строковых границ – Stephen 11 February 2009 в 15:07
Другие вопросы по тегам:

Похожие вопросы: