protected void refreshTransformers() { if (model != null) { // Select the right transformer int index = 0; for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) { for (TransformerCategory c : controller.getCategories(elmtType)) { ButtonGroup g = buttonGroups.get(index); boolean active = model.getSelectedElementClass().equals(elmtType) && model.getSelectedCategory().equals(c); g.clearSelection(); TransformerUI t = model.getSelectedTransformerUI(); for (Enumeration<AbstractButton> btns = g.getElements(); btns.hasMoreElements(); ) { AbstractButton btn = btns.nextElement(); btn.setVisible(active); if (t != null && btn.getName().equals(t.getDisplayName())) { g.setSelected(btn.getModel(), true); } } index++; } } } }
/** * event * * @throws RemoteException */ private void buttonJawabActionPerformed() throws RemoteException { if (cekPilih()) { jawabanBs = new JawabanBs(); jawabanBs.setMahasiswa(mhs); jawabanBs.setSoalBs(soalBsList.get(noSoal)); jawabanBs.setJawab(Jawab.valueOf("S")); if (soalBsList.get(noSoal).getKunci() == KunciBs.valueOf(kunciJawaban())) { bener++; jawabanBs.setJawab(Jawab.valueOf("B")); } bsPretestService.save(jawabanBs); if (noSoal < jumlahSoal - 1) { noSoal++; textNo.setText((noSoal + 1) + ""); textSoal.setText(soalBsList.get(noSoal).getSoal()); buttonGroup.clearSelection(); } else { nilai = ((double) bener / (double) jumlahSoal) * 100; nilaiBs = new NilaiBs(); nilaiBs.setMahasiswa(mhs); nilaiBs.setPertemuanPraktikum(pertemuanPraktikum); nilaiBs.setNilai(nilai); nilaiBs.setStatusNilai(StatusNilai.Y); bsPretestService.save(nilaiBs); listener.selesai(nilai, setting.getBataLulus()); } } else { JOptionPane.showMessageDialog(this, "jawaban tidak boleh kosong"); } }
private void voidButtonActionPerformed(ActionEvent evt) { // System.out.println("Void button clicked"); int pageNum = swingControl.getCurrentPageNumber(); statusButtonGroup.clearSelection(); voidButton.setSelected(!statusArray[GlobalVar.VOID_BUTTON_INDEX][pageNum]); statusArray[GlobalVar.VOID_BUTTON_INDEX][pageNum] = !statusArray[GlobalVar.VOID_BUTTON_INDEX][pageNum]; statusArray[GlobalVar.SKIP_BUTTON_INDEX][pageNum] = false; statusArray[GlobalVar.SELECT_BUTTON_INDEX][pageNum] = false; setUpSeq(); }
public void setSelected(Object selected) { if (selected == null) { group.clearSelection(); } else { for (int i = 0; i < itemList.size(); i++) { RadioMenuItem item = itemList.get(i); if (item.getUserObject() == selected) { item.setSelected(true); // Do not trigger actionPerformed dataModel.setSelectedItem(item.getUserObject()); return; } } } }
public void clearSelection() { bg.clearSelection(); }
/** DOCUMENT ME! */ private void manualPeriodChangePerformed() { buttonGroup1.clearSelection(); periodChanged(); }
private void treeValueChanged(javax.swing.event.TreeSelectionEvent evt) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_1.getLastSelectedPathComponent(); String option = (String) node.getUserObject(); CardLayout cards = (CardLayout) student.getLayout(); CardLayout cards1 = (CardLayout) content.getLayout(); if (option.equals("1")) { i = 1; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; System.out.println(answerTF[i - 1]); BG1.clearSelection(); } else if (option.equals("2")) { i = 2; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("3")) { i = 3; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("4")) { i = 4; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("5")) { i = 5; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("6")) { i = 6; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("7")) { i = 7; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("8")) { i = 8; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("9")) { i = 9; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("10")) { i = 10; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("Submit")) { cards1.show(content, "Submit"); } else if (option.equals("Index")) { cards.show(student, "student"); } }
/** The only constructor of the class. It launches the main window. */ @SuppressWarnings("unchecked") public MainFrame() throws Exception { super("StatAlign " + StatAlign.version); try { String syslook = UIManager.getSystemLookAndFeelClassName(); if (!UIManager.getLookAndFeel().getClass().getName().equals(syslook)) { UIManager.setLookAndFeel(syslook); SwingUtilities.updateComponentTreeUI(this); } } catch (Exception ex) { JOptionPane.showMessageDialog(this, ex); } ArrayList<Class<?>> substModList = new ArrayList<Class<?>>(); for (String model : Utils.classesInPackage(SubstitutionModel.class.getPackage().getName() + ".plugins")) { try { Class<?> cl = Class.forName(model); /* Only include non-abstract substitution models that extend SubstitutionModel */ if (!Modifier.isAbstract(cl.getModifiers()) && SubstitutionModel.class.isAssignableFrom(cl)) substModList.add(cl); } catch (Exception ex) { } } substModels = (Class<? extends SubstitutionModel>[]) substModList.toArray(new Class<?>[substModList.size()]); manager = new MainManager(this); mcmcSettingsDlg = new McmcSettingsDlg(this); setMinimumSize(new Dimension(500, 250)); /// /// Creates the MenuBar and the ToolBar /// toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); JMenuBar menubar = new JMenuBar(); JMenu menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); JMenuItem item; String openText = "Add sequence(s)..."; ImageIcon icon = new ImageIcon(ClassLoader.getSystemResource("icons/open.png")); openItem = createMenuItem(openText, true); openItem.setAccelerator(KeyStroke.getKeyStroke("control O")); openItem.setMnemonic(KeyEvent.VK_A); openItem.setIcon(icon); menu.add(openItem); openButton = createButton(icon, "Add sequence(s)..."); toolBar.add(openButton); toolBar.addSeparator(); JMenuItem ioPreferencesItem = createMenuItem("Preferences...", true); ioPreferencesItem.setAccelerator(KeyStroke.getKeyStroke("control 1")); ioPreferencesItem.setMnemonic(KeyEvent.VK_P); menu.add(ioPreferencesItem); menu.addSeparator(); item = createMenuItem("Exit", true); item.setAccelerator(KeyStroke.getKeyStroke("alt F4")); item.setMnemonic(KeyEvent.VK_X); menu.add(item); menubar.add(menu); // menu = new JMenu("Edit"); // menu.setMnemonic(KeyEvent.VK_E); // item = new JMenuItem("Cut"); // item.addActionListener(this); // item.setAccelerator(KeyStroke.getKeyStroke("control X")); // menu.add(item); // item = new JMenuItem("Copy"); // item.addActionListener(this); // item.setAccelerator(KeyStroke.getKeyStroke("control C")); // menu.add(item); // item = new JMenuItem("Paste"); // item.addActionListener(this); // item.setAccelerator(KeyStroke.getKeyStroke("control V")); // menu.add(item); // menubar.add(menu); menu = new JMenu("Analysis"); menu.setMnemonic(KeyEvent.VK_M); // item = createMenuItem("Settings", true); // item.setAccelerator(KeyStroke.getKeyStroke("control M")); // item.setMnemonic(KeyEvent.VK_S); // menu.add(item); String runText = "Set up and run"; icon = new ImageIcon(ClassLoader.getSystemResource("icons/play.png")); runItem = createMenuItem(runText, false); runItem.setAccelerator(KeyStroke.getKeyStroke("control ENTER")); runItem.setIcon(icon); menu.add(runItem); menu.addSeparator(); runButton = createButton(icon, runText); runButton.setEnabled(false); toolBar.add(runButton); String pauseText = "Pause"; icon = new ImageIcon(ClassLoader.getSystemResource("icons/pause.png")); pauseItem = createMenuItem("Pause", false); pauseItem.setIcon(icon); menu.add(pauseItem); pauseButton = createButton(icon, pauseText); pauseButton.setEnabled(false); toolBar.add(pauseButton); String resumeText = "Resume"; icon = new ImageIcon(ClassLoader.getSystemResource("icons/resume.png")); resumeItem = createMenuItem(resumeText, false); resumeItem.setIcon(icon); menu.add(resumeItem); resumeButton = createButton(icon, resumeText); resumeButton.setEnabled(false); toolBar.add(resumeButton); String stopText = "Stop"; icon = new ImageIcon(ClassLoader.getSystemResource("icons/stop.png")); stopItem = createMenuItem("Stop", false); stopItem.setIcon(icon); menu.add(stopItem); menubar.add(menu); stopButton = createButton(icon, stopText); stopButton.setEnabled(false); toolBar.add(stopButton); String rnaText = "RNA mode"; rnaButton = createToggleButton(new ImageIcon(ClassLoader.getSystemResource("icons/rna1.png")), rnaText); rnaButton.setEnabled(false); rnaButton.setSelected(false); toolBar.add(rnaButton); // String settingsText = "Settings"; // JButton settingsButton = createButton(new ImageIcon(ClassLoader. // getSystemResource("icons/settings.png")), settingsText); // toolBar.add(settingsButton); menu = new JMenu("Model"); menu.setMnemonic(KeyEvent.VK_L); modelButtons = new JMenuItem[substModels.length]; ButtonGroup modelGroup = new ButtonGroup(); HashMap<String, ArrayList<Class<? extends SubstitutionModel>>> substModTypes = new HashMap<String, ArrayList<Class<? extends SubstitutionModel>>>(); for (Class<? extends SubstitutionModel> cl : substModels) { String type = SubstitutionModel.getType(cl); ArrayList<Class<? extends SubstitutionModel>> arr = substModTypes.get(type); if (arr == null) substModTypes.put(type, arr = new ArrayList<Class<? extends SubstitutionModel>>()); arr.add(cl); } String[] typeArr = new String[substModTypes.keySet().size()]; int s = 0; if (typeArr.length >= 2) { typeArr[0] = "protein"; // amino acid subst models first typeArr[1] = "nucleotide"; // then nucleotide models, then the rest s = 2; } for (String type : substModTypes.keySet()) { if (!type.equals("protein") && !type.equals("nucleotide")) typeArr[s++] = type; } s = 0; for (String type : typeArr) { if (s > 0) menu.addSeparator(); for (Class<? extends SubstitutionModel> cl : substModTypes.get(type)) { String name = SubstitutionModel.getMenuName(cl); item = new JRadioButtonMenuItem(name); item.addActionListener(this); modelButtons[s++] = item; modelGroup.add(item); menu.add(item); } } modelGroup.clearSelection(); menubar.add(menu); /*menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); JMenuItem zoomInItem = new JMenuItem("Zoom in"); zoomInItem.setEnabled(false); zoomInItem.addActionListener(this); menu.add(zoomInItem); JMenuItem zoomOutItem = new JMenuItem("Zoom out"); zoomOutItem.setEnabled(false); zoomOutItem.addActionListener(this); menu.add(zoomOutItem); JMenuItem autofitItem = new JMenuItem("Fit to frame"); autofitItem.setEnabled(false); autofitItem.addActionListener(this); menu.add(autofitItem); menubar.add(menu);*/ menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); item = new JMenuItem("About..."); item.addActionListener(this); menu.add(item); menu.addSeparator(); item = new JMenuItem("Help for users"); item.addActionListener(this); menu.add(item); menu.addSeparator(); item = new JMenuItem("Html doc for developers"); item.addActionListener(this); menu.add(item); item = new JMenuItem("Description of plugins"); item.addActionListener(this); menu.add(item); menubar.add(menu); setJMenuBar(menubar); add(toolBar, BorderLayout.PAGE_START); /// /// Creates the main panel /// Container cp = getContentPane(); JPanel mainPanel = new JPanel(new BorderLayout()); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); mainPanel.setMinimumSize(new Dimension(screenSize.width / 3, screenSize.height / 3)); mainPanel.setMaximumSize(new Dimension(screenSize.width, screenSize.height)); mainPanel.setPreferredSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); tab = new JTabbedPane(); input = new Input(manager); tab.addTab(input.getTabName(), input.getIcon(), input.getJPanel(), input.getTip()); manager.inputgui = input.inputgui; // Sorts the tab according to their getTabOrder() pluginTabs = manager.postProcMan.plugins.clone(); Arrays.sort( pluginTabs, new Comparator<Postprocess>() { @Override public int compare(Postprocess firstTab, Postprocess secondTab) { return Double.compare(firstTab.getTabOrder(), secondTab.getTabOrder()); } }); tabPluginMap = new HashMap<Integer, Postprocess>(); for (int i = 0; i < pluginTabs.length; i++) { Postprocess plugin = pluginTabs[i]; if (plugin.selected && !plugin.rnaAssociated) { tabPluginMap.put(i + 1, plugin); // TODO: Jesus Java, horrible. tab.addTab(plugin.getTabName(), plugin.getIcon(), plugin.getJPanel(), plugin.getTip()); } } tab.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent changeEvent) { JTabbedPane pane = (JTabbedPane) changeEvent.getSource(); Integer i = pane.getSelectedIndex(); // Remove the last tabs toolbar items. if (lastSelectedTabIndex != -1) { Postprocess lastPlugin = tabPluginMap.get(lastSelectedTabIndex); if (lastPlugin != null && lastPlugin.hasToolBar) { for (JComponent item : lastPlugin.getToolBarItems()) { toolBar.remove(item); } toolBar.revalidate(); // TODO: optimize. toolBar.repaint(); } } // Add the currents tab toolbar items. Postprocess plugin = tabPluginMap.get(i); if (plugin != null && plugin.hasToolBar) { for (JComponent item : plugin.getToolBarItems()) { toolBar.add(item); } toolBar.revalidate(); toolBar.repaint(); } lastSelectedTabIndex = i; } }); mainPanel.add(tab, BorderLayout.CENTER); cp.add(mainPanel, BorderLayout.CENTER); JPanel statusBar = new JPanel(new BorderLayout()); statusText = new JLabel(IDLE_STATUS_MESSAGE); statusBar.add(statusText, BorderLayout.CENTER); cp.add(statusBar, BorderLayout.SOUTH); // setSize(300, 200); // setLocationByPlatform(true); // setLocation(screenSize.width/4,screenSize.height/4); pack(); setBounds( screenSize.width / 5 - 15, screenSize.height / 5 - 15, screenSize.width * 3 / 5 + 30, screenSize.height * 3 / 5 + 30); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); }