List of usage examples for javax.swing JSplitPane setResizeWeight
@BeanProperty(description = "Specifies how to distribute extra space when the split pane resizes.") public void setResizeWeight(double value)
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel() { JPanel quickOpenPanel = new JPanel(new BorderLayout()); quickOpenPanel.add(new JLabel("Quick open"), BorderLayout.NORTH); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createQuickOpenUnsolvedPanel(), createQuickOpenSolvedPanel()); splitPane.setResizeWeight(0.8); splitPane.setBorder(null);/*from w w w . j ava 2 s . c o m*/ quickOpenPanel.add(splitPane, BorderLayout.CENTER); return quickOpenPanel; }
From source file:mekhq.gui.FinancesTab.java
@Override public void initTab() { resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$ GridBagConstraints gridBagConstraints; setLayout(new GridBagLayout()); ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT); ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES); financeModel = new FinanceTableModel(); financeTable = new JTable(financeModel); financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel)); financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); TableColumn column = null;// www.j ava2 s .c o m for (int i = 0; i < FinanceTableModel.N_COL; i++) { column = financeTable.getColumnModel().getColumn(i); column.setPreferredWidth(financeModel.getColumnWidth(i)); column.setCellRenderer(financeModel.getRenderer()); } financeTable.setIntercellSpacing(new Dimension(0, 0)); financeTable.setShowGrid(false); loanModel = new LoanTableModel(); loanTable = new JTable(loanModel); loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel)); loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); column = null; for (int i = 0; i < LoanTableModel.N_COL; i++) { column = loanTable.getColumnModel().getColumn(i); column.setPreferredWidth(loanModel.getColumnWidth(i)); column.setCellRenderer(loanModel.getRenderer()); } loanTable.setIntercellSpacing(new Dimension(0, 0)); loanTable.setShowGrid(false); JScrollPane scrollLoanTable = new JScrollPane(loanTable); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; JPanel panBalance = new JPanel(new GridBagLayout()); panBalance.add(new JScrollPane(financeTable), gridBagConstraints); panBalance.setMinimumSize(new java.awt.Dimension(350, 100)); panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet")); JPanel panLoan = new JPanel(new GridBagLayout()); panLoan.add(scrollLoanTable, gridBagConstraints); JTabbedPane financeTab = new JTabbedPane(); financeTab.setMinimumSize(new java.awt.Dimension(450, 300)); financeTab.setPreferredSize(new java.awt.Dimension(450, 300)); JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab); splitFinances.setOneTouchExpandable(true); splitFinances.setContinuousLayout(true); splitFinances.setResizeWeight(1.0); splitFinances.setName("splitFinances"); financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan); financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel); financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(splitFinances, gridBagConstraints); JPanel panelFinanceRight = new JPanel(new BorderLayout()); JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2)); btnAddFunds = new JButton("Add Funds (GM)"); btnAddFunds.addActionListener(ev -> addFundsActionPerformed()); btnAddFunds.setEnabled(getCampaign().isGM()); pnlFinanceBtns.add(btnAddFunds); JButton btnGetLoan = new JButton("Get Loan"); btnGetLoan.addActionListener(e -> showNewLoanDialog()); pnlFinanceBtns.add(btnGetLoan); btnManageAssets = new JButton("Manage Assets (GM)"); btnManageAssets.addActionListener(e -> manageAssets()); btnManageAssets.setEnabled(getCampaign().isGM()); pnlFinanceBtns.add(btnManageAssets); panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH); areaNetWorth = new JTextArea(); areaNetWorth.setLineWrap(true); areaNetWorth.setWrapStyleWord(true); areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12)); areaNetWorth.setText(getCampaign().getFinancialReport()); areaNetWorth.setEditable(false); JScrollPane descriptionScroll = new JScrollPane(areaNetWorth); panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER); areaNetWorth.setCaretPosition(0); descriptionScroll.setMinimumSize(new Dimension(300, 200)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.0; gridBagConstraints.weighty = 1.0; add(panelFinanceRight, gridBagConstraints); }
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// w w w .j ava2s. c om */ 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.design.EntryFileImportDialog.java
public EntryFileImportDialog(Window owner, String title, File inputFile, Predicate<Role> entryHeadingFilter) { super(owner, title, ModalityType.APPLICATION_MODAL); this.entryHeadingFilter = entryHeadingFilter; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setGlassPane(backgroundRunner.getBlockingPane()); useScrollBarOption.addActionListener(new ActionListener() { @Override// ww w. j av a 2s . co m public void actionPerformed(ActionEvent e) { updateDataPreviewScrolling(); } }); headingRoleTableModel = createHeadingRoleTableModel(); headingRoleTable = new HeadingRoleTable<>(headingRoleTableModel); headingTableScrollPane = new JScrollPane(headingRoleTable); GuiUtil.setVisibleRowCount(headingRoleTable, 10); JPanel roleAssignmentPanel = new JPanel(new BorderLayout()); roleAssignmentPanel.add(headingTableScrollPane, BorderLayout.CENTER); headingRoleTable.setTransferHandler(flth); headingRoleTableModel.addChangeListener(headingRoleChangeListener); GuiUtil.setVisibleRowCount(dataPreviewTable, 10); dataPreviewTable.setTransferHandler(flth); dataPreviewScrollPane.setTransferHandler(flth); updateDataPreviewScrolling(); dataPreviewScrollPane.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { // boolean useScrollBar = useScrollBarOption.isSelected(); GuiUtil.initialiseTableColumnWidths(dataPreviewTable, true); } }); Box top = Box.createHorizontalBox(); top.add(new JLabel("# rows to preview: ")); top.add(new JSpinner(previewRowCountSpinnerModel)); top.add(Box.createHorizontalGlue()); top.add(useScrollBarOption); JPanel dataPreviewPanel = new JPanel(new BorderLayout()); dataPreviewPanel.add(GuiUtil.createLabelSeparator("Data Preview", top), BorderLayout.NORTH); dataPreviewPanel.add(dataPreviewScrollPane, BorderLayout.CENTER); headingWarning.setForeground(Color.RED); JLabel instructions = new JLabel("<HTML>Please assign a <i>Role</i> for each of the headings in your data" + "<br>You must specify one as the <i>Entry Name</i>." + "<br>Click on one of the <i>Role</i> cells and select from the dropdown" + "<br>To assign multiple headings, select the rows for which you wish" + "<br>to set the <i>Role</i> then right-click and choose from the dropdown."); instructions.setHorizontalAlignment(JLabel.CENTER); instructions.setBackground(Toast.PALE_YELLOW); JScrollPane instScroll = new JScrollPane(instructions); instScroll.setBackground(Toast.PALE_YELLOW); normalEntryNameField.getDocument() .addDocumentListener(new DocumentChangeListener((e) -> updateAcceptButton())); normalEntryNameField.setText(TrialDesignPreferences.getInstance().getNormalEntryTypeName()); JPanel rolesPanel = new JPanel(); GBH gbh = new GBH(rolesPanel, 2, 2, 0, 0); int y = 0; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Entry Type Name for non-Checks:"); gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, normalEntryNameField); gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, saveForFuture); ++y; gbh.add(0, y, 3, 1, GBH.BOTH, 2, 1, GBH.CENTER, roleAssignmentPanel); ++y; JSplitPane headingsAndInstructions = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rolesPanel, instScroll); JPanel headingPanel = new JPanel(new BorderLayout()); headingPanel.add(GuiUtil.createLabelSeparator("Assign Roles for Headings"), BorderLayout.NORTH); headingPanel.add(headingsAndInstructions, BorderLayout.CENTER); headingPanel.add(headingWarning, BorderLayout.SOUTH); errorMessage.setEditable(false); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, dataPreviewPanel, headingPanel); splitPane.setResizeWeight(0.5); cardPanel.add(new JScrollPane(errorMessage), CARD_ERROR); cardPanel.add(splitPane, CARD_DATA); Box bot = Box.createHorizontalBox(); bot.add(Box.createHorizontalGlue()); bot.add(new JButton(cancelAction)); bot.add(new JButton(acceptAction)); acceptAction.setEnabled(false); Container cp = getContentPane(); cp.add(cardPanel, BorderLayout.CENTER); cp.add(bot, BorderLayout.SOUTH); pack(); sheetNamesComboBox.addActionListener(sheetNamesActionListener); Timer timer = new Timer(true); previewRowCountSpinnerModel.addChangeListener(new ChangeListener() { int nPreview; TimerTask timerTask = null; @Override public void stateChanged(ChangeEvent e) { nPreview = previewRowCountSpinnerModel.getNumber().intValue(); if (timerTask == null) { timerTask = new TimerTask() { int lastPreviewCount = nPreview; @Override public void run() { if (lastPreviewCount == nPreview) { System.err.println("Stable at " + lastPreviewCount); // No change, do it now cancel(); try { updateDataPreview(lastPreviewCount); } finally { timerTask = null; } } else { System.err.println("Changing from " + lastPreviewCount + " to " + nPreview); lastPreviewCount = nPreview; } } }; timer.scheduleAtFixedRate(timerTask, 500, 100); } } }); sheetNamesComboBox.setVisible(false); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); setFile(inputFile); } }); }
From source file:com.diversityarrays.kdxplore.heatmap.HeatMapPanel.java
public HeatMapPanel(VisualisationTool vtool, int unique, SelectedValueStore svs, PlotInfoProvider pip, String title,// w ww.j a v a2 s . co m HeatMapModelData<T> heatMapModelData, SuppressionHandler suppressionHandler) { super(title, svs, vtool.getVisualisationToolId(), unique, Arrays.asList(heatMapModelData.zTraitInstance), suppressionHandler); context = heatMapModelData.context; xValueRetriever = heatMapModelData.xValueRetriever; yValueRetriever = heatMapModelData.yValueRetriever; askAboutValueForUnscored = !ValueRetriever.isEitherOneXorY(xValueRetriever, yValueRetriever); traitInstanceValueRetriever = heatMapModelData.traitInstanceValueRetriever; this.zTraitInstance = heatMapModelData.zTraitInstance; // this.plotSpecimensByPoint = heatMapModelData.model.getCellLegend(); this.plotInfoProvider = pip; this.title = title; if (heatMapModelData.plotPointsByMark.isEmpty()) { markInfo = null; } else { markInfo = new MarkInfo(Msg.LABEL_MARK_INFO_PLOT_TYPE(), heatMapModelData.plotPointsByMark); } this.heatMap = createHeatMap(heatMapModelData); this.heatMap.addPropertyChangeListener(HeatMapPane.PROPERTY_SELECTION_CHANGE, heatMapPaneSelectionChangeListener); messagesTextArea.setEditable(false); tabbedPane.addTab(TAB_MESSAGES, new JScrollPane(messagesTextArea)); tabbedPane.addTab(TAB_CURATION, createCurationControls()); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabbedPane, heatMap); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.0); add(splitPane, BorderLayout.CENTER); int cellValueCount = heatMap.getValueModel().getUniqueCellValueCount(); Gradient[] gradients = Gradient.createBuiltins(cellValueCount); Gradient initial = null; for (Gradient g : gradients) { if (Gradient.RAINBOW_NAME.equals(g.getName())) { initial = g; break; } } gradientComboBox = new JComboBox<Gradient>(gradients); gradientComboBox.setRenderer(new GradientComboBoxRenderer()); gradientComboBox.addItemListener(gradientItemListener); // gradientItemListener will to model.setGradient() gradientComboBox.setSelectedItem(initial); Box box = Box.createHorizontalBox(); box.add(syncedOption); box.add(gradientComboBox); box.add(Box.createHorizontalGlue()); // if (RunMode.getRunMode().isDeveloper()) { // box.add(useBlankTilesOption); // } box.add(new JSeparator(JSeparator.VERTICAL)); box.add(opacityLabel); box.add(unselectedOpacitySpinner); add(box, BorderLayout.SOUTH); opacityLabel.setToolTipText("Sets the opacity of unselected cells"); unselectedOpacitySpinner.setToolTipText("Sets the opacity of unselected cells"); // useBlankTilesOption.setSelected(heatMap.getUseBlankTiles()); unselectedOpacityModel.setValue(heatMap.getUnselectedOpacity()); // useBlankTilesOption.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // handleUseBlankTilesChanged(); // } // }); unselectedOpacityModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { handleOpacityChange(); } }); updateMessagesWithMissingOrBad(null, heatMapModelData); applyDecoratorsToHeatMap(heatMapModelData); }
From source file:net.sf.nmedit.nomad.core.Nomad.java
void setupUI() { this.clipBoard = new Clipboard("nomad clipboard"); ApplicationClipboard.setApplicationClipboard(clipBoard); mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); mainWindow.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Nomad.sharedInstance().handleExit(); }//from ww w. ja va 2 s.c om }); pageContainer = new DefaultDocumentManager(); Container contentPane = mainWindow.getContentPane(); explorerTree = new FileExplorerTree(); explorerTree.setFont(new Font("Arial", Font.PLAIN, 11)); explorerTree.createPopup(menuBuilder); JScrollPane explorerTreeScroller = new JScrollPane(explorerTree); toolPane = new JTabbedPane2(); toolPane.setCloseActionEnabled(false); toolPane.addTab("Explorer", getImage("/icons/eview16/filenav_nav.gif"), explorerTreeScroller); new DropTarget(contentPane, new URIListDropHandler() { public void uriListDropped(URI[] uriList) { for (URI uri : uriList) { try { File f = new File(uri); openOrSelect(f); } catch (IllegalArgumentException e) { // ignore } } } }); synthPane = new JTabbedPane2(); synthPane.setCloseActionEnabled(true); JSplitPane sidebarSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false); sidebarSplit.setTopComponent(toolPane); sidebarSplit.setBottomComponent(synthPane); sidebarSplit.setResizeWeight(0.8); sidebarSplit.setOneTouchExpandable(true); /* JComponent sidebar = new JPanel(new BorderLayout()); sidebar.setBorder(null); sidebar.add(sidebarSplit, BorderLayout.CENTER); */ if (!Platform.isFlavor(OS.MacOSFlavor)) { /* JToolBar tb = createQuickActionToolbar(); sidebar.add(tb, BorderLayout.NORTH);*/ } else { registerForMacOSXEvents(); } JSplitPane splitLR = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitLR.setResizeWeight(0); splitLR.setDividerLocation(200); splitLR.setRightComponent(pageContainer); splitLR.setLeftComponent(sidebarSplit); contentPane.setLayout(new BorderLayout()); contentPane.add(splitLR, BorderLayout.CENTER); if (contentPane instanceof JComponent) ((JComponent) contentPane).revalidate(); }
From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java
public FieldViewDialog(Window owner, String title, SampleGroupChoice sgcSamples, Trial trial, SampleGroupChoice sgcNewMedia, KDSmartDatabase db) throws IOException { super(owner, title, ModalityType.MODELESS); advanceRetreatControls = Box.createHorizontalBox(); advanceRetreatControls.add(new JButton(retreatAction)); advanceRetreatControls.add(new JButton(advanceAction)); autoAdvanceControls = Box.createHorizontalBox(); autoAdvanceControls.add(new JButton(autoAdvanceAction)); autoAdvanceOption.addActionListener(new ActionListener() { @Override/*from w w w. j av a2 s . c o m*/ public void actionPerformed(ActionEvent e) { updateMovementControls(); } }); this.database = db; this.sampleGroupChoiceForSamples = sgcSamples; this.sampleGroupChoiceForNewMedia = sgcNewMedia; NumberSpinner fontSpinner = new NumberSpinner(new SpinnerNumberModel(), "0.00"); this.fieldViewPanel = FieldViewPanel.create(database, trial, SeparatorVisibilityOption.VISIBLE, null, Box.createHorizontalGlue(), new JButton(showInfoAction), Box.createHorizontalGlue(), new JLabel("Font Size:"), fontSpinner, Box.createHorizontalGlue(), advanceRetreatControls, autoAdvanceOption, autoAdvanceControls); initialiseAction(advanceAction, "ic_object_advance_black.png", "Auto-Advance"); this.xyProvider = fieldViewPanel.getXYprovider(); this.traitMap = fieldViewPanel.getTraitMap(); fieldLayoutTable = fieldViewPanel.getFieldLayoutTable(); JScrollPane scrollPane = fieldViewPanel.getFieldTableScrollPane(); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); fieldLayoutTable.setTransferHandler(flth); fieldLayoutTable.setDropMode(DropMode.ON); fieldLayoutTable.addMouseListener(new MouseAdapter() { JPopupMenu popupMenu; @Override public void mouseClicked(MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e) || 1 != e.getClickCount()) { return; } Point pt = e.getPoint(); int row = fieldLayoutTable.rowAtPoint(pt); if (row >= 0) { int col = fieldLayoutTable.columnAtPoint(pt); if (col >= 0) { Plot plot = fieldViewPanel.getPlotAt(col, row); if (plot != null) { if (popupMenu == null) { popupMenu = new JPopupMenu("View Attachments"); } popupMenu.removeAll(); Set<File> set = plot.getMediaFiles(); if (Check.isEmpty(set)) { popupMenu.add(new JMenuItem("No Attachments available")); } else { for (File file : set) { Action a = new AbstractAction(file.getName()) { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().browse(file.toURI()); } catch (IOException e1) { MsgBox.warn(FieldViewDialog.this, e1, file.getName()); } } }; popupMenu.add(new JMenuItem(a)); } } popupMenu.show(fieldLayoutTable, pt.x, pt.y); } } } } }); Font font = fieldLayoutTable.getFont(); float fontSize = font.getSize2D(); fontSizeModel = new SpinnerNumberModel(fontSize, fontSize, 50.0, 1.0); fontSpinner.setModel(fontSizeModel); fontSizeModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { float fsize = fontSizeModel.getNumber().floatValue(); System.out.println("Using fontSize=" + fsize); Font font = fieldLayoutTable.getFont().deriveFont(fsize); fieldLayoutTable.setFont(font); FontMetrics fm = fieldLayoutTable.getFontMetrics(font); int lineHeight = fm.getMaxAscent() + fm.getMaxDescent(); fieldLayoutTable.setRowHeight(4 * lineHeight); // GuiUtil.initialiseTableColumnWidths(fieldLayoutTable, false); fieldLayoutTable.repaint(); } }); fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fieldLayoutTable.setResizable(true, true); fieldLayoutTable.getTableColumnResizer().setResizeAllColumns(true); advanceAction.setEnabled(false); fieldLayoutTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handlePlotSelection(); } } }); TableColumnModel columnModel = fieldLayoutTable.getColumnModel(); columnModel.addColumnModelListener(new TableColumnModelListener() { @Override public void columnSelectionChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { handlePlotSelection(); } } @Override public void columnRemoved(TableColumnModelEvent e) { } @Override public void columnMoved(TableColumnModelEvent e) { } @Override public void columnMarginChanged(ChangeEvent e) { } @Override public void columnAdded(TableColumnModelEvent e) { } }); PropertyChangeListener listener = new PropertyChangeListener() { // Use a timer and redisplay other columns when delay is GT 100 ms Timer timer = new Timer(true); TimerTask timerTask; long lastActive; boolean busy = false; private int eventColumnWidth; private TableColumn eventColumn; @Override public void propertyChange(PropertyChangeEvent evt) { if (busy) { return; } if (evt.getSource() instanceof TableColumn && "width".equals(evt.getPropertyName())) { eventColumn = (TableColumn) evt.getSource(); eventColumnWidth = eventColumn.getWidth(); lastActive = System.currentTimeMillis(); if (timerTask == null) { timerTask = new TimerTask() { @Override public void run() { if (System.currentTimeMillis() - lastActive > 200) { timerTask.cancel(); timerTask = null; busy = true; try { for (Enumeration<TableColumn> en = columnModel.getColumns(); en .hasMoreElements();) { TableColumn tc = en.nextElement(); if (tc != eventColumn) { tc.setWidth(eventColumnWidth); } } } finally { busy = false; } } } }; timer.scheduleAtFixedRate(timerTask, 100, 150); } } } }; for (Enumeration<TableColumn> en = columnModel.getColumns(); en.hasMoreElements();) { TableColumn tc = en.nextElement(); tc.addPropertyChangeListener(listener); } Map<Integer, Plot> plotById = new HashMap<>(); for (Plot plot : fieldViewPanel.getFieldLayout()) { plotById.put(plot.getPlotId(), plot); } TrialItemVisitor<Sample> sampleVisitor = new TrialItemVisitor<Sample>() { @Override public void setExpectedItemCount(int count) { } @Override public boolean consumeItem(Sample sample) throws IOException { Plot plot = plotById.get(sample.getPlotId()); if (plot == null) { throw new IOException("Missing plot for plotId=" + sample.getPlotId() + " sampleIdent=" + Util.createUniqueSampleKey(sample)); } plot.addSample(sample); SampleCounts counts = countsByTraitId.get(sample.getTraitId()); if (counts == null) { counts = new SampleCounts(); countsByTraitId.put(sample.getTraitId(), counts); } if (sample.hasBeenScored()) { ++counts.scored; } else { ++counts.unscored; } return true; } }; database.visitSamplesForTrial(sampleGroupChoiceForSamples, trial.getTrialId(), SampleOrder.ALL_BY_PLOT_ID_THEN_TRAIT_ID_THEN_INSTANCE_NUMBER_ORDER_THEN_SPECIMEN_NUMBER, sampleVisitor); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.trial = trial; KDClientUtils.initAction(ImageId.SETTINGS_24, showInfoAction, "Trial Summary"); Action clear = new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { infoTextArea.setText(""); } }; JPanel bottom = new JPanel(new BorderLayout()); bottom.add(GuiUtil.createLabelSeparator("Plot Details", new JButton(clear)), BorderLayout.NORTH); bottom.add(new JScrollPane(infoTextArea), BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fieldViewPanel, new JScrollPane(infoTextArea)); splitPane.setResizeWeight(0.0); splitPane.setOneTouchExpandable(true); setContentPane(splitPane); updateMovementControls(); pack(); }
From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java
private void initLayout() { Container content = this.getContentPane(); JComponent controls = Box.createVerticalBox(); {/*from w w w. j av a2 s. c o m*/ JPanel filePanel = new JPanel(new BorderLayout()); { filePanel.setBorder(BorderFactory.createTitledBorder("Stock Market Trading Data")); JPanel dataButtons = new JPanel(new GridLayout(2, 1)); { dataButtons.add(this.loadFileButton); dataButtons.add(this.viewDataButton); } filePanel.add(dataButtons, BorderLayout.EAST); JPanel fileControls = new JPanel(new FlowLayout()); { fileControls.add(new JLabel("Stock data File:")); fileControls.add(this.fileField); fileControls.add(this.fileBrowseButton); fileControls.add(new JLabel(" Stock data format:")); fileControls.add(this.fileFormatCombo); } filePanel.add(fileControls, BorderLayout.CENTER); } controls.add(filePanel); JComponent simPanel = new JPanel(new BorderLayout()); { simPanel.setBorder(BorderFactory.createTitledBorder("Simulation Run")); simPanel.add(this.runButton, BorderLayout.EAST); JComponent simControlsPanel = Box.createVerticalBox(); { JPanel accountControls = new JPanel(new FlowLayout()); { accountControls.add(new JLabel("Initial Cash:")); accountControls.add(this.initialCashField); accountControls.add(new JLabel(" Per Trade Fee:")); accountControls.add(this.perTradeFeeField); accountControls.add(new JLabel(" Per Share Trade Commission:")); accountControls.add(this.perShareTradeCommissionField); accountControls.add(new JLabel(" Compare:")); accountControls.add(this.compareIndexSymbolField); } simControlsPanel.add(accountControls); JPanel runControls = new JPanel(new FlowLayout()); { runControls.add(this.strategyField); runControls.add(new JLabel("Start Date:")); runControls.add(this.startDateField); runControls.add(new JLabel(" End Date:")); runControls.add(this.endDateField); runControls.add(new JLabel(" Strategy:")); runControls.add(this.strategyField); runControls.add(this.editButton); runControls.add(this.compileButton); } simControlsPanel.add(runControls); } simPanel.add(simControlsPanel, BorderLayout.CENTER); } controls.add(simPanel); } content.add(controls, BorderLayout.NORTH); JSplitPane vSplit = this.vSplit; { vSplit.setResizeWeight(0.5); vSplit.add(this.chartPanel, JSplitPane.TOP); JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); { hSplit.setResizeWeight(0.5); // enough for no hscrollbar in 1024 width JSplitPane reportSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); { reportSplit.setResizeWeight(0.5); JScrollPane reportScroll = new JScrollPane(this.reportArea); { reportScroll.setBorder(BorderFactory.createTitledBorder("Report")); } reportSplit.add(reportScroll, JSplitPane.TOP); JScrollPane monthScroll = new JScrollPane(this.monthlyLogArea); { monthScroll.setBorder(BorderFactory.createTitledBorder("Monthly Log")); } reportSplit.add(monthScroll, JSplitPane.BOTTOM); } hSplit.add(reportSplit, JSplitPane.LEFT); JScrollPane tradeScroll = new JScrollPane(this.tradeLogArea); { tradeScroll.setBorder(BorderFactory.createTitledBorder("Trade Log")); } hSplit.add(tradeScroll, JSplitPane.RIGHT); } vSplit.add(hSplit, JSplitPane.BOTTOM); } content.add(vSplit, BorderLayout.CENTER); }
From source file:cool.pandora.modeller.ui.jpanel.base.BagView.java
/** * createBagPanel.//from w w w .j ava 2 s .c om * * @return splitPane */ private JSplitPane createBagPanel() { final LineBorder border = new LineBorder(Color.GRAY, 1); bagButtonPanel = createBagButtonPanel(); final JPanel bagTagButtonPanel = createBagTagButtonPanel(); bagPayloadTree = new BagTree(this, AbstractBagConstants.DATA_DIRECTORY); bagPayloadTree.setEnabled(false); bagPayloadTreePanel = new BagTreePanel(bagPayloadTree); bagPayloadTreePanel.setEnabled(false); bagPayloadTreePanel.setBorder(border); bagPayloadTreePanel.setToolTipText(getMessage("bagTree.help")); bagTagFileTree = new BagTree(this, getMessage("bag.label.noname")); bagTagFileTree.setEnabled(false); bagTagFileTreePanel = new BagTreePanel(bagTagFileTree); bagTagFileTreePanel.setEnabled(false); bagTagFileTreePanel.setBorder(border); bagTagFileTreePanel.setToolTipText(getMessage("bagTree.help")); tagManifestPane = new TagManifestPane(this); tagManifestPane.setToolTipText(getMessage("compositePane.tab.help")); final JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.5); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); final JPanel payloadPannel = new JPanel(); splitPane.setLeftComponent(payloadPannel); payloadPannel.setLayout(new BorderLayout(0, 0)); final JPanel payLoadToolBarPanel = new JPanel(); payloadPannel.add(payLoadToolBarPanel, BorderLayout.NORTH); payLoadToolBarPanel.setLayout(new GridLayout(1, 0, 0, 0)); final JPanel payloadLabelPanel = new JPanel(); final FlowLayout flowLayout = (FlowLayout) payloadLabelPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); payLoadToolBarPanel.add(payloadLabelPanel); final JLabel lblPayloadTree = new JLabel(getMessage("bagView.payloadTree.name")); payloadLabelPanel.add(lblPayloadTree); payLoadToolBarPanel.add(bagButtonPanel); payloadPannel.add(bagPayloadTreePanel, BorderLayout.CENTER); final JPanel tagFilePanel = new JPanel(); splitPane.setRightComponent(tagFilePanel); tagFilePanel.setLayout(new BorderLayout(0, 0)); final JPanel tagFileToolBarPannel = new JPanel(); tagFilePanel.add(tagFileToolBarPannel, BorderLayout.NORTH); tagFileToolBarPannel.setLayout(new GridLayout(0, 2, 0, 0)); final JPanel TagFileLabelPanel = new JPanel(); final FlowLayout tagFileToolbarFlowLayout = (FlowLayout) TagFileLabelPanel.getLayout(); tagFileToolbarFlowLayout.setAlignment(FlowLayout.LEFT); tagFileToolBarPannel.add(TagFileLabelPanel); final JLabel tagFileTreeLabel = new JLabel(getMessage("bagView.TagFilesTree.name")); TagFileLabelPanel.add(tagFileTreeLabel); tagFileToolBarPannel.add(bagTagButtonPanel); tagFilePanel.add(bagTagFileTreePanel, BorderLayout.CENTER); return splitPane; }
From source file:com.diversityarrays.kdxplore.trials.TrialOverviewPanel.java
public TrialOverviewPanel(String title, OfflineData offdata, TrialExplorerManager manager, FileListTransferHandler flth, MessagePrinter mp, final Closure<List<Trial>> onTrialSelected) { super(new BorderLayout()); offlineData = offdata;/* w w w.j a v a 2 s .c o m*/ KdxploreDatabase kdxdb = offlineData.getKdxploreDatabase(); if (kdxdb != null) { kdxdb.addEntityChangeListener(trialChangeListener); kdxdb.addEntityChangeListener(traitChangeListener); } this.messagePrinter = mp; TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(trialsTable, true); trialsTable.setTransferHandler(new ChainingTransferHandler(flth, tth)); trialsTable.setAutoCreateRowSorter(true); trialsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { List<Trial> selectedTrials = getSelectedTrials(); if (selectedTrials.size() == 1) { trialTraitsTableModel.setSelectedTrial(selectedTrials.get(0)); } else { trialTraitsTableModel.setSelectedTrial(null); } onTrialSelected.execute(selectedTrials); } } }); trialsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) { fireEditCommand(e); } } }); GuiUtil.setVisibleRowCount(trialsTable, MAX_INITIAL_VISIBLE_TRIAL_ROWS); offlineData.addOfflineDataChangeListener(offlineDataChangeListener); trialTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateRefreshAction(); } }); trialTraitsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateAddTraitAction(); updateRemoveTraitAction(); updateScoringOrderAction(); } }); trialTraitsTable.addMouseListener(new MouseAdapter() { List<Trait> selectedTraits; JPopupMenu popupMenu; Action showTraitsAction = new AbstractAction("Select in Trait Explorer") { @Override public void actionPerformed(ActionEvent e) { manager.showTraitsInTraitExplorer(selectedTraits); } }; @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) { // Start editing the Trait e.consume(); int vrow = trialTraitsTable.rowAtPoint(e.getPoint()); if (vrow >= 0) { int mrow = trialTraitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { Trait trait = trialTraitsTableModel.getTraitAt(mrow); if (trait != null) { traitExplorer.startEditing(trait); ; } } } } else if (SwingUtilities.isRightMouseButton(e) && 1 == e.getClickCount()) { // Select the traits in the traitExplorer e.consume(); List<Integer> modelRows = GuiUtil.getSelectedModelRows(trialTraitsTable); if (!modelRows.isEmpty()) { selectedTraits = modelRows.stream().map(trialTraitsTableModel::getTraitAt) .collect(Collectors.toList()); if (popupMenu == null) { popupMenu = new JPopupMenu(); popupMenu.add(showTraitsAction); } Point pt = e.getPoint(); popupMenu.show(trialTraitsTable, pt.x, pt.y); } } } }); trialTraitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateRemoveTraitAction(); } } }); updateAddTraitAction(); updateRemoveTraitAction(); updateScoringOrderAction(); updateRefreshAction(); KDClientUtils.initAction(ImageId.REFRESH_24, refreshTrialTraitsAction, "Refresh"); KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitAction, "Remove selected Traits"); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addTraitAction, "Add Traits to Trial"); KDClientUtils.initAction(ImageId.TRAIT_ORDER_24, setScoringOrderAction, "Define Trait Scoring Order"); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(setScoringOrderAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(addTraitAction)); buttons.add(new JButton(removeTraitAction)); buttons.add(Box.createHorizontalStrut(10)); buttons.add(refreshTrialTraitsButton); JPanel traitsPanel = new JPanel(new BorderLayout()); traitsPanel.add(GuiUtil.createLabelSeparator("Uses Traits", buttons), BorderLayout.NORTH); traitsPanel.add(new PromptScrollPane(trialTraitsTable, "If the (single) selected Trial has Traits they will appear here"), BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(trialsTable), traitsPanel); splitPane.setResizeWeight(0.5); add(splitPane, BorderLayout.CENTER); }