List of usage examples for javax.swing JSplitPane setDividerLocation
@BeanProperty(description = "The location of the divider.") public void setDividerLocation(int location)
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();/*from ww w . j a v a 2s .c om*/ initComponents(); this.stackPanel = new JPanel(); this.stackPanel.setFocusable(false); this.stackPanel.setOpaque(false); this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32)); this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS)); final JPanel glassPanel = (JPanel) this.getGlassPane(); glassPanel.setOpaque(false); this.setGlassPane(glassPanel); glassPanel.setLayout(new BorderLayout(8, 8)); glassPanel.add(Box.createGlue(), BorderLayout.CENTER); final JPanel ppanel = new JPanel(new BorderLayout(0, 0)); ppanel.setFocusable(false); ppanel.setOpaque(false); ppanel.setCursor(null); ppanel.add(this.stackPanel, BorderLayout.SOUTH); glassPanel.add(ppanel, BorderLayout.EAST); this.stackPanel.add(Box.createGlue()); glassPanel.setVisible(false); this.setTitle("Scia Reto"); setIconImage(UiUtils.loadImage("logo256x256.png")); this.stateless = args.length > 0; final MainFrame theInstance = this; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (doClosing()) { dispose(); } } }); this.tabPane = new EditorTabPane(this); this.explorerTree = new ExplorerTree(this); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setResizeWeight(0.0d); splitPane.setLeftComponent(this.explorerTree); splitPane.setRightComponent(this.tabPane); add(splitPane, BorderLayout.CENTER); this.menuOpenRecentProject.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects(); if (lastOpenedProjects.length > 0) { for (final File folder : lastOpenedProjects) { final JMenuItem item = new JMenuItem(folder.getName()); item.setToolTipText(folder.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openProject(folder, false); } }); menuOpenRecentProject.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentProject.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); this.menuOpenRecentFile.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles(); if (lastOpenedFiles.length > 0) { for (final File file : lastOpenedFiles) { final JMenuItem item = new JMenuItem(file.getName()); item.setToolTipText(file.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFileAsTab(file); } }); menuOpenRecentFile.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentFile.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); if (!this.stateless) { restoreState(); } else { boolean openedProject = false; for (final String filePath : args) { final File file = new File(filePath); if (file.isDirectory()) { openedProject = true; openProject(file, true); } else if (file.isFile()) { openFileAsTab(file); } } if (!openedProject) { //TODO try to hide project panel! } } final LookAndFeel current = UIManager.getLookAndFeel(); final ButtonGroup lfGroup = new ButtonGroup(); final String currentLFClassName = current.getClass().getName(); for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName()); lfGroup.add(menuItem); if (currentLFClassName.equals(info.getClassName())) { menuItem.setSelected(true); } menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(theInstance); PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL, info.getClassName()); PreferencesManager.getInstance().flush(); } catch (Exception ex) { LOGGER.error("Can't change LF", ex); } } }); this.menuLookAndFeel.add(menuItem); } }
From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
@Override protected JPanel createPanel() { // add search textfield final JPanel inputPanel = new JPanel(); inputPanel.setBorder(lineBorder(Color.black)); inputPanel.setLayout(new GridBagLayout()); inputPanel.add(itemNameFilter.getPanel(), constraints(0, 0).anchorWest().noResizing().end()); importMarketLogButton.addActionListener(new ActionListener() { @Override//ww w . jav a2s . com public void actionPerformed(ActionEvent e) { importMarketLogs(); } }); inputPanel.add(importMarketLogButton, constraints(0, 1).anchorWest().noResizing().end()); // add item description text area selectedItemDescription.setEditable(false); selectedItemDescription.setWrapStyleWord(true); selectedItemDescription.setLineWrap(true); final JScrollPane selectedItemDescPanel = new JScrollPane(selectedItemDescription); selectedItemDescPanel.setBorder(BorderFactory.createTitledBorder("Selected item")); // setup table tableModel.setViewFilter(this.itemNameFilter.getViewFilter()); table.setModel(tableModel); table.setRowSorter(tableModel.getRowSorter()); table.setDefaultRenderer(String.class, new StalePriceInfoHighlighter()); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final int viewRow = table.getSelectedRow(); if (viewRow != -1) { final int modelRow = table.convertRowIndexToModel(viewRow); updateItemDescriptionDisplay(modelRow); } } } }); table.setFillsViewportHeight(true); table.addMouseListener(popupListener); table.setFillsViewportHeight(true); // setup split pane final JPanel result = new JPanel(); final JPanel topPanel = new JPanel(); new GridLayoutBuilder().add(new GridLayoutBuilder.HorizontalGroup(new GridLayoutBuilder.Cell(inputPanel), new GridLayoutBuilder.Cell(selectedItemDescPanel))).addTo(topPanel); final JSplitPane pane = new ImprovedSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, tablePane); pane.setDividerLocation(0.3d); // only works because of the splitpane // hack pane.setContinuousLayout(true); result.setLayout(new GridBagLayout()); result.add(pane, constraints().resizeBoth().useRemainingSpace().end()); return result; }
From source file:org.ash.history.detail.DetailsPanelH.java
/** * Add ChartPanel to mainPanel/* w w w .ja v a 2s . c o m*/ * @param waitClass */ private void addChartPanelT(String waitClass) { JSplitPane splitPaneMainDetail = new JSplitPane(); StackedChartDetail stackedChartMainObjectDetail = new StackedChartDetail(database, waitClass); ChartPanel chartDetailPanel = stackedChartMainObjectDetail.createChartPanel(); stackedChartMainObjectDetail.setThresholdMaxCpu(this.maxCpu); GanttDetailsH sqlsAndSessions = new GanttDetailsH(database, waitClass); chartDetailPanel.addListenerReleaseMouse(sqlsAndSessions); database.clearStackedXYAreaChartDetail(); database.saveStackedXYAreaChartDetail(stackedChartMainObjectDetail, waitClass); database.initialLoadingDataToChartPanelDataSetDetail(waitClass, this.beginTime, this.endTime); stackedChartMainObjectDetail.setTitle(); this.mainPanel.removeAll(); splitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPaneMainDetail.add(chartDetailPanel, "top"); splitPaneMainDetail.add(sqlsAndSessions, "bottom"); splitPaneMainDetail.setDividerLocation(215); splitPaneMainDetail.setOneTouchExpandable(true); this.mainPanel.add(splitPaneMainDetail, BorderLayout.CENTER); this.validate(); this.repaint(); }
From source file:de.codesourcery.eve.skills.ui.components.impl.AssetListComponent.java
@Override protected JPanel createPanel() { // Merge controls. final JPanel mergeControlsPanel = new JPanel(); mergeControlsPanel.setLayout(new GridBagLayout()); mergeControlsPanel.setBorder(BorderFactory.createTitledBorder("Merging")); int y = 0;/*from ww w . ja v a 2s. co m*/ // merge by type mergeAssetsByType.setSelected(true); mergeAssetsByType.addActionListener(actionListener); mergeControlsPanel.add(mergeAssetsByType, constraints(0, y).anchorWest().end()); mergeControlsPanel.add(new JLabel("Merge assets by type", SwingConstants.LEFT), constraints(1, y++).width(2).end()); // "ignore different packaging" ignorePackaging.setSelected(true); ignorePackaging.addActionListener(actionListener); mergeControlsPanel.add(new JLabel(""), constraints(0, y).anchorWest().end()); mergeControlsPanel.add(ignorePackaging, constraints(1, y).anchorWest().end()); final JLabel label1 = new JLabel("Merge different packaging", SwingConstants.RIGHT); mergeControlsPanel.add(label1, constraints(2, y++).end()); // "ignore different locations" ignoreLocations.setSelected(true); ignoreLocations.addActionListener(actionListener); mergeControlsPanel.add(new JLabel(""), constraints(0, y).anchorWest().end()); mergeControlsPanel.add(ignoreLocations, constraints(1, y).anchorWest().end()); final JLabel label2 = new JLabel("Merge different locations", SwingConstants.RIGHT); mergeControlsPanel.add(label2, constraints(2, y++).end()); linkComponentEnabledStates(mergeAssetsByType, ignoreLocations, ignorePackaging, label1, label2); /* * Filter controls. */ final JPanel filterControlsPanel = new JPanel(); filterControlsPanel.setLayout(new GridBagLayout()); filterControlsPanel.setBorder(BorderFactory.createTitledBorder("Filters")); y = 0; // filter by location combo box filterByLocation.addActionListener(actionListener); locationComboBox.addActionListener(actionListener); filterByLocation.setSelected(false); linkComponentEnabledStates(filterByLocation, locationComboBox); locationComboBox.setRenderer(new LocationRenderer()); locationComboBox.setPreferredSize(new Dimension(150, 20)); locationComboBox.setModel(locationModel); filterControlsPanel.add(filterByLocation, constraints(0, y).end()); filterControlsPanel.add(locationComboBox, constraints(1, y++).end()); // filter by type combo box filterByType.addActionListener(actionListener); typeComboBox.addActionListener(actionListener); filterByType.setSelected(false); linkComponentEnabledStates(filterByType, typeComboBox); typeComboBox.setPreferredSize(new Dimension(150, 20)); typeComboBox.setModel(typeModel); filterControlsPanel.add(filterByType, constraints(0, y).end()); filterControlsPanel.add(typeComboBox, constraints(1, y++).end()); // filter by item category combobox filterByCategory.addActionListener(actionListener); categoryComboBox.addActionListener(actionListener); categoryComboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(getDisplayName((InventoryCategory) value)); setEnabled(categoryComboBox.isEnabled()); return this; } }); filterByCategory.setSelected(false); linkComponentEnabledStates(filterByCategory, categoryComboBox); categoryComboBox.setPreferredSize(new Dimension(150, 20)); categoryComboBox.setModel(categoryModel); filterControlsPanel.add(filterByCategory, constraints(0, y).end()); filterControlsPanel.add(categoryComboBox, constraints(1, y++).end()); // filter by item group combobox filterByGroup.addActionListener(actionListener); groupComboBox.addActionListener(actionListener); filterByGroup.setSelected(false); linkComponentEnabledStates(filterByGroup, groupComboBox); groupComboBox.setPreferredSize(new Dimension(150, 20)); groupComboBox.setModel(groupModel); filterControlsPanel.add(filterByGroup, constraints(0, y).end()); filterControlsPanel.add(groupComboBox, constraints(1, y++).end()); /* * Table panel. */ table = new JTable() { @Override public TableCellRenderer getCellRenderer(int row, int column) { // subclassing hack is needed because table // returns different renderes depending on column type final TableCellRenderer result = super.getCellRenderer(row, column); return new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Component comp = result.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); final int modelRow = table.convertRowIndexToModel(row); final Asset asset = model.getRow(modelRow); final StringBuilder label = new StringBuilder("<HTML><BODY>"); label.append(asset.getItemId() + " - flags: " + asset.getFlags() + "<BR>"); if (asset.hasMultipleLocations()) { label.append("<BR>"); for (ILocation loc : asset.getLocations()) { label.append(loc.getDisplayName()).append("<BR>"); } } label.append("</BODY></HTML>"); ((JComponent) comp).setToolTipText(label.toString()); return comp; } }; } }; model.setViewFilter(this.viewFilter); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateSelectedVolume(); } }); FixedBooleanTableCellRenderer.attach(table); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setModel(model); table.setBorder(BorderFactory.createLineBorder(Color.BLACK)); table.setRowSorter(model.getRowSorter()); popupMenuBuilder.addItem("Refine...", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final List<Asset> assets = getSelectedAssets(); if (assets == null || assets.isEmpty()) { return; } final ICharacter c = selectionProvider.getSelectedItem(); final RefiningComponent comp = new RefiningComponent(c); comp.setItemsToRefine(assets); ComponentWrapper.wrapComponent("Refining", comp).setVisible(true); } @Override public boolean isEnabled() { return table.getSelectedRow() != -1; } }); popupMenuBuilder.addItem("Copy selection to clipboard (text)", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final List<Asset> assets = getSelectedAssets(); if (assets == null || assets.isEmpty()) { return; } new PlainTextTransferable(toPlainText(assets)).putOnClipboard(); } @Override public boolean isEnabled() { return table.getSelectedRow() != -1; } }); popupMenuBuilder.addItem("Copy selection to clipboard (CSV)", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final List<Asset> assets = getSelectedAssets(); if (assets == null || assets.isEmpty()) { return; } final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new PlainTextTransferable(toCsv(assets)), null); } @Override public boolean isEnabled() { return table.getSelectedRow() != -1; } }); table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.popupMenuBuilder.attach(table); final JScrollPane scrollPane = new JScrollPane(table); /* * Name filter */ final JPanel nameFilterPanel = new JPanel(); nameFilterPanel.setLayout(new GridBagLayout()); nameFilterPanel.setBorder(BorderFactory.createTitledBorder("Filter by name")); nameFilterPanel.setPreferredSize(new Dimension(150, 70)); nameFilter.setColumns(10); nameFilter.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { model.viewFilterChanged(); } @Override public void insertUpdate(DocumentEvent e) { model.viewFilterChanged(); } @Override public void removeUpdate(DocumentEvent e) { model.viewFilterChanged(); } }); nameFilterPanel.add(nameFilter, constraints(0, 0).resizeHorizontally().end()); final JButton clearButton = new JButton("Clear"); clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { nameFilter.setText(null); } }); nameFilterPanel.add(clearButton, constraints(1, 0).noResizing().end()); // Selected volume final JPanel selectedVolumePanel = this.selectedVolume.getPanel(); // add control panels to result panel final JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(mergeControlsPanel, constraints(0, 0).height(2).weightX(0).anchorWest().end()); topPanel.add(filterControlsPanel, constraints(1, 0).height(2).anchorWest().weightX(0).end()); topPanel.add(nameFilterPanel, constraints(2, 0).height(1).anchorWest().useRemainingWidth().end()); topPanel.add(selectedVolumePanel, constraints(2, 1).height(1).anchorWest().useRemainingWidth().end()); final JSplitPane splitPane = new ImprovedSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, scrollPane); splitPane.setDividerLocation(0.3d); final JPanel content = new JPanel(); content.setLayout(new GridBagLayout()); content.add(splitPane, constraints().resizeBoth().useRemainingSpace().end()); return content; }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
/** * @throws HeadlessException//from w ww . j av a2 s . c om */ public AgentDebuggerFrame(final boolean isStandalone, String serviceUrl) throws HeadlessException { super("Intuit Tank Agent Debugger"); workingDir = PanelBuilder.createWorkingDir(this, serviceUrl); setSize(new Dimension(1024, 800)); setBounds(new Rectangle(getSize())); setPreferredSize(getSize()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); this.standalone = isStandalone; addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { quit(); } }); errorIcon = ActionProducer.getIcon("bullet_error.png", IconSize.SMALL); modifiedIcon = ActionProducer.getIcon("bullet_code_change.png", IconSize.SMALL); skippedIcon = ActionProducer.getIcon("skip.png", IconSize.SMALL); this.glassPane = new InfiniteProgressPanel(); setGlassPane(glassPane); debuggerActions = new ActionProducer(this, serviceUrl); requestResponsePanel = new RequestResponsePanel(this); requestResponsePanel.init(); testPlanChooser = new JComboBox(); testPlanChooser.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getItem() != null) { HDTestPlan selected = (HDTestPlan) event.getItem(); if (!selected.equals(currentTestPlan)) { setCurrentTestPlan(selected); } } } }); tankClientChooser = new JComboBox<TankClientChoice>(); debuggerActions.setChoiceComboBoxOptions(tankClientChooser); actionComponents = new ActionComponents(standalone, testPlanChooser, tankClientChooser, debuggerActions); addScriptChangedListener(actionComponents); setJMenuBar(actionComponents.getMenuBar()); Component topPanel = PanelBuilder.createTopPanel(actionComponents); Component bottomPanel = PanelBuilder.createBottomPanel(this); Component contentPanel = PanelBuilder.createContentPanel(this); final JPopupMenu popup = actionComponents.getPopupMenu(); scriptEditorTA.setPopupMenu(null); scriptEditorTA.addMouseListener(new MouseAdapter() { int lastHash; @Override public void mousePressed(MouseEvent e) { maybeShow(e); } @Override public void mouseReleased(MouseEvent e) { maybeShow(e); } private void maybeShow(MouseEvent e) { if (lastHash == getHash(e)) { return; } if (e.isPopupTrigger()) { // select the line try { int offset = scriptEditorTA.viewToModel(e.getPoint()); Rectangle modelToView = scriptEditorTA.modelToView(offset); Point point = new Point(modelToView.x + 1, e.getPoint().y); if (modelToView.contains(point)) { if (!multiSelect) { int line = scriptEditorTA.getLineOfOffset(offset); scriptEditorTA.setCurrentLine(line); } popup.show(e.getComponent(), e.getX(), e.getY()); } } catch (BadLocationException e1) { e1.printStackTrace(); } } else if (e.isShiftDown()) { int line = scriptEditorTA.getCaretLineNumber(); int start = Math.min(line, lastLine); int end = Math.max(line, lastLine); multiSelect = end - start > 1; if (multiSelect) { multiSelectStart = start; multiSelectEnd = end; try { scriptEditorTA.setEnabled(true); scriptEditorTA.select(scriptEditorTA.getLineStartOffset(start), scriptEditorTA.getLineEndOffset(end)); scriptEditorTA.setEnabled(false); } catch (BadLocationException e1) { e1.printStackTrace(); multiSelect = false; } } } else { multiSelect = false; lastLine = scriptEditorTA.getCaretLineNumber(); } lastHash = getHash(e); } private int getHash(MouseEvent e) { return new HashCodeBuilder().append(e.getButton()).append(e.getSource().hashCode()) .append(e.getPoint()).toHashCode(); } }); JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); mainSplit.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); mainSplit.setTopComponent(contentPanel); mainSplit.setBottomComponent(bottomPanel); mainSplit.setDividerLocation(600); mainSplit.setResizeWeight(0.8D); mainSplit.setDividerSize(5); add(topPanel, BorderLayout.NORTH); add(mainSplit, BorderLayout.CENTER); WindowUtil.centerOnScreen(this); pack(); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { handleKeyEvent(e); } return false; } }); }
From source file:com.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java
/** * Creates a {@link JGraphXVisualizer} object. *//*from ww w. j a v a 2s . c om*/ public JGraphXVisualizer() { graph = new mxGraph(); graph.setCellsEditable(false); graph.setAllowDanglingEdges(false); graph.setAllowLoops(false); graph.setCellsDeletable(false); graph.setCellsCloneable(false); graph.setCellsDisconnectable(false); graph.setDropEnabled(false); graph.setSplitEnabled(false); graph.setCellsBendable(false); graph.setConnectableEdges(false); graph.setCellsMovable(false); graph.setCellsResizable(false); graph.setAutoSizeCells(true); component = new mxGraphComponent(graph); component.setConnectable(false); component.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); component.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); nodeLookupMap = new DualHashBidiMap<>(); connToEdgeLookupMap = new MultiValueMap<>(); edgeToConnLookupMap = new HashMap<>(); vertexLingerTriggerMap = new HashMap<>(); textOutputArea = new JTextArea(); textOutputArea.setLineWrap(false); textOutputArea.setEditable(false); JScrollPane textOutputScrollPane = new JScrollPane(textOutputArea); textOutputScrollPane.setPreferredSize(new Dimension(0, 100)); frame = new JFrame("Visualizer"); frame.setSize(400, 400); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, textOutputScrollPane); splitPane.setResizeWeight(1.0); frame.setContentPane(splitPane); component.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { zoomFit(); } }); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { Recorder<A> rec = recorder.get(); if (rec != null) { IOUtils.closeQuietly(rec); } VisualizerEventListener veListener = listener.get(); if (veListener != null) { veListener.closed(); } } }); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); splitPane.setDividerLocation(0.2); }
From source file:edu.umich.robot.GuiApplication.java
/** * Entry point.//from www . j av a2s.c o m * * @param args Args from command line. */ public GuiApplication(Config config) { // Heavyweight is not desirable but it is the only thing that will // render in front of the Viewer on all platforms. Blame OpenGL JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); // must have config //Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(frame); if (config == null) System.exit(1); // Add more stuff to the config file that doesn't change between runs. Application.setupSimulatorConfig(config); setupViewerConfig(config); Configs.toLog(logger, config); controller = new Controller(config, new Gamepad()); controller.initializeGamepad(); viewer = new Viewer(config, frame); // This puts us in full 3d mode by default. The Viewer GUI doesn't // reflect this in its right click drop-down, a bug. viewer.getVisCanvas().getViewManager().setInterfaceMode(3); controller.addListener(RobotAddedEvent.class, listener); controller.addListener(RobotRemovedEvent.class, listener); controller.addListener(AfterResetEvent.class, listener); controller.addListener(ControllerActivatedEvent.class, listener); controller.addListener(ControllerDeactivatedEvent.class, listener); actionManager = new ActionManager(this); initActions(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { controller.shutdown(); System.exit(0); } }); frame.setLayout(new BorderLayout()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(actionManager.getAction(CreateSplinterRobotAction.class)); fileMenu.add(actionManager.getAction(CreateSuperdroidRobotAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ConnectSuperdroidAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ResetPreferencesAction.class)); /* fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(TextMessageAction.class)); */ fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(SaveMapAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ExitAction.class)); menuBar.add(fileMenu); JMenu cameraMenu = new JMenu("Camera"); cameraMenu.add(actionManager.getAction(DisableFollowAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAndThetaAction.class)); cameraMenu.add(new JSeparator()); cameraMenu.add(actionManager.getAction(MoveCameraBehindAction.class)); cameraMenu.add(actionManager.getAction(MoveCameraAboveAction.class)); menuBar.add(cameraMenu); JMenu objectMenu = new JMenu("Objects"); boolean added = false; for (String objectName : controller.getObjectNames()) { added = true; objectMenu.add(new AddObjectAction(this, objectName)); } if (!added) objectMenu.add(new JLabel("No objects available")); menuBar.add(objectMenu); menuBar.revalidate(); frame.setJMenuBar(menuBar); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); toolBar.add(actionManager.getAction(SoarParametersAction.class)); toolBar.add(actionManager.getAction(SoarDataAction.class)); toolBar.add(actionManager.getAction(ResetAction.class)); toolBar.add(actionManager.getAction(SoarToggleAction.class)); toolBar.add(actionManager.getAction(SoarStepAction.class)); toolBar.add(actionManager.getAction(SimSpeedAction.class)); frame.add(toolBar, BorderLayout.PAGE_START); viewerView = new ViewerView(viewer.getVisCanvas()); robotsView = new RobotsView(this, actionManager); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewerView, robotsView); splitPane.setDividerLocation(0.75); // TODO SoarApril /* viewer.addRobotSelectionChangedListener(robotsView); viewer.getVisCanvas().setDrawGround(true); */ viewer.getVisCanvas().addEventHandler(new VisCanvasEventAdapter() { public String getName() { return "Place Object"; } @Override public boolean mouseClicked(VisCanvas vc, GRay3D ray, MouseEvent e) { boolean ret = false; synchronized (GuiApplication.this) { if (objectToAdd != null && controller != null) { controller.addObject(objectToAdd, ray.intersectPlaneXY()); objectToAdd = null; ret = true; } else { double[] click = ray.intersectPlaneXY(); chatView.setClick(new Point2D.Double(click[0], click[1])); } } status.setMessage( String.format("%3.1f,%3.1f", ray.intersectPlaneXY()[0], ray.intersectPlaneXY()[1])); return ret; } }); consoleView = new ConsoleView(); chatView = new ChatView(this); controller.getRadio().addRadioHandler(chatView); final JSplitPane bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, consoleView, chatView); bottomPane.setDividerLocation(200); final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, bottomPane); splitPane2.setDividerLocation(0.75); frame.add(splitPane2, BorderLayout.CENTER); status = new StatusBar(); frame.add(status, BorderLayout.SOUTH); /* frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { final Preferences windowPrefs = getWindowPreferences(); final Rectangle r = frame.getBounds(); if(frame.getExtendedState() == JFrame.NORMAL) { windowPrefs.putInt("x", r.x); windowPrefs.putInt("y", r.y); windowPrefs.putInt("width", r.width); windowPrefs.putInt("height", r.height); windowPrefs.putInt("divider", splitPane.getDividerLocation()); } exit(); }}); Preferences windowPrefs = getWindowPreferences(); if (windowPrefs.get("x", null) != null) { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(windowPrefs.getInt("divider", 500)); } else { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(0.75); frame.setLocationRelativeTo(null); // center } */ frame.getRootPane().setBounds(0, 0, 1600, 1200); frame.getRootPane().registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.dispose(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); frame.pack(); frame.setVisible(true); for (String s : config.getStrings("splinters", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Splinter indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSplinterRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSplinter(s); else controller.createRealSplinter(s); controller.createSimLaser(s); if (prods != null) { controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } for (String s : config.getStrings("superdroids", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Superdroid indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSuperdroidRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSuperdroid(s); else { try { controller.createRealSuperdroid(s, "192.168.1.165", 3192); } catch (UnknownHostException e1) { e1.printStackTrace(); } catch (SocketException e1) { e1.printStackTrace(); } } controller.createSimLaser(s); if (prods != null) { // wait a sec try { Thread.sleep(1000); } catch (InterruptedException ex) { } controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * //w w w .j a v a 2 s . c o m */ protected void createUI() { JTabbedPane tabbedPane = new JTabbedPane(); rp = new RegProcessor(); rp.processSQL(); tree = new JTree(rp.getRoot(INCL_ANON)); propsTable = new JTable(); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { fillPropsTable(); } }); tree.setCellRenderer(new MyTreeCellRenderer()); Component topComp = UIHelper.createScrollPane(tree); Component botComp = UIHelper.createScrollPane(propsTable); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp); splitPane.setDividerLocation(0.5); splitPane.setOneTouchExpandable(true); splitPane.setLastDividerLocation(300); Dimension minimumSize = new Dimension(200, 400); topComp.setMinimumSize(minimumSize); botComp.setMinimumSize(minimumSize); tabbedPane.add("Registration", splitPane); final List<Pair<String, String>> trackDescPairs = rp.getTrackKeyDescPairs(); Vector<String> trkItems = new Vector<String>(); for (Pair<String, String> p : trackDescPairs) { trkItems.add(p.second); } //Collections.sort(trkItems); final JList list = new JList(trkItems); //pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1)); list.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int inx = list.getSelectedIndex(); if (inx > -1) { fillUsageItemsList(trackDescPairs.get(inx).first); } } } }); tabbedPane.add("Reg Stats", getStatsPane("Registration", rp.getRegNumHash().values(), "register")); DefaultListModel model = new DefaultListModel(); trackItemsList = new JList(model); topComp = UIHelper.createScrollPane(list); botComp = UIHelper.createScrollPane(trackItemsList); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComp, botComp); splitPane.setDividerLocation(0.5); splitPane.setOneTouchExpandable(true); topComp.setMinimumSize(minimumSize); botComp.setMinimumSize(minimumSize); splitPane.setDividerLocation(0.5); trackUsageHash = rp.getTrackCatsHash(); tabbedPane.add("Usage Tracking", splitPane); tabbedPane.add("User Stats", getStatsPane("Tracking", rp.getTrackIdHash().values(), "track")); add(tabbedPane, BorderLayout.CENTER); }
From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java
public void init() { // dataPoints = new LinkedList(); t1_x = t2_x = 0;// w ww. ja v a2s . c o m t1_y = t2_y = 0.001; simulatedPoints = setupUniformSimulate(numStocks, numSimulate); tabbedPanelContainer = new JTabbedPane(); show_tangent = true; // addGraph(chartPanel); // addToolbar(sliderPanel); initGraphPanel(); initMixPanel(); initInputPanel(); emptyTool(); emptyTool2(); leftControl = new JPanel(); leftControl.setLayout(new BoxLayout(leftControl, BoxLayout.PAGE_AXIS)); addRadioButton2Left("Number of Stocks:", "", numStocksArray, numStocks - 2, this); addRadioButton2Left("Show Tangent Line :", "", on_off, 0, this); JScrollPane mixPanelContainer = new JScrollPane(mixPanel); mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100)); addTabbedPane(GRAPH, graphPanel); addTabbedPane(INPUT, inputPanel); addTabbedPane(ALL, mixPanelContainer); setChart(); tabbedPanelContainer.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) { mixPanel.removeAll(); setMixPanel(); mixPanel.validate(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) { graphPanel.removeAll(); setChart(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == INPUT) { // setInputPanel(); } } }); statusTextArea = new JTextPane(); //right side lower statusTextArea.setEditable(false); JScrollPane statusContainer = new JScrollPane(statusTextArea); statusContainer.setPreferredSize(new Dimension(600, 140)); JSplitPane upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftControl), new JScrollPane(tabbedPanelContainer)); this.getMainPanel().removeAll(); if (SHOW_STATUS_TEXTAREA) { JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(upContainer), statusContainer); container.setContinuousLayout(true); container.setDividerLocation(0.6); this.getMainPanel().add(container, BorderLayout.CENTER); } else { this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER); } this.getMainPanel().validate(); }
From source file:com.vgi.mafscaling.LogView.java
private void createDataTab() { JPanel dataPanel = new JPanel(new BorderLayout()); add(dataPanel, "<html><div style='text-align: center;'>D<br>a<br>t<br>a</div></html>"); createToolBar(dataPanel);/*from w ww. j a v a2s .c o m*/ createLogViewPanel(); createGraghPanel(); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, logViewPanel, chartPanel); splitPane.setResizeWeight(0.5); splitPane.setOneTouchExpandable(true); splitPane.setContinuousLayout(true); splitPane.setDividerLocation(150); dataPanel.add(splitPane); }