List of usage examples for javax.swing JButton setText
@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.") public void setText(String text)
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Creates the content.//w ww .jav a2s . c om */ private void createContent() { this.tabs = new JTabbedPane(); this.tabs.setPreferredSize(new Dimension(640, 480)); this.tabs.addChangeListener(this); this.tabs.setTransferHandler(this.transferHandler); final JPanel welcomePanel = this.welcomePanel = new JPanel(); welcomePanel.setTransferHandler(this.transferHandler); welcomePanel.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); welcomePanel.setPreferredSize(new Dimension(640, 480)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); c.anchor = GridBagConstraints.CENTER; welcomePanel.add(buttonPanel, c); final JButton newButton = new JButton(this.newAction); newButton.setHorizontalAlignment(SwingConstants.LEFT); newButton.setIconTextGap(10); newButton.setText("<html><body><strong>" + newButton.getText() + "</strong><br />" + newButton.getToolTipText() + "</body></html>"); newButton.setToolTipText(null); newButton.setMargin(new Insets(5, 10, 5, 10)); c.gridy = 0; c.fill = GridBagConstraints.BOTH; c.insets.set(5, 5, 5, 5); buttonPanel.add(newButton, c); final JButton openButton = new JButton(this.openAction); openButton.setHorizontalAlignment(SwingConstants.LEFT); openButton.setIconTextGap(10); openButton.setText("<html><body><strong>" + openButton.getText() + "</strong><br />" + openButton.getToolTipText() + "</body></html>"); openButton.setToolTipText(null); openButton.setMargin(new Insets(5, 10, 5, 10)); c.gridy++; buttonPanel.add(openButton, c); final JPanel separator = new JPanel(); separator.setPreferredSize(new Dimension(20, 20)); c.gridy++; buttonPanel.add(separator, c); final JButton donateButton = new JButton(this.donateAction); donateButton.setHorizontalAlignment(SwingConstants.LEFT); donateButton.setIconTextGap(10); donateButton.setText("<html><body><strong>" + donateButton.getText() + "</strong><br />" + donateButton.getToolTipText() + "</body></html>"); donateButton.setToolTipText(null); donateButton.setMargin(new Insets(5, 10, 5, 10)); c.gridy++; buttonPanel.add(donateButton, c); final SocialPane socialPane = new SocialPane(); c.insets.top = 50; c.gridy++; buttonPanel.add(socialPane, c); installStatusHandler(buttonPanel); add(welcomePanel, BorderLayout.CENTER); }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
private JButton getConsultar() { final JButton jButton = new JButton(LogicConstants.getIcon("historico_button_realizarconsulta")); jButton.setText("Consultar"); jButton.setEnabled(false);/* www.ja va 2 s.c o m*/ jButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cargando.setIcon(LogicConstants.getIcon("anim_calculando")); cargando.repaint(); limpiar.setEnabled(false); jButton.setEnabled(false); consulta = new SwingWorker<Layer, Object>() { @Override protected Layer doInBackground() throws Exception { publish(new Object[0]); List<String> idRecursos = new ArrayList<String>(); List<Long> idZonas = new ArrayList<Long>(); for (Object o : recursos.getSelectedValues()) { if (o instanceof Recurso) { idRecursos.add(((Recurso) o).getIdentificador()); } else { idRecursos.add(o.toString()); } } // for (Object o : zona.getSelectedValues()) { // if (o instanceof Zona) { // idZonas.add(((Zona) o).getId()); // } // } List<String> idIncidencias = new ArrayList<String>(); for (Object o : incidencias.getSelectedValues()) { if (o instanceof Incidencia) { idIncidencias.add(((Incidencia) o).getId().toString()); } else { idIncidencias.add(o.toString()); } } if (soloUltimas.isSelected()) { if (idRecursos.size() > 0) { getUltimasPosiciones(Authentication.getUsuario().getNombreUsuario(), idRecursos, idZonas); } if (idIncidencias.size() > 0) { getPosicionesIncidencias(Authentication.getUsuario().getNombreUsuario(), idIncidencias, idZonas); } } else { if (idRecursos.size() > 0) { getRutas(Authentication.getUsuario().getNombreUsuario(), idRecursos, getFechaIni(), getFechaFin()); } if (idIncidencias.size() > 0) { getPosicionesIncidencias(Authentication.getUsuario().getNombreUsuario(), idIncidencias, idZonas); } } return null; } @Override protected void process(List<Object> chunks) { super.process(chunks); cleanLayers(); cargando.setIcon(LogicConstants.getIcon("anim_calculando")); cargando.repaint(); } @Override protected void done() { HistoryMapViewer.getResultadoHistoricos().setSelected(true); cargando.setIcon(LogicConstants.getIcon("48x48_transparente")); cargando.repaint(); } }; consulta.execute(); } }); return jButton; }
From source file:com.isencia.passerelle.hmi.HMIBase.java
/** * DBA : add tooltip for each button/*from w w w . ja va 2 s .c o m*/ * * @return */ private JButton createToolbarButton(final Action action, final JToolBar toolbar, final String tooltip) { final JButton b = new JButton(action); b.setBorderPainted(false); b.setToolTipText(tooltip); b.setText(null); toolbar.add(b); return b; }
From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java
protected void createActionComponents(JToolBar toolBar) { JButton button = null; toolBar.setFloatable(false);/*from w ww .ja va2 s. c o m*/ /**************** Demo Tab****************/ if (useStaticExample) { exampleStaticAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Create First Example reset(); resetTable(); resetMappingList(); resetExample(); if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) setMixPanel(); updateStatus(url); validate(); } }; button = toolBar.add(exampleStaticAction); button.setText(EXAMPLE); button.setToolTipText(chartDescription); } /**************** DO-CHART Tab ****************/ computeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { doChart(); } }; button = toolBar.add(computeAction); button.setText(DOCHART); button.setToolTipText("Press this Button to Generate the Chart"); /**************** CLEAR Tab****************/ clearAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { /* somehow reset has to be called more than once to set to the correct header. I'll leave it like this before I figure out why. annie che 20051123 -_- */ reset(); // Need to work out what this means // reset(); resetTable(); resetMappingList(); resetChart(); ChartExampleData exampleNull = new ChartExampleData(0, 0); /* A Null Example (with no data) is used here to reset the table so that when "CLEAR" button is pressed, the cells of dataTable is NOT null. annieche 20060110. */ updateExample(exampleNull); if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) setMixPanel(); updateStatus("The Chart has been reset!"); //updateExample(exampleNull); } }; button = toolBar.add(clearAction); button.setText(CLEAR); button.setToolTipText("Clears All Windows"); /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); parentApplet.getAppletContext().showDocument(new java.net.URL( "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); } catch (MalformedURLException Exc) { JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE); Exc.printStackTrace(); } } }; button = toolBar.add(linkAction); //button.setMinimumSize(new Dimension(110, 20)); button.setText(" WIKI_Activity "); button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page"); /**************** TEST Tab ****************/ testAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { doTest(); } }; if (TEST_API) { button = toolBar.add(testAction); button.setText(TEST); button.setToolTipText("Press this Button to test the API"); } }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformationFamilyChart.java
protected void createActionComponents(JToolBar toolBar) { super.createActionComponents(toolBar); JButton button; /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); parentApplet.getAppletContext().showDocument(new java.net.URL( "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); } catch (MalformedURLException Exc) { JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE); Exc.printStackTrace();/*w w w.ja v a 2s .c o m*/ } } }; button = toolBar.add(linkAction); button.setText(" WIKI_Activity "); button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page"); }
From source file:de.codesourcery.jasm16.ide.ui.views.SourceEditorView.java
protected JPanel createPanel() { // button panel final JToolBar toolbar = new JToolBar(); toolbar.setLayout(new GridBagLayout()); setColors(toolbar);/*ww w.j a v a2s.c om*/ final JButton showASTButton = new JButton("Show AST"); setColors(showASTButton); showASTButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final boolean currentlyVisible = isASTInspectorVisible(); if (currentlyVisible) { showASTButton.setText("Show AST"); } else { showASTButton.setText("Hide AST"); } if (currentlyVisible) { astInspector.setVisible(false); } else { showASTInspector(); } } }); GridBagConstraints cnstrs = constraints(0, 0, false, true, GridBagConstraints.NONE); toolbar.add(showASTButton, cnstrs); // navigation history back button cnstrs = constraints(1, 0, false, true, GridBagConstraints.NONE); toolbar.add(navigationHistoryBack, cnstrs); navigationHistoryBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { navigationHistoryBack(); } }); navigationHistoryBack.setEnabled(false); // navigation history forward button cnstrs = constraints(2, 0, true, true, GridBagConstraints.NONE); toolbar.add(navigationHistoryForward, cnstrs); navigationHistoryForward.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { navigationHistoryForward(); } }); navigationHistoryForward.setEnabled(false); // create status area statusArea.setPreferredSize(new Dimension(400, 100)); statusArea.setModel(statusModel); setColors(statusArea); /** * TOOLBAR * SOURCE * cursor position * status area */ final JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(toolbar, cnstrs); cnstrs = constraints(0, 1, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 1.0; topPanel.add(super.getPanel(), cnstrs); final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); statusArea.addMouseListener(new MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { final int viewRow = statusArea.rowAtPoint(e.getPoint()); if (viewRow != -1) { final int modelRow = statusArea.convertRowIndexToModel(viewRow); StatusMessage message = statusModel.getMessage(modelRow); if (message.getLocation() != null) { moveCursorTo(message.getLocation(), true); } } } }; }); EditorContainer.addEditorCloseKeyListener(statusArea, this); statusArea.setFillsViewportHeight(true); statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane statusPane = new JScrollPane(statusArea); setColors(statusPane); statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); statusPane.setPreferredSize(new Dimension(400, 100)); statusPane.setMinimumSize(new Dimension(100, 20)); cnstrs = constraints(0, 0, GridBagConstraints.BOTH); cnstrs.weightx = 1; cnstrs.weighty = 1; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = GridBagConstraints.REMAINDER; bottomPanel.add(statusPane, cnstrs); // setup result panel final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); setColors(splitPane); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); setColors(panel); cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); panel.add(splitPane, cnstrs); final AncestorListener l = new AncestorListener() { @Override public void ancestorRemoved(AncestorEvent event) { } @Override public void ancestorMoved(AncestorEvent event) { } @Override public void ancestorAdded(AncestorEvent event) { splitPane.setDividerLocation(0.8d); } }; panel.addAncestorListener(l); return panel; }
From source file:com.hp.alm.ali.idea.cfg.AliConfigurable.java
protected Component getSouthernComponent() { JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final TroubleShootService troubleShootService = ApplicationManager.getApplication() .getComponent(TroubleShootService.class); final JButton troubleshoot = new JButton( troubleShootService.isRunning() ? "Stop Troubleshoot" : "Troubleshoot"); troubleshoot.addActionListener(new ActionListener() { @Override// w w w . ja va 2 s . com public void actionPerformed(ActionEvent e) { if (troubleshoot.getText().equals("Troubleshoot")) { if (!troubleShootService.isRunning()) { if (Messages.showYesNoDialog("Do you want to log complete ALM server communication?", "Confirmation", null) == Messages.YES) { FileSaverDescriptor desc = new FileSaverDescriptor("Log server communication", "Log server communication on the local filesystem."); final VirtualFileWrapper file = FileChooserFactory.getInstance() .createSaveFileDialog(desc, troubleshoot).save(null, "REST_log.txt"); if (file == null) { return; } troubleShootService.start(file.getFile()); troubleshoot.setText("Stop Troubleshoot"); } } } else { troubleShootService.stop(); troubleshoot.setText("Troubleshoot"); } } }); southPanel.add(troubleshoot); return southPanel; }
From source file:net.sf.jabref.gui.entryeditor.EntryEditor.java
private void setupToolBar() { JPanel leftPan = new JPanel(); leftPan.setLayout(new BorderLayout()); JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setBorder(null);/*from ww w . j a va 2s . com*/ toolBar.setRollover(true); toolBar.setMargin(new Insets(0, 0, 0, 2)); // The toolbar carries all the key bindings that are valid for the whole // window. ActionMap actionMap = toolBar.getActionMap(); InputMap inputMap = toolBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_ENTRY_EDITOR), "close"); actionMap.put("close", closeAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store"); actionMap.put("store", getStoreFieldAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOGENERATE_BIBTEX_KEYS), "generateKey"); actionMap.put("generateKey", getGenerateKeyAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOMATICALLY_LINK_FILES), "autoLink"); actionMap.put("autoLink", autoLinkAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_ENTRY), "prev"); actionMap.put("prev", getPrevEntryAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_ENTRY), "next"); actionMap.put("next", getNextEntryAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo"); actionMap.put("undo", undoAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo"); actionMap.put("redo", redoAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help"); actionMap.put("help", getHelpAction()); toolBar.setFloatable(false); // Add actions (and thus buttons) JButton closeBut = new JButton(closeAction); closeBut.setText(null); closeBut.setBorder(null); closeBut.setMargin(new Insets(8, 0, 8, 0)); leftPan.add(closeBut, BorderLayout.NORTH); // Create type-label TypedBibEntry typedEntry = new TypedBibEntry(entry, Optional.empty(), panel.getBibDatabaseContext().getMode()); leftPan.add(new TypeLabel(typedEntry.getTypeForDisplay()), BorderLayout.CENTER); TypeButton typeButton = new TypeButton(); toolBar.add(typeButton); toolBar.add(getGenerateKeyAction()); toolBar.add(autoLinkAction); toolBar.add(writeXmp); toolBar.addSeparator(); toolBar.add(deleteAction); toolBar.add(getPrevEntryAction()); toolBar.add(getNextEntryAction()); toolBar.addSeparator(); toolBar.add(getHelpAction()); Component[] comps = toolBar.getComponents(); for (Component comp : comps) { ((JComponent) comp).setOpaque(false); } leftPan.add(toolBar, BorderLayout.SOUTH); add(leftPan, BorderLayout.WEST); }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
JButton createChooseBetweenImdbAndLocalDatabaseButton() { /*This button choses between IMDB and local movie database*/ final JButton chooseBetweenImdbAndLocalDatabase = new JButton( Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase//from w w w. j a v a 2s . c o m .setToolTipText(Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.tooltip")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.setActionCommand("GetIMDBInfo - chooseBetweenImdbAndLocalDatabase"); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { log.debug("ActionPerformed: " + event.getActionCommand()); //$NON-NLS-1$ if (addInfoToExistingMovie) { getPanelMoviesList().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); chooseBetweenImdbAndLocalDatabase .setText(Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.setToolTipText( Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.tooltip")); //$NON-NLS-1$ addInfoToExistingMovie = false; executeSearchMultipleMovies(); } else { executeEditExistingMovie(""); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase .setText(Localizer.get("DialogIMDbMultiAdd.button.search-on-IMDb.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase .setToolTipText(Localizer.get("DialogIMDbMultiAdd.button.search-on-IMDb.tooltip")); //$NON-NLS-1$ addInfoToExistingMovie = true; getPanelMoviesList().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-your-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); } } }); return chooseBetweenImdbAndLocalDatabase; }
From source file:de.codesourcery.jasm16.utils.ASTInspector.java
private void setupUI() throws MalformedURLException { // editor pane editorPane = new JTextPane(); editorScrollPane = new JScrollPane(editorPane); editorPane.addCaretListener(listener); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(400, 600)); editorScrollPane.setMinimumSize(new Dimension(100, 100)); final AdjustmentListener adjustmentListener = new AdjustmentListener() { @Override// w w w. ja v a2s .co m public void adjustmentValueChanged(AdjustmentEvent e) { if (!e.getValueIsAdjusting()) { if (currentUnit != null) { doSemanticHighlighting(currentUnit); } } } }; editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener); editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener); // button panel final JPanel topPanel = new JPanel(); final JToolBar toolbar = new JToolBar(); final JButton showASTButton = new JButton("Show AST"); showASTButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean currentlyVisible = astInspector != null ? astInspector.isVisible() : false; if (currentlyVisible) { showASTButton.setText("Show AST"); } else { showASTButton.setText("Hide AST"); } if (currentlyVisible) { astInspector.setVisible(false); } else { showASTInspector(); } } }); fileChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; if (lastOpenDirectory != null && lastOpenDirectory.isDirectory()) { chooser = new JFileChooser(lastOpenDirectory); } else { lastOpenDirectory = null; chooser = new JFileChooser(); } final FileFilter filter = new FileFilter() { @Override public boolean accept(File f) { if (f.isDirectory()) { return true; } return f.isFile() && (f.getName().endsWith(".asm") || f.getName().endsWith(".dasm") || f.getName().endsWith(".dasm16")); } @Override public String getDescription() { return "DCPU-16 assembler sources"; } }; chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { File newFile = chooser.getSelectedFile(); if (newFile.isFile()) { lastOpenDirectory = newFile.getParentFile(); try { openFile(newFile); } catch (IOException e1) { statusModel.addError("Failed to read from file " + newFile.getAbsolutePath(), e1); } } } } }); toolbar.add(fileChooser); toolbar.add(showASTButton); final ComboBoxModel<String> model = new ComboBoxModel<String>() { private ICompilerPhase selected; private final List<String> realModel = new ArrayList<String>(); { for (ICompilerPhase p : compiler.getCompilerPhases()) { realModel.add(p.getName()); if (p.getName().equals(ICompilerPhase.PHASE_GENERATE_CODE)) { selected = p; } } } @Override public Object getSelectedItem() { return selected != null ? selected.getName() : null; } private ICompilerPhase getPhaseByName(String name) { for (ICompilerPhase p : compiler.getCompilerPhases()) { if (p.getName().equals(name)) { return p; } } return null; } @Override public void setSelectedItem(Object name) { selected = getPhaseByName((String) name); } @Override public void addListDataListener(ListDataListener l) { } @Override public String getElementAt(int index) { return realModel.get(index); } @Override public int getSize() { return realModel.size(); } @Override public void removeListDataListener(ListDataListener l) { } }; comboBox.setModel(model); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (model.getSelectedItem() != null) { ICompilerPhase oldPhase = findDisabledPhase(); if (oldPhase != null) { oldPhase.setStopAfterExecution(false); } compiler.getCompilerPhaseByName((String) model.getSelectedItem()).setStopAfterExecution(true); try { compile(); } catch (IOException e1) { e1.printStackTrace(); } } } private ICompilerPhase findDisabledPhase() { for (ICompilerPhase p : compiler.getCompilerPhases()) { if (p.isStopAfterExecution()) { return p; } } return null; } }); toolbar.add(new JLabel("Stop compilation after: ")); toolbar.add(comboBox); cursorPosition.setSize(new Dimension(400, 15)); cursorPosition.setEditable(false); statusArea.setPreferredSize(new Dimension(400, 100)); statusArea.setModel(statusModel); /** * TOOLBAR * SOURCE * cursor position * status area */ topPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(toolbar, cnstrs); cnstrs = constraints(0, 1, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; topPanel.add(editorScrollPane, cnstrs); cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(cursorPosition, cnstrs); cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); statusArea.addMouseListener(new MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { final int row = statusArea.rowAtPoint(e.getPoint()); StatusMessage message = statusModel.getMessage(row); if (message.getLocation() != null) { moveCursorTo(message.getLocation()); } } }; }); statusArea.setFillsViewportHeight(true); statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane statusPane = new JScrollPane(statusArea); statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); statusPane.setPreferredSize(new Dimension(400, 100)); statusPane.setMinimumSize(new Dimension(100, 20)); cnstrs = constraints(0, 0, GridBagConstraints.BOTH); cnstrs.weightx = 1; cnstrs.weighty = 1; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = GridBagConstraints.REMAINDER; bottomPanel.add(statusPane, cnstrs); // setup frame frame = new JFrame( "DCPU-16 assembler " + Compiler.VERSION + " (c) 2012 by tobias.gierke@code-sourcery.de"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); splitPane.setBackground(Color.WHITE); frame.getContentPane().add(splitPane); frame.pack(); frame.setVisible(true); splitPane.setDividerLocation(0.9); }