List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:FontChooser.java
private void createUserInterface() { final JPanel content = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); setContentPane(content);// w w w . j av a 2 s . com content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = gbc.gridy = 0; content.add(new JLabel("Font"), gbc); ++gbc.gridx; content.add(new JLabel("Size"), gbc); if (_selectStyles) { ++gbc.gridx; content.add(new JLabel("Style"), gbc); } ++gbc.gridy; gbc.gridx = 0; _fontNamesCmb = new JComboBox( GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); content.add(_fontNamesCmb, gbc); ++gbc.gridx; _fontSizesCmb.setEditable(true); content.add(_fontSizesCmb, gbc); if (_selectStyles) { ++gbc.gridx; content.add(_boldChk, gbc); ++gbc.gridy; content.add(_italicChk, gbc); } gbc.gridx = 0; ++gbc.gridy; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; content.add(createPreviewPanel(), gbc); ++gbc.gridy; gbc.fill = GridBagConstraints.HORIZONTAL; content.add(createButtonsPanel(), gbc); pack(); setResizable(true); }
From source file:IconDemoApplet.java
public void init() { //Parse the applet parameters pictures = parseParameters();/* w w w.j a va2s .c o m*/ //If the applet tag doesn't provide an "IMAGE0" parameter, //display an error message. if (pictures.size() == 0) { captionLabel = new JLabel("No images listed in applet tag."); captionLabel.setHorizontalAlignment(JLabel.CENTER); getContentPane().add(captionLabel); return; } //NOW CREATE THE GUI COMPONENTS //A label to identify XX of XX. numberLabel = new JLabel("Picture " + (current + 1) + " of " + pictures.size()); numberLabel.setHorizontalAlignment(JLabel.LEFT); numberLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5)); //A label for the caption. final Photo first = (Photo) pictures.firstElement(); captionLabel = new JLabel(first.caption); captionLabel.setHorizontalAlignment(JLabel.CENTER); captionLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); //A label for displaying the photographs. photographLabel = new JLabel("Loading first image..."); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setVerticalAlignment(JLabel.CENTER); photographLabel.setVerticalTextPosition(JLabel.CENTER); photographLabel.setHorizontalTextPosition(JLabel.CENTER); photographLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); photographLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0), photographLabel.getBorder())); //Set the preferred size for the picture, //with room for the borders. Insets i = photographLabel.getInsets(); photographLabel.setPreferredSize( new Dimension(widthOfWidest + i.left + i.right, heightOfTallest + i.bottom + i.top)); //Create the next and previous buttons. ImageIcon nextIcon = new ImageIcon(getURL(imagedir + "right.gif")); ImageIcon dimmedNextIcon = new ImageIcon(getURL(imagedir + "dimmedRight.gif")); ImageIcon previousIcon = new ImageIcon(getURL(imagedir + "left.gif")); ImageIcon dimmedPreviousIcon = new ImageIcon(getURL(imagedir + "dimmedLeft.gif")); previousButton = new JButton("Previous Picture", previousIcon); previousButton.setDisabledIcon(dimmedPreviousIcon); previousButton.setVerticalTextPosition(AbstractButton.CENTER); previousButton.setHorizontalTextPosition(AbstractButton.RIGHT); previousButton.setMnemonic(KeyEvent.VK_P); previousButton.setActionCommand("previous"); previousButton.addActionListener(this); previousButton.setEnabled(false); nextButton = new JButton("Next Picture", nextIcon); nextButton.setDisabledIcon(dimmedNextIcon); nextButton.setVerticalTextPosition(AbstractButton.CENTER); nextButton.setHorizontalTextPosition(AbstractButton.LEFT); nextButton.setMnemonic(KeyEvent.VK_N); nextButton.setActionCommand("next"); nextButton.addActionListener(this); //Lay out the GUI. GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); Container contentPane = getContentPane(); contentPane.setLayout(layout); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(numberLabel, c); contentPane.add(numberLabel); layout.setConstraints(captionLabel, c); contentPane.add(captionLabel); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; layout.setConstraints(photographLabel, c); contentPane.add(photographLabel); c.gridwidth = GridBagConstraints.RELATIVE; c.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(previousButton, c); contentPane.add(previousButton); c.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(nextButton, c); contentPane.add(nextButton); //Start loading the image for the first photograph now. //The loadImage method uses a SwingWorker //to load the image in a separate thread. loadImage(imagedir + first.filename, current); }
From source file:de.topobyte.livecg.LiveCG.java
public void setup(boolean exitOnClose, Content content) { frame.setSize(800, 600);//from w w w . j a v a 2s . com if (exitOnClose) { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } frame.setTitle("Live CG"); GeometryEditor geometryEditor = new GeometryEditor(); Menu menu = new Menu(this, geometryEditor.getEditPane(), geometryEditor.getEditPane()); Toolbar toolbar = new Toolbar(geometryEditor.getEditPane(), geometryEditor.getEditPane()); toolbar.setFloatable(false); StatusBar statusBar = new StatusBar(); StatusBarMouseListener statusBarMouseListener = new StatusBarMouseListener(geometryEditor.getEditPane(), statusBar); geometryEditor.getEditPane().addMouseListener(statusBarMouseListener); geometryEditor.getEditPane().addMouseMotionListener(statusBarMouseListener); GridBagConstraints c = new GridBagConstraints(); JPanel mainPanel = new JPanel(new GridBagLayout()); frame.setJMenuBar(menu); frame.setContentPane(mainPanel); c.weightx = 1.0; c.fill = GridBagConstraints.BOTH; c.gridy = 0; c.weighty = 0.0; mainPanel.add(toolbar, c); c.gridy = 1; c.weighty = 1.0; mainPanel.add(geometryEditor, c); c.gridy = 2; c.weighty = 0.0; mainPanel.add(statusBar, c); frame.setLocationByPlatform(true); frame.setVisible(true); objectDialog = new ObjectDialog(frame, geometryEditor.getEditPane()); objectDialog.setSize(300, 300); contentDialog = new ContentDialog(frame, geometryEditor.getEditPane()); contentDialog.setSize(300, 300); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (showObjectDialog) { showObjectDialog(); } if (showContentDialog) { showContentDialog(); } } }); if (content != null) { geometryEditor.getEditPane().setContent(content); } }
From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java
private CaGridComponent() { super(new GridBagLayout()); addHeader();//from w w w. jav a 2 s.c om addcagridService(); addRunButton(); addRefreshButton(); addServiceURLButton(); checkButtons(); addResultPanel(); //force reference service to be constructed now rather than at first workflow run //getReferenceService(); }
From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java
/** * Class Constructor./*from ww w.j ava 2s . com*/ */ public AdhocQuerySearchPanel(final FindParamsPanel findParamsPanel, ConfigurationType cfg) { super(findParamsPanel, cfg); GridBagLayout gb = new GridBagLayout(); setLayout(gb); // create QuerySelection and QueryParams panels JPanel querySelectionPanel = createQuerySelectionPanel(); parentOfEntryPanel = createParentOfEntryPanels(); JScrollPane querySelectionScrollPane = new JScrollPane(querySelectionPanel); JScrollPane parentOfEntryScrollPane = new JScrollPane(parentOfEntryPanel); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, querySelectionScrollPane, parentOfEntryScrollPane); setLayout(new BorderLayout()); add(splitPane, BorderLayout.CENTER); //add listener for 'locale' bound property RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this); }
From source file:com.rapidminer.gui.new_plotter.gui.dialog.ManageZoomDialog.java
/** * Setup the GUI./*w w w . j a v a 2 s . c o m*/ */ private void setupGUI() { JPanel mainPanel = new JPanel(); this.setContentPane(mainPanel); // start layout mainPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 2, 5); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BorderLayout()); zoomRadiobutton = new JRadioButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.zoom.label")); zoomRadiobutton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.zoom.tip")); zoomRadiobutton.setSelected(true); radioPanel.add(zoomRadiobutton, BorderLayout.LINE_START); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; selectionRadiobutton = new JRadioButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.selection.label")); selectionRadiobutton .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.selection.tip")); selectionRadiobutton.setHorizontalAlignment(SwingConstants.CENTER); radioPanel.add(selectionRadiobutton, BorderLayout.LINE_END); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 3; this.add(radioPanel, gbc); ButtonGroup group = new ButtonGroup(); group.add(zoomRadiobutton); group.add(selectionRadiobutton); gbc.gridx = 0; gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.CENTER; rangeAxisSelectionCombobox = new JComboBox(); rangeAxisSelectionCombobox.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.range_axis_combobox.tip")); rangeAxisSelectionCombobox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateValueRange(); } }); this.add(rangeAxisSelectionCombobox, gbc); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 1; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 2, 5); JLabel domainRangeLowerBoundLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_lower_bound.label")); this.add(domainRangeLowerBoundLabel, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.insets = new Insets(2, 5, 2, 5); gbc.fill = GridBagConstraints.HORIZONTAL; domainRangeLowerBoundField = new JTextField(); domainRangeLowerBoundField.setText(String.valueOf(domainRangeLowerBound)); domainRangeLowerBoundField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyDomainRangeLowerBoundInput(input); } }); domainRangeLowerBoundField.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_lower_bound.tip")); this.add(domainRangeLowerBoundField, gbc); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.NONE; JLabel domainRangeUpperBoundLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_upper_bound.label")); this.add(domainRangeUpperBoundLabel, gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.fill = GridBagConstraints.HORIZONTAL; domainRangeUpperBoundField = new JTextField(); domainRangeUpperBoundField.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_upper_bound.tip")); domainRangeUpperBoundField.setText(String.valueOf(domainRangeUpperBound)); domainRangeUpperBoundField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyDomainRangeUpperBoundInput(input); } }); this.add(domainRangeUpperBoundField, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.fill = GridBagConstraints.NONE; JLabel valueRangeLowerBoundLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_lower_bound.label")); this.add(valueRangeLowerBoundLabel, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.fill = GridBagConstraints.HORIZONTAL; valueRangeLowerBoundField = new JTextField(); valueRangeLowerBoundField.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_lower_bound.tip")); valueRangeLowerBoundField.setText(String.valueOf(valueRangeLowerBound)); valueRangeLowerBoundField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyValueRangeLowerBoundInput(input); } }); this.add(valueRangeLowerBoundField, gbc); gbc.gridx = 0; gbc.gridy = 5; gbc.fill = GridBagConstraints.NONE; JLabel valueRangeUpperBoundLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_upper_bound.label")); this.add(valueRangeUpperBoundLabel, gbc); gbc.gridx = 1; gbc.gridy = 5; gbc.fill = GridBagConstraints.HORIZONTAL; valueRangeUpperBoundField = new JTextField(); valueRangeUpperBoundField.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_upper_bound.tip")); valueRangeUpperBoundField.setText(String.valueOf(valueRangeUpperBound)); valueRangeUpperBoundField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyValueRangeUpperBoundInput(input); } }); this.add(valueRangeUpperBoundField, gbc); gbc.gridx = 0; gbc.gridy = 6; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; this.add(new JSeparator(), gbc); gbc.gridx = 0; gbc.gridy = 7; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; JLabel colorMinValueLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_min_value.label")); this.add(colorMinValueLabel, gbc); gbc.gridx = 1; gbc.gridy = 7; gbc.fill = GridBagConstraints.HORIZONTAL; colorMinValueField = new JTextField(); colorMinValueField .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_min_value.tip")); colorMinValueField.setText(String.valueOf(colorMinValue)); colorMinValueField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyColorInput(input); } }); colorMinValueField.setEnabled(false); this.add(colorMinValueField, gbc); gbc.gridx = 0; gbc.gridy = 8; gbc.fill = GridBagConstraints.NONE; JLabel colorMaxValueLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_max_value.label")); this.add(colorMaxValueLabel, gbc); gbc.gridx = 1; gbc.gridy = 8; gbc.fill = GridBagConstraints.HORIZONTAL; colorMaxValueField = new JTextField(); colorMaxValueField .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_max_value.tip")); colorMaxValueField.setText(String.valueOf(colorMaxValue)); colorMaxValueField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyColorInput(input); } }); colorMaxValueField.setEnabled(false); this.add(colorMaxValueField, gbc); gbc.gridx = 1; gbc.gridy = 9; gbc.fill = GridBagConstraints.NONE; restoreColorButton = new JButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.label")); restoreColorButton .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.tip")); restoreColorButton.setIcon(SwingTools.createIcon( "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.icon"))); restoreColorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LinkAndBrushSelection linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.RESTORE_COLOR, new LinkedList<Pair<Integer, Range>>(), new LinkedList<Pair<Integer, Range>>(), null, null, engine.getPlotInstance()); engine.getChartPanel().informLinkAndBrushSelectionListeners(linkAndBrushSelection); updateColorValues(); } }); restoreColorButton.setEnabled(false); this.add(restoreColorButton, gbc); gbc.gridx = 0; gbc.gridy = 10; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(2, 5, 5, 5); this.add(new JSeparator(), gbc); gbc.gridx = 0; gbc.gridy = 11; gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.label")); okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.tip")); okButton.setIcon(SwingTools .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.icon"))); okButton.setMnemonic( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.mne").toCharArray()[0]); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // make sure fields have correct values boolean fieldsPassedChecks = checkFields(); if (!fieldsPassedChecks) { return; } Object selectedItem = rangeAxisSelectionCombobox.getSelectedItem(); if (selectedItem != null && selectedItem instanceof RangeAxisConfig) { RangeAxisConfig config = (RangeAxisConfig) selectedItem; boolean zoomOnLinkAndBrushSelection = engine.getChartPanel().getZoomOnLinkAndBrushSelection(); Range domainRange = new Range(Double.parseDouble(domainRangeLowerBoundField.getText()), Double.parseDouble(domainRangeUpperBoundField.getText())); Range valueRange = new Range(Double.parseDouble(valueRangeLowerBoundField.getText()), Double.parseDouble(valueRangeUpperBoundField.getText())); LinkedList<Pair<Integer, Range>> domainRangeList = new LinkedList<Pair<Integer, Range>>(); // only add domain zoom if != 0 if (domainRange.getUpperBound() != 0) { domainRangeList.add(new Pair<Integer, Range>(0, domainRange)); } LinkedList<Pair<Integer, Range>> valueRangeList = new LinkedList<Pair<Integer, Range>>(); // only add range zoom if at least one RangeAxisConfig exists if (engine.getPlotInstance().getMasterPlotConfiguration().getRangeAxisConfigs().size() > 0) { if (valueRange.getUpperBound() != 0) { // only add value zoom if != 0 valueRangeList.add( new Pair<Integer, Range>(engine.getPlotInstance().getMasterPlotConfiguration() .getIndexOfRangeAxisConfigById(config.getId()), valueRange)); } } // zoom or select or color LinkAndBrushSelection linkAndBrushSelection = null; if (zoomRadiobutton.isSelected()) { linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.ZOOM_IN, domainRangeList, valueRangeList); if (isColorChanged(Double.parseDouble(colorMinValueField.getText()), Double.parseDouble(colorMaxValueField.getText()))) { linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.COLOR_ZOOM, domainRangeList, valueRangeList, Double.parseDouble(colorMinValueField.getText()), Double.parseDouble(colorMaxValueField.getText()), engine.getPlotInstance()); } } else if (selectionRadiobutton.isSelected()) { linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.SELECTION, domainRangeList, valueRangeList); if (isColorChanged(Double.parseDouble(colorMinValueField.getText()), Double.parseDouble(colorMaxValueField.getText()))) { linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.COLOR_SELECTION, domainRangeList, valueRangeList, Double.parseDouble(colorMinValueField.getText()), Double.parseDouble(colorMaxValueField.getText()), engine.getPlotInstance()); } } engine.getChartPanel().informLinkAndBrushSelectionListeners(linkAndBrushSelection); engine.getChartPanel().setZoomOnLinkAndBrushSelection(zoomOnLinkAndBrushSelection); } else { return; } ManageZoomDialog.this.dispose(); } }); okButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { okButton.doClick(); } } }); this.add(okButton, gbc); gbc.gridx = 2; gbc.gridy = 11; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; cancelButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.label")); cancelButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.tip")); cancelButton.setIcon(SwingTools .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.icon"))); cancelButton.setMnemonic( I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.mne").toCharArray()[0]); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // cancel requested, close dialog ManageZoomDialog.this.dispose(); } }); this.add(cancelButton, gbc); // misc settings this.setMinimumSize(new Dimension(375, 360)); // center dialog this.setLocationRelativeTo(null); this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.title.label")); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setModal(true); this.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { okButton.requestFocusInWindow(); } }); }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
private void initializeComponent() { if (!this.initialized) { logger.info("Initializing the main window."); if (AssuranceUtils.getPlatform() == Platform.MAC) { System.setProperty("apple.laf.useScreenMenuBar", "true"); com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication(); MacApplicationAdapter macAdapter = new MacApplicationAdapter(this); macApplication.addApplicationListener(macAdapter); macApplication.setEnabledPreferencesMenu(true); }//from w ww . j av a 2 s. co m this.setTitle(Application.applicationShortName); this.setDefaultCloseOperation(EXIT_ON_CLOSE); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); this.topArea = new JTabbedPane(); this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150)); this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150)); this.topArea.addTab("Scan", this.scanLaunchPanel); this.topArea.addTab("History", this.scanHistoryPanel); this.resultsPanel.setPreferredSize(new Dimension(600, 400)); this.topArea.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { resultsPanel.resetPanel(); // NOTE: This isn't ideal. It feels brittle. if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) { viewHistoryMenuItem.setSelected(true); } else { viewScanMenuItem.setSelected(true); } } }); GridBagConstraints topPanelConstraints = new GridBagConstraints(); topPanelConstraints.anchor = GridBagConstraints.NORTH; topPanelConstraints.fill = GridBagConstraints.BOTH; topPanelConstraints.gridx = 0; topPanelConstraints.gridy = 0; topPanelConstraints.weightx = 1.0; topPanelConstraints.weighty = 0.33; topPanelConstraints.gridheight = 1; topPanelConstraints.gridwidth = 1; topPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.topArea, topPanelConstraints); GridBagConstraints resultsPanelConstraints = new GridBagConstraints(); resultsPanelConstraints.anchor = GridBagConstraints.SOUTH; resultsPanelConstraints.fill = GridBagConstraints.BOTH; resultsPanelConstraints.gridx = 0; resultsPanelConstraints.gridy = 1; resultsPanelConstraints.weightx = 1.0; resultsPanelConstraints.weighty = 0.67; resultsPanelConstraints.gridheight = 1; resultsPanelConstraints.gridwidth = 1; resultsPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.resultsPanel, resultsPanelConstraints); this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this); this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this); this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this); JMenu menu; JMenuItem menuItem; menuBar = new JMenuBar(); StringBuilder accessiblityLabel = new StringBuilder(128); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu(Application.applicationShortName); menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.quitApplicationAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Display information about this version of ") .append(Application.applicationShortName).append(".").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.aboutApplicationAction); menu.add(menuItem); } menu = new JMenu("Scan"); menu.setMnemonic(KeyEvent.VK_S); menu.getAccessibleContext().setAccessibleDescription("Actions for file scans"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Launch a scan using the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription( "Launch a scan using the selected scan definition and merge the results"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAndMergeAction); menu.add(menuItem); menu = new JMenu("Results"); menu.setMnemonic(KeyEvent.VK_R); menu.getAccessibleContext().setAccessibleDescription("Actions for scan results"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the source file with the target file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceSourceAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the target file with the source file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceTargetAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.sourceAttributesAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.targetAttributesAction); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString()); accessiblityLabel.setLength(0); menuBar.add(menu); ButtonGroup group = new ButtonGroup(); this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel); this.viewScanMenuItem.addActionListener(this); this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction); this.viewScanMenuItem.setSelected(true); group.add(this.viewScanMenuItem); menu.add(this.viewScanMenuItem); this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel); this.viewHistoryMenuItem.addActionListener(this); this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction); this.viewHistoryMenuItem.setSelected(true); group.add(this.viewHistoryMenuItem); menu.add(this.viewHistoryMenuItem); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu("Tools"); menu.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Additional actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Change settings for the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.displaySettingsAction); menu.add(menuItem); } this.setJMenuBar(menuBar); this.initialized = true; } }
From source file:com.vgi.mafscaling.Rescale.java
private void createDataTab() { JPanel dataPanel = new JPanel(); add(dataPanel, "<html><div style='text-align: center;'>D<br>a<br>t<br>a</div></html>"); GridBagLayout gbl_dataPanel = new GridBagLayout(); gbl_dataPanel.columnWidths = new int[] { 0 }; gbl_dataPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_dataPanel.columnWeights = new double[] { 0.0 }; gbl_dataPanel.rowWeights = new double[] { 0.0, 0.0, 1.0 }; dataPanel.setLayout(gbl_dataPanel);// w ww . j av a 2 s. c o m createControlPanel(dataPanel); createMafScalesScrollPane(dataPanel); createGraghPanel(dataPanel); }
From source file:com.vgi.mafscaling.MafCompare.java
/** * Initialize the contents of the frame. *///from ww w .ja v a2s.co m private void initialize() { try { ImageIcon tableImage = new ImageIcon(getClass().getResource("/table.jpg")); setTitle(Title); setIconImage(tableImage.getImage()); setBounds(100, 100, 621, 372); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setSize(Config.getCompWindowSize()); setLocation(Config.getCompWindowLocation()); setLocationRelativeTo(null); setVisible(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Utils.clearTable(origMafTable); Utils.clearTable(newMafTable); Utils.clearTable(compMafTable); Config.setCompWindowSize(getSize()); Config.setCompWindowLocation(getLocation()); origMafData.clear(); newMafData.clear(); } }); JPanel dataPanel = new JPanel(); GridBagLayout gbl_dataPanel = new GridBagLayout(); gbl_dataPanel.columnWidths = new int[] { 0, 0, 0 }; gbl_dataPanel.rowHeights = new int[] { RowHeight, RowHeight, RowHeight, RowHeight, RowHeight, 0 }; gbl_dataPanel.columnWeights = new double[] { 0.0, 0.0, 0.0 }; gbl_dataPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; dataPanel.setLayout(gbl_dataPanel); getContentPane().add(dataPanel); JLabel origLabel = new JLabel(origMaf); GridBagConstraints gbc_origLabel = new GridBagConstraints(); gbc_origLabel.anchor = GridBagConstraints.PAGE_START; gbc_origLabel.insets = new Insets(1, 1, 1, 5); gbc_origLabel.weightx = 0; gbc_origLabel.weighty = 0; gbc_origLabel.gridx = 0; gbc_origLabel.gridy = 0; gbc_origLabel.gridheight = 2; dataPanel.add(origLabel, gbc_origLabel); JLabel newLabel = new JLabel(newMaf); GridBagConstraints gbc_newLabel = new GridBagConstraints(); gbc_newLabel.anchor = GridBagConstraints.PAGE_START; gbc_newLabel.insets = new Insets(1, 1, 1, 5); gbc_newLabel.weightx = 0; gbc_newLabel.weighty = 0; gbc_newLabel.gridx = 0; gbc_newLabel.gridy = 2; gbc_newLabel.gridheight = 2; dataPanel.add(newLabel, gbc_newLabel); JLabel compLabel = new JLabel("Change"); GridBagConstraints gbc_compLabel = new GridBagConstraints(); gbc_compLabel.anchor = GridBagConstraints.PAGE_START; gbc_compLabel.insets = new Insets(1, 1, 1, 5); gbc_compLabel.weightx = 0; gbc_compLabel.weighty = 0; gbc_compLabel.gridx = 0; gbc_compLabel.gridy = 4; dataPanel.add(compLabel, gbc_compLabel); JLabel origVoltLabel = new JLabel("volt"); GridBagConstraints gbc_origVoltLabel = new GridBagConstraints(); gbc_origVoltLabel.anchor = GridBagConstraints.PAGE_START; gbc_origVoltLabel.insets = new Insets(1, 1, 1, 5); gbc_origVoltLabel.weightx = 0; gbc_origVoltLabel.weighty = 0; gbc_origVoltLabel.gridx = 1; gbc_origVoltLabel.gridy = 0; dataPanel.add(origVoltLabel, gbc_origVoltLabel); JLabel origGsLabel = new JLabel(" g/s"); GridBagConstraints gbc_origGsLabel = new GridBagConstraints(); gbc_origGsLabel.anchor = GridBagConstraints.PAGE_START; gbc_origGsLabel.insets = new Insets(1, 1, 1, 5); gbc_origGsLabel.weightx = 0; gbc_origGsLabel.weighty = 0; gbc_origGsLabel.gridx = 1; gbc_origGsLabel.gridy = 1; dataPanel.add(origGsLabel, gbc_origGsLabel); JLabel newVoltLabel = new JLabel("volt"); GridBagConstraints gbc_newVoltLabel = new GridBagConstraints(); gbc_newVoltLabel.anchor = GridBagConstraints.PAGE_START; gbc_newVoltLabel.insets = new Insets(1, 1, 1, 5); gbc_newVoltLabel.weightx = 0; gbc_newVoltLabel.weighty = 0; gbc_newVoltLabel.gridx = 1; gbc_newVoltLabel.gridy = 2; dataPanel.add(newVoltLabel, gbc_newVoltLabel); JLabel newGsLabel = new JLabel(" g/s"); GridBagConstraints gbc_newGsLabel = new GridBagConstraints(); gbc_newGsLabel.anchor = GridBagConstraints.PAGE_START; gbc_newGsLabel.insets = new Insets(1, 1, 1, 5); gbc_newGsLabel.weightx = 0; gbc_newGsLabel.weighty = 0; gbc_newGsLabel.gridx = 1; gbc_newGsLabel.gridy = 3; dataPanel.add(newGsLabel, gbc_newGsLabel); JLabel compPctLabel = new JLabel(" % "); GridBagConstraints gbc_compPctLabel = new GridBagConstraints(); gbc_compPctLabel.anchor = GridBagConstraints.PAGE_START; gbc_compPctLabel.insets = new Insets(1, 1, 1, 5); gbc_compPctLabel.weightx = 0; gbc_compPctLabel.weighty = 0; gbc_compPctLabel.gridx = 1; gbc_compPctLabel.gridy = 4; dataPanel.add(compPctLabel, gbc_compPctLabel); JPanel tablesPanel = new JPanel(); GridBagLayout gbl_tablesPanel = new GridBagLayout(); gbl_tablesPanel.columnWidths = new int[] { 0 }; gbl_tablesPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_tablesPanel.columnWeights = new double[] { 0.0 }; gbl_tablesPanel.rowWeights = new double[] { 0.0, 0.0, 1.0 }; tablesPanel.setLayout(gbl_tablesPanel); JScrollPane mafScrollPane = new JScrollPane(tablesPanel); mafScrollPane.setMinimumSize(new Dimension(1600, 107)); mafScrollPane.getHorizontalScrollBar().setMaximumSize(new Dimension(20, 20)); mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); GridBagConstraints gbc_mafScrollPane = new GridBagConstraints(); gbc_mafScrollPane.weightx = 1.0; gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START; gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL; gbc_mafScrollPane.gridx = 2; gbc_mafScrollPane.gridy = 0; gbc_mafScrollPane.gridheight = 5; dataPanel.add(mafScrollPane, gbc_mafScrollPane); origMafTable = new JTable(); origMafTable.setColumnSelectionAllowed(true); origMafTable.setCellSelectionEnabled(true); origMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); origMafTable.setRowHeight(RowHeight); origMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); origMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); origMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount)); origMafTable.setTableHeader(null); Utils.initializeTable(origMafTable, ColumnWidth); GridBagConstraints gbc_origMafTable = new GridBagConstraints(); gbc_origMafTable.anchor = GridBagConstraints.PAGE_START; gbc_origMafTable.insets = new Insets(0, 0, 0, 0); gbc_origMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_origMafTable.weightx = 1.0; gbc_origMafTable.weighty = 0; gbc_origMafTable.gridx = 0; gbc_origMafTable.gridy = 0; tablesPanel.add(origMafTable, gbc_origMafTable); excelAdapter.addTable(origMafTable, false, false, false, false, true, false, true, false, true); newMafTable = new JTable(); newMafTable.setColumnSelectionAllowed(true); newMafTable.setCellSelectionEnabled(true); newMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); newMafTable.setRowHeight(RowHeight); newMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); newMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); newMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount)); newMafTable.setTableHeader(null); Utils.initializeTable(newMafTable, ColumnWidth); GridBagConstraints gbc_newMafTable = new GridBagConstraints(); gbc_newMafTable.anchor = GridBagConstraints.PAGE_START; gbc_newMafTable.insets = new Insets(0, 0, 0, 0); gbc_newMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_newMafTable.weightx = 1.0; gbc_newMafTable.weighty = 0; gbc_newMafTable.gridx = 0; gbc_newMafTable.gridy = 1; tablesPanel.add(newMafTable, gbc_newMafTable); excelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true); compMafTable = new JTable(); compMafTable.setColumnSelectionAllowed(true); compMafTable.setCellSelectionEnabled(true); compMafTable.setBorder(new LineBorder(new Color(0, 0, 0))); compMafTable.setRowHeight(RowHeight); compMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); compMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); compMafTable.setModel(new DefaultTableModel(1, MafTableColumnCount)); compMafTable.setTableHeader(null); Utils.initializeTable(compMafTable, ColumnWidth); NumberFormatRenderer numericRenderer = new NumberFormatRenderer(); numericRenderer.setFormatter(new DecimalFormat("0.000")); compMafTable.setDefaultRenderer(Object.class, numericRenderer); GridBagConstraints gbc_compMafTable = new GridBagConstraints(); gbc_compMafTable.anchor = GridBagConstraints.PAGE_START; gbc_compMafTable.insets = new Insets(0, 0, 0, 0); gbc_compMafTable.fill = GridBagConstraints.HORIZONTAL; gbc_compMafTable.weightx = 1.0; gbc_compMafTable.weighty = 0; gbc_compMafTable.gridx = 0; gbc_compMafTable.gridy = 2; tablesPanel.add(compMafTable, gbc_compMafTable); compExcelAdapter.addTable(compMafTable, false, true, false, false, false, true, true, false, true); TableModelListener origTableListener = new TableModelListener() { public void tableChanged(TableModelEvent tme) { if (tme.getType() == TableModelEvent.UPDATE) { int colCount = origMafTable.getColumnCount(); Utils.ensureColumnCount(colCount, newMafTable); Utils.ensureColumnCount(colCount, compMafTable); origMafData.clear(); String origY, origX, newY; for (int i = 0; i < colCount; ++i) { origY = origMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, origY)) { origX = origMafTable.getValueAt(0, i).toString(); if (Pattern.matches(Utils.fpRegex, origX)) origMafData.add(Double.valueOf(origX), Double.valueOf(origY), false); newY = newMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, newY)) compMafTable.setValueAt( ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i); } else break; } origMafData.fireSeriesChanged(); } } }; TableModelListener newTableListener = new TableModelListener() { public void tableChanged(TableModelEvent tme) { if (tme.getType() == TableModelEvent.UPDATE) { int colCount = newMafTable.getColumnCount(); Utils.ensureColumnCount(colCount, origMafTable); Utils.ensureColumnCount(colCount, compMafTable); newMafData.clear(); String newY, newX, origY; for (int i = 0; i < colCount; ++i) { newY = newMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, newY)) { newX = newMafTable.getValueAt(0, i).toString(); if (Pattern.matches(Utils.fpRegex, newX)) newMafData.add(Double.valueOf(newX), Double.valueOf(newY), false); origY = origMafTable.getValueAt(1, i).toString(); if (Pattern.matches(Utils.fpRegex, origY)) compMafTable.setValueAt( ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i); } else break; } newMafData.fireSeriesChanged(); } } }; origMafTable.getModel().addTableModelListener(origTableListener); newMafTable.getModel().addTableModelListener(newTableListener); Action action = new AbstractAction() { private static final long serialVersionUID = 8148393537657380215L; public void actionPerformed(ActionEvent e) { TableCellListener tcl = (TableCellListener) e.getSource(); if (Pattern.matches(Utils.fpRegex, compMafTable.getValueAt(0, tcl.getColumn()).toString())) { if (Pattern.matches(Utils.fpRegex, origMafTable.getValueAt(1, tcl.getColumn()).toString())) { double corr = Double.valueOf(compMafTable.getValueAt(0, tcl.getColumn()).toString()) / 100.0 + 1.0; newMafTable.setValueAt( Double.valueOf(origMafTable.getValueAt(1, tcl.getColumn()).toString()) * corr, 1, tcl.getColumn()); } } else compMafTable.setValueAt(tcl.getOldValue(), 0, tcl.getColumn()); } }; setCompMafCellListener(new TableCellListener(compMafTable, action)); // CHART JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL, false, true, false); chart.setBorderVisible(true); chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.PAGE_START; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.insets = new Insets(1, 1, 1, 1); gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 5; gbl_chartPanel.gridheight = 1; gbl_chartPanel.gridwidth = 3; dataPanel.add(chartPanel, gbl_chartPanel); XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesStroke(1, stroke); lineRenderer.setSeriesPaint(0, new Color(201, 0, 0)); lineRenderer.setSeriesPaint(1, new Color(0, 0, 255)); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setSeriesShape(1, ShapeUtilities.createDownTriangle((float) 2.5)); lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() { private static final long serialVersionUID = -4045338273187150888L; public String generateLabel(XYDataset dataset, int series) { XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series); return xys.getDescription(); } }); NumberAxis mafvDomain = new NumberAxis(XAxisName); mafvDomain.setAutoRangeIncludesZero(false); mafvDomain.setAutoRange(true); mafvDomain.setAutoRangeStickyZero(false); NumberAxis mafgsRange = new NumberAxis(YAxisName); mafgsRange.setAutoRangeIncludesZero(false); mafgsRange.setAutoRange(true); mafgsRange.setAutoRangeStickyZero(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); origMafData.setDescription(origMaf); newMafData.setDescription(newMaf); lineDataset.addSeries(origMafData); lineDataset.addSeries(newMafData); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, mafvDomain); plot.setRangeAxis(0, mafgsRange); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); } catch (Exception e) { logger.error(e); } }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
public JPanel getSelectFramePanel() { if (selectFramePanel == null) { selectFramePanel = new JPanel(new GridBagLayout()); this.selectFrameButtons = new ArrayList<>(); fillPanelWithButton(1);/* www . j a v a 2 s. c o m*/ } return selectFramePanel; }