List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color)
From source file:savant.view.swing.Frame.java
/** * Set the tracks associated with this frame. Normally, this should only be * done once, since the Frame also uses this opportunity to set up some GUI * elements which depend on the presence of loaded tracks. * * @param newTracks the tracks to be displayed in this frame */// w ww . ja v a 2 s .c om public void setTracks(Track[] newTracks) { Track t0 = newTracks[0]; DataFormat df = t0.getDataFormat(); if (!GenomeController.getInstance().isGenomeLoaded() && df != DataFormat.SEQUENCE) { handleEvent(new TrackCreationEvent(new Exception())); for (Track track : newTracks) { TrackController.getInstance().removeTrack(track); } DialogUtils.displayError("Sorry", "This does not appear to be a genome track. Please load a genome first."); return; } if (df == DataFormat.SEQUENCE) { GenomeController.getInstance().setSequence((SequenceTrack) newTracks[0]); } tracks = newTracks; graphPane.setTracks(tracks); for (Track t : tracks) { t.setFrame(this, initialDrawingMode); // Adds the track to the TrackController's internal list, and fires a TrackEvent.ADDED event to all listeners. TrackController.getInstance().addTrack(t); } commandBar = new FrameCommandBar(this); // We get the name and other properties from the zero'th track. setKey(t0.getName()); if (df != DataFormat.SEQUENCE && df != DataFormat.RICH_INTERVAL) { yMaxPanel = new JLabel(); yMaxPanel.setBorder(BorderFactory.createLineBorder(Color.darkGray)); yMaxPanel.setBackground(new Color(240, 240, 240)); yMaxPanel.setOpaque(true); yMaxPanel.setAlignmentX(0.5f); if (df == DataFormat.ALIGNMENT) { // We need to listen to genome changes so that we can redraw mismatches as appropriate. GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { // In certain BAM modes, we care about whether the sequence has been set (or unset). if (event.getNewGenome() == event.getOldGenome()) { forceRedraw(); } } }); } } GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.NORTHEAST; gbc.weightx = 1.0; gbc.insets = new Insets(4, 0, 0, 0); sidePanel.add(commandBar, gbc); sidePanel.add(legend, gbc); if (yMaxPanel != null) { sidePanel.add(yMaxPanel, gbc); } gbc.weighty = 1.0; gbc.fill = GridBagConstraints.VERTICAL; JPanel filler = new JPanel(); filler.setOpaque(false); sidePanel.add(filler, gbc); drawTracksInRange(LocationController.getInstance().getReferenceName(), LocationController.getInstance().getRange()); JPanel contentPane = (JPanel) getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(frameLandscape); }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java
/** Builds and lays out the UI. */ void buildUI() {//from ww w . j av a2s . c o m int width = TAB * getTabulationLevel(); if (DEFAULT_TEXT.equals(name)) width = 0; if (CollectionUtils.isEmpty(children)) { double[][] size = { { width, TableLayout.PREFERRED, 5, TableLayout.FILL }, { TableLayout.PREFERRED } }; setLayout(new TableLayout(size)); add(Box.createHorizontalStrut(width), "0, 0"); add(getLabel(), "1, 0"); add(getComponent(), "3, 0"); } else { //create a row. double[][] size = { { TableLayout.FILL }, { TableLayout.PREFERRED } }; TableLayout layout = new TableLayout(size); setLayout(layout); Iterator<ScriptComponent> i = children.iterator(); ScriptComponent child; setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); add(createRow(), "0, 0"); int index = 1; while (i.hasNext()) { child = i.next(); child.buildUI(); layout.insertRow(index, TableLayout.PREFERRED); add(child, "0, " + index); index++; } } }
From source file:org.isatools.isacreator.gui.DataEntryForm.java
/** * Generic initialisers for frame/* w ww . j ava2 s .c o m*/ */ protected void instantiatePane() { setLayout(new BorderLayout()); setBackground(UIHelper.BG_COLOR); setPreferredSize(new Dimension(600, 600)); setBorder(BorderFactory.createLineBorder(UIHelper.LIGHT_GREEN_COLOR)); }
From source file:org.biojava.bio.view.MotifAnalyzer.java
private JPanel getInputTab() { inputTab = new JPanel(new GridLayout(1, 1)); ////////////////// {/*from w ww . j a va2 s . c o m*/ JPanel generalPar = new JPanel(); inputTab.add(generalPar); GroupLayout inputTabLayout = new GroupLayout((JComponent) generalPar); generalPar.setLayout(inputTabLayout); generalPar.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "General Parameters", 0, 0, new Font(Font.DIALOG, Font.BOLD, 16), Color.black)); generalPar.setPreferredSize(new java.awt.Dimension(787, 291)); inputTabLayout.setHorizontalGroup(inputTabLayout.createSequentialGroup().addContainerGap(12, 12) .addGroup(inputTabLayout.createParallelGroup() .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getCheckReverse(), GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE) .addGap(250)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getMultipleDataSets(), GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addGap(255)) .addGroup(inputTabLayout.createSequentialGroup() .addGroup(inputTabLayout.createParallelGroup() .addComponent(getJLabel1(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel8(), GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) .addGap(74)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel7(), GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addGap(107)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel2(), GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE) .addGap(59)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel3(), GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE) .addGap(39)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel4(), GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE) .addGap(50)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel6(), GroupLayout.PREFERRED_SIZE, 126, GroupLayout.PREFERRED_SIZE) .addGap(61)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel5(), GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE) .addGap(79)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getJLabel9(), GroupLayout.PREFERRED_SIZE, 155, GroupLayout.PREFERRED_SIZE) .addGap(32))) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(inputTabLayout.createParallelGroup().addGroup( GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getMinPoints(), GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE) .addGap(134)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getClusteringEpsilon(), GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE) .addGap(134)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout .createSequentialGroup() .addComponent(getNumOfMotifs(), GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE) .addGap(187)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout .createSequentialGroup() .addComponent(getNumOfTrials(), GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE) .addGap(187)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout .createSequentialGroup() .addComponent(getMotifWidth(), GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE) .addGap(187)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout.createSequentialGroup() .addComponent(getDatasetTypeComboBox(), GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE) .addGap(111)) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout .createSequentialGroup() .addComponent(getDatasetComboBox(), GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE) .addGap(111)) .addComponent(getSpeciesType(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 256, GroupLayout.PREFERRED_SIZE) .addGroup(GroupLayout.Alignment.LEADING, inputTabLayout .createSequentialGroup() .addComponent(getNumOfClusters(), GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE) .addGap(134))))) .addContainerGap(317, 317)); inputTabLayout.setVerticalGroup(inputTabLayout.createSequentialGroup().addContainerGap() .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getNumOfMotifs(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel1(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getSpeciesType(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel2(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getNumOfTrials(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel3(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getMotifWidth(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel4(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getDatasetTypeComboBox(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel6(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getDatasetComboBox(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel5(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(20) .addComponent(getMultipleDataSets(), GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE) .addGap(19) .addComponent(getCheckReverse(), GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE) .addGap(16) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getClusteringEpsilon(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel7(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getMinPoints(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel8(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(inputTabLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(getNumOfClusters(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addComponent(getJLabel9(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(65, 65)); } return inputTab; }
From source file:org.pmedv.blackboard.board.BoardDesignerPerspective.java
@Override protected void initializeComponents() { setLayout(new BorderLayout()); toolTabPane = new JTabbedPane(JTabbedPane.BOTTOM); horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); ctx = AppContext.getContext();/*from w w w .j a va 2 s . c o m*/ resources = ctx.getBean(ResourceService.class); advisor = ctx.getBean(ApplicationWindowAdvisor.class); final String position = (String) Preferences.values .get("org.pmedv.blackboard.BoardDesignerPerspective.layerPanelPlacement"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { viewMap = new ViewMap(); rootWindow = DockingUtil.createRootWindow(viewMap, true); rootWindow.getWindowBar(Direction.DOWN).setEnabled(true); rootWindow.getWindowProperties().setMinimizeEnabled(true); DockingWindowsTheme theme = new SoftBlueIceDockingTheme(); rootWindow.getRootWindowProperties().addSuperObject(theme.getRootWindowProperties()); rootWindow.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getCloseButtonProperties().setVisible(false); rootWindow.getWindowProperties().getTabProperties().getNormalButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea = new TabWindow(); editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getCloseButtonProperties().setVisible(false); editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties() .getMinimizeButtonProperties().setVisible(true); editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties() .getMinimizeButtonProperties().setVisible(true); DockingWindowAdapter dockingAdapter = new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow window) throws OperationAbortedException { } }; editorArea.addListener(dockingAdapter); setDockingListener(dockingAdapter); rootWindow.setWindow(editorArea); if (position.equalsIgnoreCase("left")) { horizontalSplitPane.setRightComponent(rootWindow); } else { horizontalSplitPane.setLeftComponent(rootWindow); } advisor.setCurrentEditorArea(editorArea); } }); JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer(); taskpanecontainer.setBackground(new Color(182, 191, 205)); JXTaskPane shapePane = new JXTaskPane(); shapePane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.shapes.title")); shapePane.add(ctx.getBean(ShapePropertiesPanel.class)); taskpanecontainer.add(shapePane); ctx.getBean(ShapePropertiesPanel.class).getStartLineCombo().setSelectedItem(LineEdgeType.STRAIGHT); ctx.getBean(ShapePropertiesPanel.class).getEndLineCombo().setSelectedItem(LineEdgeType.STRAIGHT); ctx.getBean(ShapePropertiesPanel.class).getThicknessCombo().setSelectedItem(new BasicStroke(2.0f)); JXTaskPane layerPane = new JXTaskPane(); layerPane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.layers")); layerPane.add(ctx.getBean(ShowLayersCommand.class).getLayerPanel()); taskpanecontainer.add(layerPane); JScrollPane scrollPane = new JScrollPane(taskpanecontainer); if (position.equalsIgnoreCase("left")) { horizontalSplitPane.setLeftComponent(toolTabPane); } else { horizontalSplitPane.setRightComponent(toolTabPane); } horizontalSplitPane.setOneTouchExpandable(true); horizontalSplitPane.setDividerSize(10); toolTabPane.addTab(resources.getResourceByKey("tooltab.forms"), resources.getIcon("icon.paint"), scrollPane); final SymbolListPanel symbolListPanel = ctx.getBean(SymbolListPanel.class); toolTabPane.addTab(resources.getResourceByKey("tooltab.symbols"), resources.getIcon("icon.symbols"), symbolListPanel); final ModelListPanel modelListPanel = ctx.getBean(ModelListPanel.class); toolTabPane.addTab(resources.getResourceByKey("tooltab.models"), resources.getIcon("icon.model"), modelListPanel); add(horizontalSplitPane, BorderLayout.CENTER); commandArea = new RSyntaxTextArea(); commandArea.setRows(1); commandArea.setColumns(100); JPanel commandPanel = new JPanel(new BorderLayout()); commandPanel.add(new JLabel("Command :"), BorderLayout.WEST); commandPanel.add(commandArea, BorderLayout.CENTER); commandArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(Color.BLACK))); add(commandPanel, BorderLayout.NORTH); setupAutoComplete(); commandArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (commandArea.getText().startsWith("add ") && commandArea.getText().length() > 4 && commandArea.hasFocus()) { PartFactory pf = AppContext.getContext().getBean(PartFactory.class); String tokens[] = commandArea.getText().split(" "); StringBuffer partName = new StringBuffer(); for (int i = 1; i < tokens.length; i++) { partName.append(tokens[i] + " "); } String name = partName.toString().trim(); if (pf.getPartnames().contains(name)) { e.consume(); commandArea.setText(""); BoardUtil.addPart(name, EditorUtils.getCurrentActiveEditor()); } } else if (commandArea.getText().equals("new")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(CreateBoardCommand.class).execute(null); } else if (commandArea.getText().equals("resistor")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddResistorCommand.class).execute(null); } else if (commandArea.getText().equals("diode")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddDiodeCommand.class).execute(null); } else if (commandArea.getText().equals("text")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(AddTextCommand.class).execute(null); } else if (commandArea.getText().equals("open")) { e.consume(); commandArea.setText(""); new OpenBoardCommand().execute(null); } else if (commandArea.getText().equals("save")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(SaveBoardCommand.class).execute(null); } else if (commandArea.getText().equals("color")) { e.consume(); commandArea.setText(""); AppContext.getContext().getBean(ChooseColorCommand.class).execute(null); } } } }); horizontalSplitPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equalsIgnoreCase("dividerLocation")) { configProvider.getConfig().setDividerLocation(horizontalSplitPane.getDividerLocation()); } } }); ctx.getBean(ShapePropertiesPanel.class).getObjectField() .setText(resources.getResourceByKey("ShapePropertiesPanel.items.none")); ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner().setEnabled(false); ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner().setEnabled(false); initListeners(); }
From source file:org.squidy.designer.zoom.impl.SourceCodeShape.java
private JEditorPane createCodePane(URL sourceCodeURL) { codePane = new JEditorPane() { @Override/* w ww. ja v a 2 s . c o m*/ protected void processComponentKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE && e.isControlDown()) { System.out.println("Code completion"); int caretPosition = codePane.getCaretPosition(); String code = codePane.getText(); switch (code.charAt(caretPosition - 1)) { case '.': int pseudoCaret = caretPosition - 1; StringBuilder word = new StringBuilder(); for (char c = code.charAt(--pseudoCaret); !isEndOfWord(c); c = code.charAt(--pseudoCaret)) { word.append(c); } word = word.reverse(); System.out.println("WORD: " + word); // Class<?> type = // ReflectionUtil.loadClass(word.toString()); // // System.out.println("TYPE: " + type); JPopupMenu menu = new JPopupMenu("sdaf"); Point p = codePane.getCaret().getMagicCaretPosition(); System.out.println("CARET POS: " + p); // Point p = codePane.get // menu.setPreferredSize(new Dimension(200, 200)); menu.setLocation(30, 30); menu.add("test"); codePane.add(menu); // System.out.println(p); // codePane.get menu.show(codePane, p.x, p.y); break; } } super.processComponentKeyEvent(e); } /** * @param c * @return */ private boolean isEndOfWord(char c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t'; } }; EditorKit editorKit = new StyledEditorKit() { /** * */ private static final long serialVersionUID = 7024886168909204806L; public Document createDefaultDocument() { return new SyntaxDocument(); } }; codePane.setEditorKitForContentType("text/java", editorKit); codePane.setContentType("text/java"); try { FileInputStream fis = new FileInputStream(sourceCodeURL.getPath()); codePane.read(fis, null); originSourceCode = codePane.getText(); computeHeightOfCodePane(); codePane.setAutoscrolls(true); } catch (Exception e) { codePane.setText("File not found!"); } codePane.requestFocus(); codePane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); codePane.addKeyListener(new KeyAdapter() { /* * (non-Javadoc) * * @see * java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent) */ @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_SPACE: computeHeightOfCodePane(); break; } markDirty(); } }); // final JPopupMenu menu = new JPopupMenu(); // // JMenuItem i = new JMenuItem("Option 1"); // JMenuItem i2 = new JMenuItem("Option 2"); // menu.add(i); // menu.add(i2); // edit.add(menu); // getComponent().addKeyListener(new KeyAdapter() { // // public void keyTyped(KeyEvent e) { // if(e.getModifiers() == 2 && e.getKeyChar() == ' ') { // Point popupLoc = edit.getCaret().getMagicCaretPosition(); // System.out.println(popupLoc); // menu.setLocation(new // Point((int)popupLoc.getX(),(int)popupLoc.getY())); // menu.setVisible(true); // } // // } // }); return codePane; }
From source file:org.optaplanner.examples.meetingscheduling.swingui.MeetingSchedulingPanel.java
private JPanel createTableHeader(JLabel label) { JPanel headerPanel = new JPanel(new BorderLayout()); headerPanel.add(label, BorderLayout.NORTH); headerPanel.setBorder(//from ww w . ja v a2 s . c o m BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(TangoColorFactory.ALUMINIUM_5), BorderFactory.createEmptyBorder(2, 2, 2, 2))); return headerPanel; }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Initialize all GUI components and display the UI *//* w ww . j ava 2 s . com*/ protected void initGUI() { settingsCLM = new ProteinQuantChartsCLM(false); setTitle("Qurate"); try { setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this); assert null != contentPanel; } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } //Menu openFileAction = new OpenFileAction(this); createChartsAction = new CreateChartsAction(); filterPepXMLAction = new FilterPepXMLAction(this); proteinSummaryAction = new ProteinSummaryAction(this); try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } //Global stuff setSize(fullWidth, fullHeight); setContentPane(contentPanel); ListenerHelper helper = new ListenerHelper(this); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; leftPanel.setLayout(new GridBagLayout()); leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); //Properties panel stuff propertiesTable = new QuantEvent.QuantEventPropertiesTable(); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesTable); propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight)); //event summary table; disembodied eventSummaryTable = new QuantEventsSummaryTable(); eventSummaryTable.setVisible(true); ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel(); tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler()); JScrollPane eventSummaryScrollPane = new JScrollPane(); eventSummaryScrollPane.setViewportView(eventSummaryTable); eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight); eventSummaryFrame = new Frame("All Events"); eventSummaryFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { eventSummaryFrame.setVisible(false); } }); eventSummaryFrame.setSize(950, 450); eventSummaryFrame.add(eventSummaryScrollPane); //fields related to navigation navigationPanel = new JPanel(); backButton = new JButton("<"); backButton.setToolTipText("Previous Event"); backButton.setMaximumSize(new Dimension(50, 30)); backButton.setEnabled(false); forwardButton = new JButton(">"); forwardButton.setToolTipText("Next Event"); forwardButton.setMaximumSize(new Dimension(50, 30)); forwardButton.setEnabled(false); showEventSummaryButton = new JButton("Show All"); showEventSummaryButton.setToolTipText("Show all events in a table"); showEventSummaryButton.setEnabled(false); helper.addListener(backButton, "buttonBack_actionPerformed"); helper.addListener(forwardButton, "buttonForward_actionPerformed"); helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed"); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; navigationPanel.add(backButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; navigationPanel.add(forwardButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; navigationPanel.add(showEventSummaryButton, gbc); gbc.fill = GridBagConstraints.BOTH; navigationPanel.setBorder(BorderFactory.createTitledBorder("Event")); gbc.anchor = GridBagConstraints.PAGE_START; //Fields related to curation of events curationPanel = new JPanel(); curationPanel.setLayout(new GridBagLayout()); curationPanel.setBorder(BorderFactory.createTitledBorder("Curation")); //Quantitation curation JPanel quantCurationPanel = new JPanel(); quantCurationPanel.setLayout(new GridBagLayout()); quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation")); quantCurationButtonGroup = new ButtonGroup(); JRadioButton unknownRadioButton = new JRadioButton("?"); JRadioButton goodRadioButton = new JRadioButton("Good"); JRadioButton badRadioButton = new JRadioButton("Bad"); onePeakRatioRadioButton = new JRadioButton("1-Peak"); unknownRadioButton.setEnabled(false); goodRadioButton.setEnabled(false); badRadioButton.setEnabled(false); onePeakRatioRadioButton.setEnabled(false); quantCurationButtonGroup.add(unknownRadioButton); quantCurationButtonGroup.add(goodRadioButton); quantCurationButtonGroup.add(badRadioButton); quantCurationButtonGroup.add(onePeakRatioRadioButton); unknownRadioButtonModel = unknownRadioButton.getModel(); goodRadioButtonModel = goodRadioButton.getModel(); badRadioButtonModel = badRadioButton.getModel(); onePeakRadioButtonModel = onePeakRatioRadioButton.getModel(); helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed"); helper.addListener(goodRadioButton, "buttonCuration_actionPerformed"); helper.addListener(badRadioButton, "buttonCuration_actionPerformed"); helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; quantCurationPanel.add(unknownRadioButton, gbc); quantCurationPanel.add(badRadioButton, gbc); quantCurationPanel.add(goodRadioButton, gbc); quantCurationPanel.add(onePeakRatioRadioButton, gbc); gbc.anchor = GridBagConstraints.PAGE_START; //ID curation JPanel idCurationPanel = new JPanel(); idCurationPanel.setLayout(new GridBagLayout()); idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID")); idCurationButtonGroup = new ButtonGroup(); JRadioButton idUnknownRadioButton = new JRadioButton("?"); JRadioButton idGoodRadioButton = new JRadioButton("Good"); JRadioButton idBadRadioButton = new JRadioButton("Bad"); idUnknownRadioButton.setEnabled(false); idGoodRadioButton.setEnabled(false); idBadRadioButton.setEnabled(false); idCurationButtonGroup.add(idUnknownRadioButton); idCurationButtonGroup.add(idGoodRadioButton); idCurationButtonGroup.add(idBadRadioButton); idUnknownRadioButtonModel = idUnknownRadioButton.getModel(); idGoodRadioButtonModel = idGoodRadioButton.getModel(); idBadRadioButtonModel = idBadRadioButton.getModel(); helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; idCurationPanel.add(idUnknownRadioButton, gbc); idCurationPanel.add(idBadRadioButton, gbc); idCurationPanel.add(idGoodRadioButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; curationPanel.add(quantCurationPanel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; curationPanel.add(idCurationPanel, gbc); //curation comment commentTextField = new JTextField(); commentTextField.setToolTipText("Comment on this event"); //saves after every keypress. Would be more efficient to save when navigating away or saving to file commentTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (quantEvents == null) return; QuantEvent quantEvent = quantEvents.get(displayedEventIndex); //save the comment, being careful about tabs and new lines quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " ")); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); curationPanel.add(commentTextField, gbc); assessmentPanel = new JPanel(); assessmentPanel.setLayout(new GridBagLayout()); assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment")); assessmentTypeTextField = new JTextField(); assessmentTypeTextField.setEditable(false); assessmentPanel.add(assessmentTypeTextField, gbc); assessmentDescTextField = new JTextField(); assessmentDescTextField.setEditable(false); assessmentPanel.add(assessmentDescTextField, gbc); //Theoretical peak distribution gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; theoreticalPeaksPanel = new JPanel(); theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks")); theoreticalPeaksPanel.setLayout(new GridBagLayout()); theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight)); theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight)); showTheoreticalPeaks(); //Add everything to the left panel gbc.insets = new Insets(0, 5, 0, 5); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; leftPanel.addComponentListener(new LeftPanelResizeListener()); gbc.weighty = 10; gbc.fill = GridBagConstraints.VERTICAL; leftPanel.add(propertiesScrollPane, gbc); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_END; gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(assessmentPanel, gbc); leftPanel.add(theoreticalPeaksPanel, gbc); gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(curationPanel, gbc); leftPanel.add(navigationPanel, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_START; //Chart display multiChartDisplay = new TabbedMultiChartDisplayPanel(); multiChartDisplay.setResizeDelayMS(0); rightPanel.addComponentListener(new RightPanelResizeListener()); rightPanel.add(multiChartDisplay, gbc); //status message messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); //paranoia. Sometimes it seems Qurate doesn't exit when you close every window addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == WindowEvent.WINDOW_CLOSED) { dispose(); System.exit(0); } } }); }
From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java
License:asdf
/** * Initialize the GUI components//from w ww . ja va 2 s. c om */ protected void initGUI() { //Global stuff setSize(fullWidth, fullHeight); eventPropertiesTable = new QuantEvent.QuantEventPropertiesTable(); eventPropertiesTable.setVisible(true); JScrollPane eventPropsScrollPane = new JScrollPane(); eventPropsScrollPane.setViewportView(eventPropertiesTable); eventPropsScrollPane.setSize(propertiesWidth, propertiesHeight); eventPropertiesDialog = new JDialog(this, "Event Properties"); eventPropertiesDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); eventPropertiesDialog.setSize(propertiesWidth, propertiesHeight); eventPropertiesDialog.setContentPane(eventPropsScrollPane); ListenerHelper helper = new ListenerHelper(this); setTitle("Protein Summary"); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; try { (getOwner()).setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/ProteinQuantSummaryFrame.xml", this); assert null != contentPanel; setContentPane(contentPanel); } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } buttonSelectAllVisible.setEnabled(false); helper.addListener(buttonSelectAllVisible, "buttonSelectAllVisible_actionPerformed"); buttonDeselectAll.setEnabled(false); helper.addListener(buttonDeselectAll, "buttonDeselectAll_actionPerformed"); buildTurkHITsButton.setEnabled(false); helper.addListener(buildTurkHITsButton, "buttonBuildTurkHITs_actionPerformed"); loadSelectedEventsButton.setEnabled(false); helper.addListener(loadSelectedEventsButton, "buttonLoadSelected_actionPerformed"); autoAssessSelectedEventsButton.setEnabled(false); helper.addListener(autoAssessSelectedEventsButton, "buttonAutoAssess_actionPerformed"); showPropertiesButton.setEnabled(false); helper.addListener(showPropertiesButton, "buttonShowProperties_actionPerformed"); showProteinRatiosButton.setEnabled(false); helper.addListener(showProteinRatiosButton, "buttonShowProteinRatios_actionPerformed"); //summary panel summaryPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); summaryPanel.setPreferredSize(new Dimension(fullWidth, summaryPanelHeight)); summaryPanel.setMinimumSize(new Dimension(200, summaryPanelHeight)); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = 1; summaryPanel.add(buttonSelectAllVisible, gbc); summaryPanel.add(buttonDeselectAll, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; summaryPanel.add(showPropertiesButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; summaryPanel.add(showProteinRatiosButton, gbc); gbc.gridwidth = 1; summaryPanel.add(loadSelectedEventsButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; summaryPanel.add(autoAssessSelectedEventsButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; summaryPanel.add(buildTurkHITsButton, gbc); gbc.fill = GridBagConstraints.BOTH; eventsScrollPane = new JScrollPane(); eventsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); eventsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); eventsPanel = new JPanel(); eventsPanel.setLayout(new GridBagLayout()); eventsTable = new QuantEventsSummaryTable(); eventsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); eventsTable.getSelectionModel().addListSelectionListener(new EventsTableListSelectionHandler()); eventsScrollPane.setViewportView(eventsTable); eventsScrollPane.setMinimumSize(new Dimension(400, 400)); gbc.insets = new Insets(0, 0, 0, 0); mainPanel.add(eventsScrollPane, gbc); logRatioHistogramPanel = new PanelWithLogRatioHistAndFields(); logRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios")); logRatioHistogramPanel.setPreferredSize(new Dimension(width - 10, 300)); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 100; gbc.gridwidth = GridBagConstraints.REMAINDER; add(logRatioHistogramPanel, gbc); //status message messageLabel = new JLabel(); messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); statusPanel = new JPanel(); gbc.weighty = 1; statusPanel.setPreferredSize(new Dimension(width - 10, 50)); statusPanel.add(messageLabel, gbc); add(statusPanel, gbc); //per-protein event summary table; disembodied //todo: move this into its own class? it's getting kind of complicated proteinRatiosTable = new JTable(); proteinRatiosTable.setVisible(true); ListSelectionModel proteinTableSelectionModel = proteinRatiosTable.getSelectionModel(); proteinTableSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); proteinTableSelectionModel.addListSelectionListener(new ProteinTableListSelectionHandler()); JScrollPane proteinRatiosScrollPane = new JScrollPane(); proteinRatiosScrollPane.setViewportView(proteinRatiosTable); proteinRatiosScrollPane.setPreferredSize(new Dimension(proteinDialogWidth, proteinDialogHeight - PROTEINTABLE_HISTPANEL_HEIGHT - PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT - 70)); proteinRatiosDialog = new JDialog(this, "Protein Ratios"); proteinRatiosDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); proteinRatiosDialog.setSize(proteinDialogWidth, proteinDialogHeight); JPanel proteinRatiosContentPanel = new JPanel(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; proteinRatiosContentPanel.add(proteinRatiosScrollPane, gbc); proteinRatiosDialog.setContentPane(proteinRatiosContentPanel); perProteinLogRatioHistogramPanel = new PanelWithLogRatioHistAndFields(); perProteinLogRatioHistogramPanel.addRangeUpdateListener(new ProteinTableLogRatioHistogramListener()); perProteinLogRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios")); perProteinLogRatioHistogramPanel .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_HISTPANEL_HEIGHT)); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; proteinRatiosDialog.add(perProteinLogRatioHistogramPanel, gbc); perProteinPeptideLogRatioPanel = new JPanel(); perProteinPeptideLogRatioPanel.setBorder(BorderFactory.createTitledBorder("By Peptide")); perProteinPeptideLogRatioPanel .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT)); proteinRatiosDialog.add(perProteinPeptideLogRatioPanel, gbc); }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a new Password Text Field// w w w . j a va 2 s. c om * * @param container - parent container * @param name - name of text field * @param initialValue - initial value of text field * @param mnemonic - mnemonic key * @param tooltip - tool tip for field * @param suffix - suffix text for field * @param labelWidth - label width * @param placement - TableLayout placement * @param debug - turn on/off red debug borders * @return JPasswordField */ public static JPasswordField addPasswordField(Container container, String name, String initialValue, int mnemonic, String tooltip, String suffix, double labelWidth, String placement, boolean debug) { double[][] size = null; JPanel panel = new JPanel(); panel.setOpaque(false); if (suffix.equals("")) size = new double[][] { { labelWidth, TableLayout.FILL }, { 30 } }; else size = new double[][] { { labelWidth, TableLayout.FILL, TableLayout.PREFERRED }, { 30 } }; TableLayout layout = new TableLayout(size); panel.setLayout(layout); JLabel label = new JLabel(name); label.setDisplayedMnemonic(mnemonic); JPasswordField result = new JPasswordField(20); label.setLabelFor(result); label.setOpaque(false); result.setToolTipText(tooltip); if (initialValue != null) result.setText(initialValue); panel.add(label, "0, 0, r, c"); panel.add(result, "1, 0, f, c"); if (suffix.length() != 0) { JLabel suffixLabel = new JLabel(" " + suffix); panel.add(suffixLabel, "2,0, l, c"); } if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); container.add(panel, placement); return result; }