List of usage examples for javax.swing JTabbedPane JTabbedPane
public JTabbedPane()
TabbedPane
with a default tab placement of JTabbedPane.TOP
. From source file:org.biojava.bio.view.MotifAnalyzer.java
private void initComponents() { mainFrame = new JFrame(); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setBackground(Color.white); mainFrame.setTitle("Motif Analayzer"); mainFrame.setJMenuBar(getJJMenuBar()); tabs = new JTabbedPane(); tabs.setFont(tabFont);/*from ww w. j a v a 2 s .c om*/ mainFrame.add(tabs, BorderLayout.CENTER); tabs.addTab("Input", getInputTab()); seqViewerTab = new JPanel(); seqViewerTab.setLayout(new BorderLayout()); // has a problem when view change in horizontal scrolling/////////////// JScrollPane s = new JScrollPane(seqViewerTab);//, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); tabs.addTab("Sequence Viewer", s); tabs.addTab("Motif Scores", getMotifScoreTab()); mainFrame.setSize(800, 600); mainFrame.setExtendedState(mainFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH); mainFrame.setVisible(true); }
From source file:com.tascape.qa.th.android.driver.App.java
/** * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction. * * @param timeoutMinutes timeout in minutes to fail the manual steps * * @throws Exception if case of error//from w ww . jav a 2 s .c o m */ public void interactManually(int timeoutMinutes) throws Exception { LOG.info("Start manual UI interaction"); long end = System.currentTimeMillis() + timeoutMinutes * 60000L; AtomicBoolean visible = new AtomicBoolean(true); AtomicBoolean pass = new AtomicBoolean(false); String tName = Thread.currentThread().getName() + "m"; SwingUtilities.invokeLater(() -> { JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail()); jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); JPanel jpContent = new JPanel(new BorderLayout()); jd.setContentPane(jpContent); jpContent.setPreferredSize(new Dimension(1088, 828)); jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel jpInfo = new JPanel(); jpContent.add(jpInfo, BorderLayout.PAGE_START); jpInfo.setLayout(new BorderLayout()); { JButton jb = new JButton("PASS"); jb.setForeground(Color.green.darker()); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_START); jb.addActionListener(event -> { pass.set(true); jd.dispose(); visible.set(false); }); } { JButton jb = new JButton("FAIL"); jb.setForeground(Color.red); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_END); jb.addActionListener(event -> { pass.set(false); jd.dispose(); visible.set(false); }); } JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); new SwingWorker<Long, Long>() { @Override protected Long doInBackground() throws Exception { while (System.currentTimeMillis() < end) { Thread.sleep(1000); long left = (end - System.currentTimeMillis()) / 1000; this.publish(left); } return 0L; } @Override protected void process(List<Long> chunks) { Long l = chunks.get(chunks.size() - 1); jlTimeout.setText(l + " seconds left"); if (l < 850) { jlTimeout.setForeground(Color.red); } } }.execute(); JPanel jpResponse = new JPanel(new BorderLayout()); JPanel jpProgress = new JPanel(new BorderLayout()); jpResponse.add(jpProgress, BorderLayout.PAGE_START); JTextArea jtaJson = new JTextArea(); jtaJson.setEditable(false); jtaJson.setTabSize(4); Font font = jtaJson.getFont(); jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize())); JTree jtView = new JTree(); JTabbedPane jtp = new JTabbedPane(); jtp.add("tree", new JScrollPane(jtView)); jtp.add("json", new JScrollPane(jtaJson)); jpResponse.add(jtp, BorderLayout.CENTER); JPanel jpScreen = new JPanel(); jpScreen.setMinimumSize(new Dimension(200, 200)); jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS)); JScrollPane jsp1 = new JScrollPane(jpScreen); jpResponse.add(jsp1, BorderLayout.LINE_START); JPanel jpJs = new JPanel(new BorderLayout()); JTextArea jtaJs = new JTextArea(); jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER); JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs); jSplitPane.setResizeWeight(0.88); jpContent.add(jSplitPane, BorderLayout.CENTER); JPanel jpLog = new JPanel(); jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS)); JCheckBox jcbTap = new JCheckBox("Enable Click", null, false); jpLog.add(jcbTap); jpLog.add(Box.createHorizontalStrut(8)); JButton jbLogUi = new JButton("Log Screen"); jpResponse.add(jpLog, BorderLayout.PAGE_END); { jpLog.add(jbLogUi); jbLogUi.addActionListener((ActionEvent event) -> { jtaJson.setText("waiting for screenshot..."); Thread t = new Thread(tName) { @Override public void run() { LOG.debug("\n\n"); try { WindowHierarchy wh = device.loadWindowHierarchy(); jtView.setModel(getModel(wh)); jtaJson.setText(""); jtaJson.append(wh.root.toJson().toString(2)); jtaJson.append("\n"); File png = device.takeDeviceScreenshot(); BufferedImage image = ImageIO.read(png); int w = device.getDisplayWidth(); int h = device.getDisplayHeight(); BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(image, 0, 0, w, h, null); g2.dispose(); JLabel jLabel = new JLabel(new ImageIcon(resizedImg)); jpScreen.removeAll(); jsp1.setPreferredSize(new Dimension(w + 30, h)); jpScreen.add(jLabel); jLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY()); if (jcbTap.isSelected()) { device.click(e.getPoint().x, e.getPoint().y); device.waitForIdle(); jbLogUi.doClick(); } } }); } catch (Exception ex) { LOG.error("Cannot log screen", ex); jtaJson.append("Cannot log screen"); } jtaJson.append("\n\n\n"); LOG.debug("\n\n"); jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1); jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1); } }; t.start(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbLogMsg = new JButton("Log Message"); jpLog.add(jbLogMsg); JTextField jtMsg = new JTextField(10); jpLog.add(jtMsg); jtMsg.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent pE) { } @Override public void focusGained(final FocusEvent pE) { jtMsg.selectAll(); } }); jtMsg.addKeyListener(new KeyAdapter() { @Override public void keyPressed(java.awt.event.KeyEvent e) { if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) { jbLogMsg.doClick(); } } }); jbLogMsg.addActionListener(event -> { Thread t = new Thread(tName) { @Override public void run() { String msg = jtMsg.getText(); if (StringUtils.isNotBlank(msg)) { LOG.info("{}", msg); jtMsg.selectAll(); } } }; t.start(); try { t.join(); } catch (InterruptedException ex) { LOG.error("Cannot take screenshot", ex); } jtMsg.requestFocus(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbClear = new JButton("Clear"); jpLog.add(jbClear); jbClear.addActionListener(event -> { jtaJson.setText(""); }); } JPanel jpAction = new JPanel(); jpContent.add(jpAction, BorderLayout.PAGE_END); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jpJs.add(jpAction, BorderLayout.PAGE_END); jd.pack(); jd.setVisible(true); jd.setLocationRelativeTo(null); jbLogUi.doClick(); }); while (visible.get()) { if (System.currentTimeMillis() > end) { LOG.error("Manual UI interaction timeout"); break; } Thread.sleep(500); } if (pass.get()) { LOG.info("Manual UI Interaction returns PASS"); } else { Assert.fail("Manual UI Interaction returns FAIL"); } }
From source file:com.diversityarrays.kdxplore.boxplot.BoxPlotPanel.java
public BoxPlotPanel(PlotInfoProvider pip, VisualisationToolId<?> vtoolId, SelectedValueStore svs, String title, VisToolData data, Supplier<TraitColorProvider> colorProviderFactory, SuppressionHandler suppressionHandler) { super(title, vtoolId, svs, nextId++, data.traitInstances, data.context.getTrial(), suppressionHandler); int ndecs = 0; for (TraitInstance ti : traitInstances) { String vr = ti.trait.getTraitValRule(); if (!Check.isEmpty(vr)) { try { ValidationRule vrule = ValidationRule.create(vr); ndecs = Math.max(ndecs, vrule.getNumberOfDecimalPlaces()); } catch (UnsupportedOperationException | InvalidRuleException snh) { throw new RuntimeException(ti.trait.getTraitValRule(), snh); }// ww w . j av a 2 s. c o m } } this.maxNumberOfDecimalPlaces = ndecs; Function<TraitInstance, List<KdxSample>> sampleProvider = new Function<TraitInstance, List<KdxSample>>() { @Override public List<KdxSample> apply(TraitInstance ti) { return pip.getSampleMeasurements(ti); } }; tivrByTi = VisToolUtil.buildTraitInstanceValueRetrieverMap(trial, traitInstances, sampleProvider); this.plotInfoProvider = pip; this.colorProviderFactory = colorProviderFactory; if (Check.isEmpty(data.plotSpecimensToGraph)) { plotSpecimens = new ArrayList<>(); VisToolUtil.collectPlotSpecimens(plotInfoProvider.getPlots(), new Consumer<PlotOrSpecimen>() { @Override public void accept(PlotOrSpecimen pos) { plotSpecimens.add(pos); } }); selectedPlotSpecimenCount = 0; } else { plotSpecimens = data.plotSpecimensToGraph; selectedPlotSpecimenCount = plotSpecimens.size(); } JComponent controlsOrLabel; String messageLine = selectedPlotSpecimenCount <= 0 ? null : Msg.MSG_ONLY_FOR_N_PLOTS(selectedPlotSpecimenCount); if (traitInstances.size() == 1) { curationControls = new CurationControls(true, // askAboutValueForUnscored suppressionHandler, selectedValueStore, toolPanelId, messageLine, traitNameStyle, Arrays.asList(traitInstances.get(0))); curationControls.setBorder(new EmptyBorder(2, 4, 2, 4)); controlsOrLabel = curationControls; } else { StringBuilder sb = new StringBuilder("<HTML>"); //$NON-NLS-1$ if (messageLine != null) { sb.append(messageLine).append("<br>"); //$NON-NLS-1$ } sb.append(Msg.HTML_CURATION_NOT_AVAILABLE_WITH_MULTIPLE_TRAITS()); controlsOrLabel = new JLabel(sb.toString()); } messagesAndCurationTabbedPane = new JTabbedPane(); messagesAndCurationTabbedPane.addTab(TAB_MESSAGES, new JScrollPane(reportTextArea)); messagesAndCurationTabbedPane.addTab(TAB_CURATION, controlsOrLabel); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, messagesAndCurationTabbedPane, new JLabel()); // placeholder splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.0); Box controls = generateControls(); add(controlsOrLabel, BorderLayout.NORTH); add(splitPane, BorderLayout.CENTER); add(controls, BorderLayout.SOUTH); generateGraph(Why.INITIAL); minSpinnerModel.addChangeListener(spinnerChangeListener); maxSpinnerModel.addChangeListener(spinnerChangeListener); NumberEditor formatterMin; NumberEditor formatterMax; stillChanging = true; try { if (maxNumberOfDecimalPlaces <= 0) { // integer minSpinnerModel.setStepSize(1); maxSpinnerModel.setStepSize(1); formatterMin = new JSpinner.NumberEditor(minSpinner, "0"); //$NON-NLS-1$ formatterMax = new JSpinner.NumberEditor(maxSpinner, "0"); //$NON-NLS-1$ } else { double stepSize = Math.pow(10, -maxNumberOfDecimalPlaces); minSpinnerModel.setStepSize(stepSize); maxSpinnerModel.setStepSize(stepSize); StringBuilder sb = new StringBuilder("0."); //$NON-NLS-1$ for (int i = maxNumberOfDecimalPlaces; --i >= 0;) { sb.append("0"); //$NON-NLS-1$ } String fmt = sb.toString(); formatterMin = new JSpinner.NumberEditor(minSpinner, fmt); formatterMax = new JSpinner.NumberEditor(maxSpinner, fmt); } } finally { stillChanging = false; } formatterMin.setEnabled(true); formatterMax.setEnabled(true); minSpinner.setEditor(formatterMin); maxSpinner.setEditor(formatterMax); minSpinner.setBorder(new EmptyBorder(3, 5, 3, 5)); maxSpinner.setBorder(new EmptyBorder(3, 5, 3, 5)); setSpinnerRanges(); }
From source file:fll.subjective.SubjectiveFrame.java
/** * Create a window to edit subjective scores. *//*from ww w . jav a 2 s . co m*/ public SubjectiveFrame() { super("Subjective Score Entry"); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(new BorderLayout()); final JPanel topPanel = new JPanel(); getContentPane().add(topPanel, BorderLayout.NORTH); final JButton quitButton = new JButton("Quit"); topPanel.add(quitButton); quitButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { quit(); } }); final JButton saveButton = new JButton("Save"); topPanel.add(saveButton); saveButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { try { save(); } catch (final IOException ioe) { JOptionPane.showMessageDialog(null, "Error writing to data file: " + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } }); final JButton summaryButton = new JButton("Summary"); topPanel.add(summaryButton); summaryButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { final SummaryDialog dialog = new SummaryDialog(SubjectiveFrame.this); dialog.pack(); dialog.setVisible(true); } }); final JButton compareButton = new JButton("Compare Scores"); topPanel.add(compareButton); compareButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { final File compareFile = chooseSubjectiveFile("Choose the file to compare with"); if (null != compareFile) { try { save(); } catch (final IOException ioe) { JOptionPane.showMessageDialog(null, "Error writing to data file: " + ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } try { final Collection<SubjectiveScoreDifference> diffs = SubjectiveUtils .compareSubjectiveFiles(getFile(), compareFile); if (null == diffs) { JOptionPane.showMessageDialog(null, "Challenge descriptors are different, comparison failed", "Error", JOptionPane.ERROR_MESSAGE); } else if (!diffs.isEmpty()) { showDifferencesDialog(diffs); } else { JOptionPane.showMessageDialog(null, "No differences found", "No Differences", JOptionPane.INFORMATION_MESSAGE); } } catch (final SAXParseException spe) { final String errorMessage = String.format( "Error parsing file line: %d column: %d%n Message: %s%n This may be caused by using the wrong version of the software attempting to parse a file that is not subjective data.", spe.getLineNumber(), spe.getColumnNumber(), spe.getMessage()); LOGGER.error(errorMessage, spe); JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); } catch (final SAXException se) { final String errorMessage = "The subjective scores file was found to be invalid, check that you are parsing a subjective scores file and not something else"; LOGGER.error(errorMessage, se); JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE); } catch (final IOException e) { LOGGER.error("Error reading compare file", e); JOptionPane.showMessageDialog(null, "Error reading compare file: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }); tabbedPane = new JTabbedPane(); getContentPane().add(tabbedPane, BorderLayout.CENTER); addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { quit(); } }); pack(); }
From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java
private JPanel buildBottomPane() { JPanel panel = new JPanel(); JTabbedPane tabbedPane = new JTabbedPane(); panel.setLayout(new BorderLayout()); panel.add(tabbedPane, BorderLayout.CENTER); tabbedPane.add("Symbol Profiling", new JScrollPane(symbolTable)); tabbedPane.add("Message Profiling", new JScrollPane(messageTable)); return panel; }
From source file:edu.ku.brc.specify.config.ResourceImportExportDlg.java
@Override public void createUI() { this.setHelpContext("Import"); super.createUI(); CellConstraints cc = new CellConstraints(); levelCBX = createComboBox();/*from w w w. j a va 2 s . com*/ DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); for (SpAppResourceDir curDir : contextMgr.getSpAppResourceList()) { SpAppResourceDir dir; if (curDir.getId() != null) { dir = session.get(SpAppResourceDir.class, curDir.getId()); dir.setTitle(curDir.getTitle()); // Force Load dir.getSpAppResources().size(); dir.getSpPersistedAppResources().size(); dir.getSpPersistedViewSets().size(); for (SpAppResource appRes : curDir.getSpAppResources()) { if (appRes.getId() == null) { dir.getSpAppResources().add(appRes); } } for (SpViewSetObj vso : curDir.getSpViewSets()) { if (vso.getId() == null) { dir.getSpViewSets().add(vso); } } } else { dir = (SpAppResourceDir) curDir.clone(); } dirs.add(dir); levelCBX.addItem(dir); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ResourceImportExportDlg.class, ex); } finally { if (session != null) { session.close(); } } PanelBuilder centerPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "p,10px,p")); centerPB.add(createLabel(UIRegistry.getLocalizedMessage("RIE_USR_LBL", userName)), cc.xy(2, 1)); centerPB.add(levelCBX, cc.xy(2, 3)); tabbedPane = new JTabbedPane(); PanelBuilder viewPanel = new PanelBuilder(new FormLayout("f:p:g,10px,f:p:g", "p,2px,f:p:g")); viewPanel.add(createLabel(getResourceString("RIE_VIEWSETS"), SwingConstants.CENTER), cc.xy(1, 1)); viewSetsList = new JList(viewSetsModel); viewSetsList.setCellRenderer(new ARListRenderer()); JScrollPane sp = new JScrollPane(viewSetsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(1, 3)); viewPanel.add(createLabel(getResourceString("RIE_VIEWS"), SwingConstants.CENTER), cc.xy(3, 1)); viewsList = new JList(viewsModel); viewsList.setCellRenderer(new ViewRenderer()); sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(3, 3)); viewsList.setEnabled(false); PanelBuilder resPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p")); resPane.add(createLabel(getResourceString("RIE_OTHER_RES"), SwingConstants.CENTER), cc.xy(1, 1)); resList = new JList(resModel); resList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(resList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); resPane.add(sp, cc.xy(1, 3)); PanelBuilder repPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g")); repPane.add(createLabel(getResourceString("RIE_REPORT_RES"), SwingConstants.CENTER), cc.xy(1, 1)); repList = new JList(repModel); repList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); repList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(repList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); repPane.add(sp, cc.xy(1, 3)); boolean addResourcesPanel = AppPreferences.getLocalPrefs().getBoolean("ADD_IMP_RES", false); viewsPanel = viewPanel.getPanel(); tabbedPane.addTab(getResourceString("RIE_VIEWSETS"), viewsPanel); if (addResourcesPanel) { resPanel = resPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_OTHER_RES"), resPanel); } repPanel = repPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_REPORT_RES"), repPanel); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p")); pb.add(centerPB.getPanel(), cc.xy(1, 1)); pb.add(tabbedPane, cc.xy(1, 3)); exportBtn = createButton(getResourceString("RIE_EXPORT")); importBtn = createButton(getResourceString("RIE_IMPORT")); revertBtn = createButton(getResourceString("RIE_REVERT")); PanelBuilder btnPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p,10px")); btnPB.add(exportBtn, cc.xy(2, 1)); btnPB.add(importBtn, cc.xy(4, 1)); btnPB.add(revertBtn, cc.xy(6, 1)); pb.add(btnPB.getPanel(), cc.xy(1, 5)); pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Component selectedComp = tabbedPane.getSelectedComponent(); if (selectedComp != null) { if (selectedComp == viewsPanel) { viewSetsList.setSelectedIndex(-1); } else if (selectedComp == resPanel) { resList.setSelectedIndex(-1); } else { repList.setSelectedIndex(-1); } //revertBtn.setVisible(selectedComp != repPanel); } enableUI(); // JGoodies Resizes the panel in the Dialog and // partially hides the buttons, this fixes that. Dimension size = ResourceImportExportDlg.this.getSize(); //ResourceImportExportDlg.this.pack(); //Dimension newSize = ResourceImportExportDlg.this.getSize(); Dimension newSize = ResourceImportExportDlg.this.getPreferredSize(); size.height = newSize.height; ResourceImportExportDlg.this.setSize(size); } }); levelCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { levelSelected(); } }); } }); levelCBX.setSelectedIndex(0); pack(); exportBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportResource(); } }); importBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importResource(); } }); revertBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { revertResource(); } }); viewSetsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (viewSetsList.getSelectedIndex() > -1) { resList.clearSelection(); repList.clearSelection(); } fillViewsList(); enableUI(); } } }); resList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); repList.clearSelection(); } enableUI(); } } }); repList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); resList.clearSelection(); } enableUI(); } } }); pack(); }
From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java
public COSMOSACDialog() { super("JCOSMO Simple"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); db = COSMOSACDataBase.getInstance(); COSMOSAC models[] = new COSMOSAC[5]; models[0] = new COSMOSAC(); models[1] = new COSMOPAC(); models[2] = new COSMOSAC_SVP(); models[3] = new COSMOSAC_G(); models[4] = new PCMSAC(); modelBox = new JComboBox(models); modelBox.addActionListener(this); JPanel north = new JPanel(new GridLayout(0, 2)); add(north, BorderLayout.NORTH); JPanel northAba1 = new JPanel(new GridLayout(0, 4)); JPanel northAba2 = new JPanel(new GridLayout(0, 2)); //Where the GUI is created: JMenuBar menuBar;//from w w w . ja va 2 s .c o m JMenu file, help; JMenuItem menuItem; //Create the menu bar. menuBar = new JMenuBar(); // the file menu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); menuBar.add(file); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.setActionCommand(QUIT); menuItem.addActionListener(this); file.add(menuItem); // the help menu help = new JMenu("Help"); file.setMnemonic(KeyEvent.VK_H); menuBar.add(help); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); menuItem.setActionCommand(ABOUT); menuItem.addActionListener(this); help.add(menuItem); setJMenuBar(menuBar); listModel = new DefaultListModel(); list = new JList(listModel); list.setBorder(BorderFactory.createTitledBorder("compounds")); list.setVisibleRowCount(2); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listScrollPane = new JScrollPane(list); JButton addButton = new JButton("Add"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AddCompoundDialog(COSMOSACDialog.this); } }); removeButton = new JButton("Remove"); removeButton.addActionListener(this); visibRemove(false); JButton calcButton = new JButton("Calculate"); calcButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildChart(); rebuildSigmaProfiles(); } }); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildSigmaProfiles(); } }); ignoreSGButton = new JCheckBox("Ignore SG"); ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term"); ignoreSGButton.addActionListener(this); JPanel but = new JPanel(new GridLayout(0, 1)); but.add(addButton, BorderLayout.EAST); but.add(removeButton, BorderLayout.EAST); but.add(modelBox); north.add(listScrollPane); north.add(but); northAba1.add(new JLabel("Temperature [K]")); northAba1.add(temperature = new JTextField(10)); temperature.setText("298"); northAba1.add(new JLabel("Sigma HB")); northAba1.add(sigmaHB = new JTextField(10)); northAba1.add(new JLabel("Sigma HB2")); northAba1.add(sigmaHB2 = new JTextField(10)); northAba1.add(new JLabel("Sigma HB3")); northAba1.add(sigmaHB3 = new JTextField(10)); northAba1.add(new JLabel("Charge HB")); northAba1.add(chargeHB = new JTextField(10)); northAba1.add(new JLabel("Sigma Disp")); northAba1.add(sigmaDisp = new JTextField(10)); northAba1.add(new JLabel("Charge Disp")); northAba1.add(chargeDisp = new JTextField(10)); northAba1.add(new JLabel("Beta")); northAba1.add(beta = new JTextField(10)); northAba1.add(new JLabel("fpol")); northAba1.add(fpol = new JTextField(10)); northAba1.add(new JLabel("Anorm")); northAba1.add(anorm = new JTextField(10)); northAba1.add(ignoreSGButton); northAba1.add(calcButton); northAba2.add(new JLabel("")); northAba2.add(refreshButton); // chart = new JLineChart(); // add(chart, BorderLayout.CENTER); // chart.setTitle("Gamma Plot"); // chart.setSubtitle(""); // chart.setXAxisLabel("Mole Fraction, x_1"); // chart.setYAxisLabel("ln gamma, gE/RT"); // chart.setSource(getTitle()); // chart.setLegendPosition(LegendPosition.BOTTOM); // chart.setShapesVisible(true); JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null, PlotOrientation.VERTICAL, true, true, false); plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(new Range(0.0, 1.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setUseFillPaint(true); r.setBaseFillPaint(Color.white); r.setBaseShapesVisible(true); JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null, PlotOrientation.VERTICAL, true, true, false); sigmaProfilePlot = sigmaProfileChart.getXYPlot(); sigmaProfilePlot.getDomainAxis().setAutoRange(false); sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025)); // sigmaProfilePlot.setBackgroundPaint(Color.lightGray); // sigmaProfilePlot.setDomainGridlinePaint(Color.white); // sigmaProfilePlot.setRangeGridlinePaint(Color.white); JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null, PlotOrientation.VERTICAL, true, true, false); plotSegGamma = (XYPlot) chartSegGamma.getPlot(); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(lnGammaInf1Label = new JLabel()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(lnGammaInf2Label = new JLabel()); south.add(Box.createHorizontalStrut(20)); south.add(new JLabel("<html>γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(gammaInf1Label = new JLabel()); south.add(new JLabel("<html>γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(gammaInf2Label = new JLabel()); JPanel aba1 = new JPanel(new BorderLayout()); aba1.add(northAba1, BorderLayout.NORTH); JPanel chartsPanel = new JPanel(new GridLayout(0, 2)); aba1.add(chartsPanel, BorderLayout.CENTER); chartsPanel.add(new ChartPanel(chart)); chartsPanel.add(new ChartPanel(chartSegGamma)); aba1.add(south, BorderLayout.SOUTH); JPanel aba2 = new JPanel(new BorderLayout()); aba2.add(northAba2, BorderLayout.NORTH); aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("gamma", aba1); tabbedPane.addTab("sigma", aba2); add(tabbedPane, BorderLayout.CENTER); // cosmosac.setAEffPrime(6.596176570595075); // cosmosac.setCoord(11.614599507917934); // cosmosac.setVnorm(56.36966406129967); // cosmosac.setAnorm(41.56058649432742); // cosmosac.setCHB(65330.19484947528); // cosmosac.setSigmaHB(0.008292411048046008); //Display the window. setSize(800, 600); setLocationRelativeTo(null); modelBox.setSelectedIndex(0); setVisible(true); // test for a mixture // addList("WATER"); // addList("H3O+1"); // addList("OH-1"); // addList("CL-1"); // addList("OXYGEN"); // addList("sec-butylamine"); // addList("hydrogen-fluoride"); // addList("ACETONE"); // addList("METHANOL"); // addList("ACETONE.opt"); // addList("METHANOL.opt"); // addList("METHYL-ETHYL-KETONE"); // addList("ETHANOL"); // addList("N-HEPTANE"); // addList("PROPIONIC-ACID"); // addList("EMIM"); // addList("NTF2"); // addList("DCA"); // addList("N-OCTANE"); addList("ETHYLENE CARBONATE"); addList("BENZENE"); addList("TOLUENE"); removeButton.setEnabled(true); }
From source file:net.sf.jhylafax.JHylaFAX.java
private void initializeContent() { setTitle("JHylaFAX"); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { exit();//from ww w .j a va 2 s .c om } }); mainTabbedPane = new JTabbedPane(); mainTabbedPane.setBorder(GUIHelper.createEmptyBorder(10)); getContentPane().add(mainTabbedPane, BorderLayout.CENTER); recvqPanel = new ReceiveQueuePanel("recvq"); mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_inbox.png"), recvqPanel); sendqPanel = new JobQueuePanel("sendq"); mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_outbox.png"), sendqPanel); doneqPanel = new JobQueuePanel("doneq"); mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_sent_mail.png"), doneqPanel); pollqPanel = new JobQueuePanel("pollq"); if (Settings.SHOW_POLLQ.getValue()) { mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_print.png"), pollqPanel); } docqPanel = new DocumentQueuePanel("docq"); mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_txt.png"), docqPanel); }
From source file:at.becast.youploader.gui.FrmMain.java
/** * //from www. jav a 2 s. c o m */ public void initComponents() { if (Main.debug) LOG.debug("init Components", FrmMain.class); int left = Integer.parseInt(Main.s.get("left", "0")); int top = Integer.parseInt(Main.s.get("top", "0")); int width = Integer.parseInt(Main.s.get("width", DEFAULT_WIDTH)); int height = Integer.parseInt(Main.s.get("height", DEFAULT_HEIGHT)); setBounds(left, top, width, height); TabbedPane = new JTabbedPane(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle(Main.APP_NAME + " " + Main.VERSION); setName("frmMain"); //Main Tab Creation initMainTab(); //Queue Tab creation initQueuetab(); //Playlist Settings Tab creation initPlaylistSettingsTab(); statusBar = new StatusBar(); GroupLayout layout = new GroupLayout(getContentPane()); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(statusBar, GroupLayout.DEFAULT_SIZE, 884, Short.MAX_VALUE) .addComponent(TabbedPane, GroupLayout.DEFAULT_SIZE, 884, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, layout.createSequentialGroup() .addComponent(TabbedPane, GroupLayout.PREFERRED_SIZE, 498, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(statusBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))); getContentPane().setLayout(layout); cmbCategory.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { changeCategory(); } }); QueuePanel.revalidate(); }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot./*from w w w.j a v a 2 s . c om*/ * <P> * In designing the panel, we need to be aware that subclasses of Plot will * need to implement subclasses of PlotPropertyEditPanel - so we need to * leave one or two 'slots' where the subclasses can extend the user * interface. * * @param plot * the plot, which should be changed. */ public DefaultPlotEditor(Plot plot) { this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); // Disabled because makes no sense for us // if (plot instanceof CategoryPlot) { // this.plotOrientation = ((CategoryPlot) plot).getOrientation(); // } else if (plot instanceof XYPlot) { // this.plotOrientation = ((XYPlot) plot).getOrientation(); // } if (plot instanceof CategoryPlot) { CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getBaseLinesVisible()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } else if (plot instanceof XYPlot) { XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } setLayout(new BorderLayout()); this.availableStrokeSamples = new StrokeSample[4]; this.availableStrokeSamples[0] = new StrokeSample(null); this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(2.0f)); this.availableStrokeSamples[3] = new StrokeSample(new BasicStroke(3.0f)); // create a panel for the settings... JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":"))); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Outline_stroke"))); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (StrokeSample s : this.availableStrokeSamples) { model.addElement(s.getStroke()); } this.cbOutlineStroke = new JComboBox(model); this.cbOutlineStroke.setSelectedItem(this.outlineStrokeSample.getStroke()); this.cbOutlineStroke.setRenderer(new StrokeComboboxRenderer()); interior.add(this.cbOutlineStroke); interior.add(new JLabel()); interior.add(new JLabel(localizationResources.getString("Outline_Paint"))); JButton button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("OutlinePaint"); button.addActionListener(this); interior.add(this.outlinePaintSample); interior.add(button); interior.add(new JLabel(localizationResources.getString("Background_paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(this.backgroundPaintSample); interior.add(button); // Disabled because makes no sense for us // if (this.plotOrientation != null) { // boolean isVertical = // this.plotOrientation.equals(PlotOrientation.VERTICAL); // int index = isVertical ? ORIENTATION_VERTICAL : // ORIENTATION_HORIZONTAL; // interior.add(new // JLabel(localizationResources.getString("Orientation"))); // this.orientationCombo = new JComboBox(orientationNames); // this.orientationCombo.setSelectedIndex(index); // this.orientationCombo.setActionCommand("Orientation"); // this.orientationCombo.addActionListener(this); // interior.add(this.orientationCombo); // interior.add(new JPanel()); // } if (this.drawLines != null) { interior.add(new JLabel(localizationResources.getString("Draw_lines"))); this.drawLinesCheckBox = new JCheckBox(); this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); this.drawLinesCheckBox.setActionCommand("DrawLines"); this.drawLinesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawLinesCheckBox); } if (this.drawShapes != null) { interior.add(new JLabel(localizationResources.getString("Draw_shapes"))); this.drawShapesCheckBox = new JCheckBox(); this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); this.drawShapesCheckBox.setActionCommand("DrawShapes"); this.drawShapesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawShapesCheckBox); } general.add(interior, BorderLayout.NORTH); JPanel appearance = new JPanel(new BorderLayout()); appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); appearance.add(general, BorderLayout.NORTH); JTabbedPane tabs = new JTabbedPane(); tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance(domainAxis); if (this.domainAxisPropertyPanel != null) { this.domainAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Domain_Axis"), this.domainAxisPropertyPanel); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); if (this.rangeAxisPropertyPanel != null) { this.rangeAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Range_Axis"), this.rangeAxisPropertyPanel); } tabs.add(localizationResources.getString("Appearance"), appearance); panel.add(tabs); add(panel); }