public void start() { str1 = l1.getItem(2); i1 = l1.getItemCount(); l2.replaceItem("英语", 2); str2 = l3.getSelectedItem(); repaint(); }
/** This method initializes styleList */ private List getStyleList() { if (styleList == null) { styleList = new List(styleListChoices.length); for (String s : styleListChoices) { styleList.add(s); } styleList.setPreferredSize(new Dimension(97, 117)); styleList.select(0); styleList.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { styleIndex = styleList.getSelectedIndex(); if (model.items() != null) { algorithm = algs[styleIndex]; refreshObjects(); } } } }); } return styleList; }
public Dimension preferredSize(int v) { if (fm == null) { List li = (List) target; fm = getFontMetrics(li.getFont()); } Dimension d = minimumSize(v); d.width = Math.max(d.width, getMaxWidth() + 20); return d; }
void drawAllROIs(Graphics g) { RoiManager rm = RoiManager.getInstance(); if (rm == null) { rm = Interpreter.getBatchModeRoiManager(); if (rm != null && rm.getList().getItemCount() == 0) rm = null; } if (rm == null) { // if (showAllList!=null) // overlay = showAllList; showAllROIs = false; repaint(); return; } initGraphics(g, null, showAllColor); Hashtable rois = rm.getROIs(); java.awt.List list = rm.getList(); boolean drawLabels = rm.getDrawLabels(); currentRoi = null; int n = list.getItemCount(); if (IJ.debugMode) IJ.log("paint: drawing " + n + " \"Show All\" ROIs"); if (labelRects == null || labelRects.length != n) labelRects = new Rectangle[n]; if (!drawLabels) showAllList = new Overlay(); else showAllList = null; if (imp == null) return; int currentImage = imp.getCurrentSlice(); int channel = 0, slice = 0, frame = 0; boolean hyperstack = imp.isHyperStack(); if (hyperstack) { channel = imp.getChannel(); slice = imp.getSlice(); frame = imp.getFrame(); } drawNames = Prefs.useNamesAsLabels; for (int i = 0; i < n; i++) { String label = list.getItem(i); Roi roi = (Roi) rois.get(label); if (roi == null) continue; if (showAllList != null) showAllList.add(roi); if (i < 200 && drawLabels && roi == imp.getRoi()) currentRoi = roi; if (Prefs.showAllSliceOnly && imp.getStackSize() > 1) { if (hyperstack && roi.getPosition() == 0) { int c = roi.getCPosition(); int z = roi.getZPosition(); int t = roi.getTPosition(); if ((c == 0 || c == channel) && (z == 0 || z == slice) && (t == 0 || t == frame)) drawRoi(g, roi, drawLabels ? i : -1); } else { int position = roi.getPosition(); if (position == 0) position = getSliceNumber(roi.getName()); if (position == 0 || position == currentImage) drawRoi(g, roi, drawLabels ? i : -1); } } else drawRoi(g, roi, drawLabels ? i : -1); } ((Graphics2D) g).setStroke(Roi.onePixelWide); drawNames = false; }
private void passAllNames(List listaA, List listaB) { String item = ""; int numItens = listaA.getItemCount(); for (int i = 0; i < numItens; i++) { item = listaA.getItem(0); listaB.add(item); listaA.remove(item); } }
public void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.black); this.setSize(650, 600); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {} }); /** ************************* MAIN PANEL ******************************* */ mainPanel = new JPanel(); // If put to False: we see the container's background mainPanel.setOpaque(false); mainPanel.setLayout(new BorderLayout()); container.add(mainPanel, BorderLayout.CENTER); allmessagesTextArea = new TextArea(); allmessagesTextArea.setEditable(false); allmessagesTextArea.setFont(new Font("Dialog", 1, 12)); allmessagesTextArea.setForeground(Color.black); allmessagesTextArea.append("Select a session in the list to view its messages"); mainPanel.add(allmessagesTextArea, BorderLayout.CENTER); sessionsList = new List(); sessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { showMessages(e); } }); sessionsList.setForeground(Color.black); sessionsList.setFont(new Font("Dialog", 1, 14)); mainPanel.add(sessionsList, BorderLayout.WEST); okButton = new JButton(" OK "); okButton.setToolTipText("Returns to the main frame"); okButton.setFont(new Font("Dialog", 1, 16)); okButton.setFocusPainted(false); okButton.setBackground(Color.lightGray); okButton.setBorder(new BevelBorder(BevelBorder.RAISED)); okButton.setVerticalAlignment(SwingConstants.CENTER); okButton.setHorizontalAlignment(SwingConstants.CENTER); container.add(okButton, BorderLayout.SOUTH); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setVisible(false); } }); }
public OpenProjectListDialog(String name) { conn = SQLiteDBConnection.ConnecrDb(); this.userName = name; setModalityType(ModalityType.APPLICATION_MODAL); setTitle("Open Project List"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLocationRelativeTo(null); setBounds(100, 100, 450, 250); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(null); projectList.setBounds(44, 46, 329, 108); contentPanel.add(projectList); String sql = "select * from Project where ProjectManager = ?;"; try { pst = conn.prepareStatement(sql); pst.setString(1, userName); rs = pst.executeQuery(); while (rs.next()) { projectList.add(rs.getString("ProjectName")); } rs.close(); pst.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex); } JLabel lblNowYouHave = new JLabel("Now, you have the following projects: "); lblNowYouHave.setBounds(23, 11, 321, 14); contentPanel.add(lblNowYouHave); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); JButton okButton = new JButton("OK"); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String projectNam = projectList.getSelectedItem().toString(); setProjectName(projectNam); // JOptionPane.showMessageDialog(null, "Project "+projectName+" Opened"); dispose(); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); }
public void updateList(ArrayList<TownModel> patients) { int index; patientsListView.clear(); for (index = 0; index < patients.size(); index++) { if (patients.get(index).isFiltered_m()) patientsListView.add( patients.get(index).getFirstName() + " " + patients.get(index).getSurname()); } patientsListView.select(0); }
public void init() { List actionList = new List(3); // makes a list to choose from actionList.add("wave"); actionList.add("think"); actionList.add("write"); actionList.addActionListener(this); // tell Java to listen for user input add(actionList); myDuke = new Dukes(); // make an instance of Duke action = myDuke.getActionImage(); // see what Duke's current action is }
private void PreencheGenero() { for (int i = 0; i < Main.facade.recuperarGeneros().size(); i++) { list.add(Main.facade.recuperarGeneros().get(i).getTitulo()); } list.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent ie) { Genero gen = Main.facade.recuperarGeneros().get(list.getSelectedIndex()); selecionado1.setText("Gênero: " + gen.getTitulo()); selecionado2.setText("Descrição: " + gen.getDescricao()); } }); }
/** Refreshes the list of shared content */ private void updateLocalFiles() { // ContentManager.getContent() retrieves all of the content that is // being shared by this peer. Content[] content = cms.getContentManager().getContent(); // erase the list of shared content... fileList.removeAll(); // ...and repopulate it for (int i = 0; i < content.length; i++) { fileList.add(content[i].getContentAdvertisement().getName()); } }
public int[] getSelectedIndexes() { List l = (List) target; int len = l.countItems(); int sel[] = new int[len]; int nsel = 0; for (int i = 0; i < len; i++) { if (isSelected(i)) { sel[nsel++] = i; } } int selected[] = new int[nsel]; System.arraycopy(sel, 0, selected, 0, nsel); return selected; }
@Override @SuppressWarnings({"nls", "boxing"}) protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder enc) { super.initialize(type, oldInstance, newInstance, enc); List list = (List) oldInstance; Statement setterStm = new Statement(oldInstance, "setSize", new Object[] {list.getSize()}); enc.writeStatement(setterStm); int count = list.getItemCount(); Expression getterExp = null; for (int i = 0; i < count; i++) { getterExp = new Expression(list, "getItem", new Object[] {i}); try { // Calculate the old value of the property Object oldVal = getterExp.getValue(); // Write the getter expression to the encoder enc.writeExpression(getterExp); // Get the target value that exists in the new environment Object targetVal = enc.get(oldVal); // Get the current property value in the new environment Object newVal = null; try { newVal = new Expression(newInstance, "getItem", new Object[] {i}).getValue(); } catch (IndexOutOfBoundsException ex) { // The newInstance has no elements, so current property // value remains null } /* * Make the target value and current property value equivalent * in the new environment */ if (null == targetVal) { if (null != newVal) { // Set to null setterStm = new Statement(oldInstance, "add", new Object[] {null}); enc.writeStatement(setterStm); } } else { PersistenceDelegate pd = enc.getPersistenceDelegate(targetVal.getClass()); if (!pd.mutatesTo(targetVal, newVal)) { setterStm = new Statement(oldInstance, "add", new Object[] {oldVal}); enc.writeStatement(setterStm); } } } catch (Exception ex) { enc.getExceptionListener().exceptionThrown(ex); } } }
@Override public void itemStateChanged(ItemEvent arg0) { List l = (List) arg0.getItemSelectable(); String tableName = l.getSelectedItem(); ui.statusBar.setText(tableName); DefaultTableModel tm = dbDao.getAllTableData(tableName); if (tm != null) { ui.table.setModel(tm); ui.statusBar.setText(tableName + ":共" + (tm.getRowCount() - 1) + "条数据"); } ui.tfSqlCommand.setText( "select * from " + ui.awtList.getSelectedItem() + " where like \"%%\""); }
public void setTracesSessions(TracesSessions tracesSessions) { sessionsList.removeAll(); this.tracesSessions = tracesSessions; for (int i = 0; i < tracesSessions.size(); i++) { TracesSession tracesSession = tracesSessions.elementAt(i); String name = tracesSession.getName(); // System.out.println("name:"+name); if (name.equals("No available session yet, click on refresh")) sessionsList.add(name); else { String trueName = getTrueName(name); sessionsList.add("Trace " + (i + 1) + " from " + trueName); } } if (tracesSessions.size() != 0) sessionsList.select(0); }
public ListDialog(JFrame parent, String title, String label, String[] values) { super(parent, title, true, cx, cy, cw, ch, xw, yw, cf); setSize(width, height); container = getContentPane(); container.setLayout(new GridBagLayout()); constraints = new GridBagConstraints(); addWithConstraints(0, new JLabel(label)); display = new JList<String>(values); addWithConstraints(1, new JScrollPane(display)); display.addListSelectionListener(this); selected = new List(); addWithConstraints(2, selected); selected.setFont(display.getFont()); okBouton = new JButton("OK"); addWithConstraints(3, okBouton); okBouton.addActionListener(this); cancelBouton = new JButton("Cancel"); addWithConstraints(4, cancelBouton); cancelBouton.addActionListener(this); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == logout) { Main.Frame.setPanel(new LoginPanel()); } /*Ao filtrar por AUTOR*/ if (e.getSource() == autor) { Main.Frame.setPanel(new AutorPanel()); } /*Ao filtrar por TRABALHO ARTISTICO*/ if (e.getSource() == titulo) { Main.Frame.setPanel(new TrabalhoPanel()); } /*Ao filtrar por GÊNERO*/ if (e.getSource() == genero) { genero.setSelected(true); autor.setSelected(false); titulo.setSelected(false); list.removeAll(); selecionado1.setText(""); selecionado2.setText(""); selecionado3.setText(""); PreencheGenero(); } if (e.getSource() == adicionar) { this.setVisible(false); Main.Frame.setPanel(new AdicionarPanel()); } }
private void ListValueChanged( javax.swing.event.ListSelectionEvent evt) { // GEN-FIRST:event_ListValueChanged // TODO add your handling code here: // String part=partno.getText(); try { String sql = "SELECT TYPE,ITEM_NAME,QUANTITY,MRP FROM MOTORS WHERE ITEM_NAME='" + List.getSelectedValue() + "'"; Class.forName("com.mysql.jdbc.Driver"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", ""); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { partno.setText(rs.getString("TYPE")); name.setText(rs.getString("ITEM_NAME")); qty.setText(rs.getString("QUANTITY")); rate.setText(rs.getString("MRP")); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e.toString()); } } // GEN-LAST:event_ListValueChanged
public void itemStateChanged(ItemEvent E) { // The 'log chat' checkbox if (E.getSource() == logChat) { server.logChats = logChat.getState(); // Loop through all of the chat rooms, and set the logging // state to be the same as the value of the checkbox for (int count = 0; count < server.chatRooms.size(); count++) { babylonChatRoom tmp = (babylonChatRoom) server.chatRooms.elementAt(count); try { tmp.setLogging(server.logChats); } catch (IOException e) { server.serverOutput( server.strings.get(thisClass, "togglelogerror") + " " + tmp.name + "\n"); } } } // The user list if (E.getSource() == userList) { // If anything is selected, enable the 'disconnect user' // button, otherwise disable it synchronized (userList) { disconnect.setEnabled(userList.getSelectedItem() != null); } } }
public boolean action(Event e, Object o) { int curCursorType; String session; Vector values; if (e.target == close) removeSelf(); else if (e.target == start) { selection = sessionList.getSelectedIndex(); if (selection < 0) { (new ErrorFrame()).showMsg("Please select a session."); return true; } session = sessionList.getSelectedItem(); curCursorType = getCursorType(); setCursor(Frame.WAIT_CURSOR); values = theAR.getValues(new Date(session)); numSteps = values.size(); setCursor(curCursorType); theApplet.playStart(values); step.enable(); stepIndex = -1; } else if (e.target == step) { int newSelection = sessionList.getSelectedIndex(); if (selection == newSelection) { stepIndex++; if (stepIndex < numSteps) theApplet.playStep(stepIndex); else { (new ErrorFrame()) .showMsg( "End of session has been reached. Please select a new session or click cancel."); step.disable(); } } else if (newSelection < 0) (new ErrorFrame()).showMsg("Please select a session."); else (new ErrorFrame()) .showMsg( "A session must be selected and started before clicking step. 1) Select a session and press start OR 2) Reselect the session you were stepping through"); } return true; }
public ListPanel() { setLayout(new BorderLayout()); patientsListView = new List(); scrollPane = new JScrollPane(patientsListView); setSize(500, 500); patientsListView.select(0); add(scrollPane); }
public void go() { f = new Frame("좋아하는 선수 고르기"); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { f.setVisible(false); f.dispose(); System.exit(0); } }); lstSunsu = new List(4, true); // 4개 보여주고,여러명 선택가능 lstSunsu.addItemListener(this); // 2. step lstSunsu.add("==선수선택=="); lstSunsu.add("조오련"); lstSunsu.add("박찬호"); lstSunsu.add("박세리"); lstSunsu.add("안정환"); lstSunsu.add("이천수"); lstSunsu.add("이영표"); lstSunsu.add("차범근"); lstSunsu.add("김남일"); lstSunsu.add("차두리"); tf = new TextField(); f.add(new Label("좋아하는 선수를 여러명 선택하세요"), "North"); f.add(lstSunsu, "Center"); f.add(tf, "South"); f.setSize(200, 300); f.setVisible(true); }
public void itemStateChanged(ItemEvent e) { String sunsu = "내가 좋아하는 선수는 "; String[] array = lstSunsu.getSelectedItems(); for (int i = 0; i < array.length; i++) { // tf.setText(array[i] + ", "); sunsu += array[i] + ","; } tf.setText(sunsu); }
/** * Methode : fillOutTheChoiceList() allows you to fill out the choice list for the user This * methode will search all the device linked with this SESAME. */ public void fillOutTheChoiceList() { System.out.println("<--- BEGIN : fillOutTheChoiceList() --->"); String[] all_device_id; // Make the deserialization of the table file which is the database of the device IdentifiantAndKeyTable table_id_key = null; boolean flag_extraction = false; File file = new File("identifiant_and_key_table.ser"); try (FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(fileIn)) { table_id_key = (IdentifiantAndKeyTable) in.readObject(); flag_extraction = true; } catch (IOException i) { flag_extraction = false; System.out.println("IOException : " + i.getMessage()); } catch (ClassNotFoundException c) { System.out.println("DeviceLinkingData class not found"); flag_extraction = false; } // Check if the deserialization is done succesffully if (flag_extraction) { all_device_id = table_id_key.getAllLinkedDeviceId(); if (all_device_id.length > 0) { // Fit the device array list for (int i = 0; i < all_device_id.length; i++) { liste_peripherique.add(all_device_id[i], i); } } else { for (int i = 0; i < device_list.length; i++) { liste_peripherique.add(device_list[i], i); } } } else { for (int i = 0; i < device_list.length; i++) { liste_peripherique.add(device_list[i], i); } } System.out.println("<--- END : fillOutTheChoiceList() --->"); // liste_peripherique.addListSelectionListener(this); }
public ListPanel(ArrayList<TownModel> patients) { setLayout(new BorderLayout()); patientsListView = new List(); scrollPane = new JScrollPane(patientsListView); setSize(500, 500); updateList(patients); patientsListView.select(0); add(scrollPane); }
public void makeSessionList() { sessionList = new List(5, false); Vector theSessions = theAR.getSessions(); int size = theSessions.size(); for (int j = 0; j < size; j++) { Date d = (Date) theSessions.elementAt(j); sessionList.addItem(d.toString()); } }
/** Rigourous Test :-) */ public void testApp() { List mockList = mock(List.class); mockList.add("one"); mockList.clear(); verify(mockList).add("one"); verify(mockList).clear(); LinkedList<String> mockString = mock(LinkedList.class); Mockito.when(mockString.get(0)).thenReturn("first"); Mockito.when(mockString.get(1)).thenThrow(new RuntimeException()); System.out.println(mockString.get(0)); System.out.println(mockString.get(99)); Mockito.verify(mockString).get(0); }
public void createGUI() { frame = new Frame(); frame.setTitle("KeyMaskTest"); frame.setLayout(new GridLayout(1, 6)); button = new Button(); button.addKeyListener(this); frame.add(button); buttonLW = new LWButton(); buttonLW.addKeyListener(this); frame.add(buttonLW); textField = new TextField(5); textField.addKeyListener(this); frame.add(textField); textArea = new TextArea(5, 5); textArea.addKeyListener(this); frame.add(textArea); list = new List(); for (int i = 1; i <= 5; ++i) { list.add("item " + i); } list.addKeyListener(this); frame.add(list); listLW = new LWList(); for (int i = 1; i <= 5; ++i) { listLW.add("item " + i); } listLW.addKeyListener(this); frame.add(listLW); frame.setBackground(Color.gray); frame.setSize(500, 100); frame.setVisible(true); frame.toFront(); }
/** * Overwritten set visible method to populate the list as soon as the map loader goes visible. * * @param visible the new value for the visible flag */ @Override public void setVisible(final boolean visible) { if (visible) { populateMaplist(); } super.setVisible(visible); if (!visible) { mapList.removeAll(); } }
/** @author Jesper Create the frame. */ public LoadBookingW() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 451, 236); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(null); JButton btnCancel = new JButton("Cancel"); btnCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selected = -1; latch.countDown(); } }); btnCancel.setBounds(12, 152, 71, 25); panel.add(btnCancel); listBookings = new List(); listBookings.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { selected = listBookings.getSelectedIndex(); latch.countDown(); } }); listBookings.setBounds(12, 41, 389, 99); panel.add(listBookings); JLabel lblReserveretSder = new JLabel("Bookings"); lblReserveretSder.setFont(new Font("Tahoma", Font.PLAIN, 18)); lblReserveretSder.setBounds(12, 13, 158, 22); panel.add(lblReserveretSder); }