List of usage examples for java.awt.event ComponentListener ComponentListener
ComponentListener
From source file:org.pentaho.ui.xul.swing.tags.SwingHbox.java
public void setBackground(String src) { this.background = src; URL url = SwingImage.class.getClassLoader() .getResource(this.domContainer.getXulLoader().getRootDir() + src); // Then try to see if we can get the fully qualified file if (url == null) { try {//from w w w .j a va2 s. c om url = new File(src).toURL(); } catch (MalformedURLException e) { // do nothing and let the null url get caught below. } } if (url == null) { logger.error("Could not find resource: " + src); return; } final ImageIcon ico = new ImageIcon(url); container.addComponentListener(new ComponentListener() { public void componentHidden(ComponentEvent arg0) { } public void componentMoved(ComponentEvent arg0) { } public void componentResized(ComponentEvent arg0) { container.getGraphics().drawImage(ico.getImage(), 0, 0, container); } public void componentShown(ComponentEvent arg0) { } }); }
From source file:com.hammurapi.jcapture.CaptureFrame.java
public CaptureFrame(final AbstractCaptureApplet applet) throws Exception { super("Screen capture"); setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("camera.png"))); setUndecorated(true);/*from ww w . j a v a2 s .c om*/ Translucener.makeFrameTranslucent(this); setAlwaysOnTop(true); this.applet = applet; captureConfig = new CaptureConfig(); captureConfig.load(applet.loadConfig()); captureConfig.setBackgroundProcessor(applet.getBackgroundProcessor()); //--- GUI construction --- capturePanel = new JPanel(); final JLabel dimensionsLabel = new JLabel(""); capturePanel.add(dimensionsLabel, BorderLayout.CENTER); capturePanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); dimensionsLabel.setText(e.getComponent().getWidth() + " x " + e.getComponent().getHeight()); } }); JButton captureButton = new JButton(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { Rectangle bounds = capturePanel.getBounds(); Point loc = bounds.getLocation(); SwingUtilities.convertPointToScreen(loc, capturePanel); bounds.setLocation(loc); Properties props = captureConfig.setRecordingRectangle(bounds); if (props != null) { getApplet().storeConfig(props); } capturing.set(true); setVisible(false); } }); captureButton.setText("Capture"); captureButton.setToolTipText("Create a snapshot of the screen"); capturePanel.add(captureButton, BorderLayout.CENTER); recordButton = new JButton(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { Rectangle bounds = capturePanel.getBounds(); Point loc = bounds.getLocation(); SwingUtilities.convertPointToScreen(loc, capturePanel); bounds.setLocation(loc); Properties props = captureConfig.setRecordingRectangle(bounds); if (props != null) { getApplet().storeConfig(props); } recording.set(true); setVisible(false); } }); recordButton.setText("Record"); setRecordButtonState(); capturePanel.add(recordButton, BorderLayout.CENTER); JButton optionsButton = new JButton(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { new CaptureOptionsDialog(CaptureFrame.this).setVisible(true); } }); optionsButton.setText("Options"); capturePanel.add(optionsButton, BorderLayout.CENTER); JButton cancelButton = new JButton(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { CaptureFrame.this.setVisible(false); } }); cancelButton.setText("Cancel"); capturePanel.add(cancelButton, BorderLayout.CENTER); getContentPane().add(capturePanel, BorderLayout.CENTER); capturePanel.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); if (captureConfig.getRecordingRectangle() == null) { setSize(400, 300); setLocationRelativeTo(null); } else { setBounds(captureConfig.getRecordingRectangle()); } Insets dragInsets = new Insets(5, 5, 5, 5); new ComponentResizer(dragInsets, this); ComponentMover cm = new ComponentMover(); cm.registerComponent(this); cm.setDragInsets(dragInsets); addComponentListener(new ComponentListener() { @Override public void componentShown(ComponentEvent e) { // TODO Auto-generated method stub } @Override public void componentResized(ComponentEvent e) { // TODO Auto-generated method stub } @Override public void componentMoved(ComponentEvent e) { // TODO Auto-generated method stub } @Override public void componentHidden(ComponentEvent e) { if (capturing.get()) { capturing.set(false); try { capture(); } catch (Exception ex) { ex.printStackTrace(); } } else if (recording.get()) { recording.set(false); record(); } } }); }
From source file:it.unibas.spicygui.vista.MappingTaskTopComponent.java
private void initComponentListener() { this.addComponentListener(new ComponentListener() { public void componentResized(ComponentEvent e) { jLayeredPane.getGlassPane().updateUI(); }//from w ww . java 2 s . co m public void componentMoved(ComponentEvent e) { jLayeredPane.getGlassPane().updateUI(); } public void componentShown(ComponentEvent e) { if (!jLayeredPane.isAnalizzato()) { drawScene(); jLayeredPane.moveToFront(); } jLayeredPane.getGlassPane().updateUI(); modello.putBean(Costanti.MAPPINGTASK_SHOWED, scenario.getMappingTask()); } public void componentHidden(ComponentEvent e) { } }); }
From source file:loci.slim2.process.interactive.ui.DefaultDecayGraph.java
@Override public JFrame init(final JFrame parentFrame, final int bins, final double timeInc, final PixelPicker pixelPicker) { if (null == frame || !frame.isVisible() || this.bins != bins || this.timeInc != timeInc) { // save incoming parameters this.bins = bins; this.timeInc = timeInc; maxValue = timeInc * bins;//from w ww. j a v a 2 s. com this.picker = pixelPicker; if (null != frame) { // delete existing frame frame.setVisible(false); frame.dispose(); } // create the combined chart final JFreeChart chart = createCombinedChart(bins, timeInc); final ChartPanel panel = new ChartPanel(chart, true, true, true, false, true); panel.setDomainZoomable(false); panel.setRangeZoomable(false); panel.setPreferredSize(SIZE); // add start/stop vertical bar handling dataStart = transStop = null; final JXLayer<JComponent> layer = new JXLayer<JComponent>(panel); startStopDraggingUI = new StartStopDraggingUI<JComponent>(panel, decaySubPlot, this, maxValue); layer.setUI(startStopDraggingUI); // create a frame for the chart frame = new JFrame(); final Container container = frame.getContentPane(); container.setLayout(new BorderLayout()); container.add(layer, BorderLayout.CENTER); final JPanel miscPane = new JPanel(); miscPane.setLayout(new FlowLayout()); final JLabel label1 = new JLabel(CHI_SQUARE); miscPane.add(label1); chiSqTextField = new JTextField(7); chiSqTextField.setEditable(false); miscPane.add(chiSqTextField); final JLabel label2 = new JLabel(PHOTON_COUNT); miscPane.add(label2); photonTextField = new JTextField(7); photonTextField.setEditable(false); miscPane.add(photonTextField); logCheckBox = new JCheckBox(LOGARITHMIC); logCheckBox.setSelected(logarithmic); logCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { logarithmic = logCheckBox.isSelected(); NumberAxis photonAxis; if (logarithmic) { photonAxis = new LogarithmicAxis(PHOTON_AXIS_LABEL); } else { photonAxis = new NumberAxis(PHOTON_AXIS_LABEL); } decaySubPlot.setRangeAxis(photonAxis); } }); miscPane.add(logCheckBox); container.add(miscPane, BorderLayout.SOUTH); System.out.println("size from prefs " + getSizeFromPreferences()); // _frame.setSize(getSizeFromPreferences()); // _frame.setMaximumSize(MAX_SIZE); // doesn't work; bug in Java frame.pack(); frame.setLocationRelativeTo(parentFrame); frame.setVisible(true); frame.addComponentListener(new ComponentListener() { @Override public void componentHidden(final ComponentEvent e) { } @Override public void componentMoved(final ComponentEvent e) { } @Override public void componentResized(final ComponentEvent e) { // constrain maximum size boolean resize = false; final Dimension size = frame.getSize(); System.out.println("COMPONENT RESIZED incoming size " + size); if (size.width > MAX_SIZE.width) { size.width = MAX_SIZE.width; resize = true; } if (size.height > MAX_SIZE.height) { size.height = MAX_SIZE.height; resize = true; } if (size.width < MIN_SIZE.width) { size.width = MIN_SIZE.width; resize = true; } if (size.height < MIN_SIZE.height) { size.height = MIN_SIZE.height; resize = true; } if (resize) { frame.setSize(size); } System.out.println("save resized " + resize + " size " + size); saveSizeInPreferences(size); } @Override public void componentShown(final ComponentEvent e) { } }); this.frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { if (null != picker) { // TODO ARG does not work if you use the name 'pixelPicker' // (collides with local var; this.pP won't work). picker.hideCursor(); } } }); this.frame.setSize(getSizeFromPreferences()); } return this.frame; }
From source file:loci.slim.ui.DecayGraph.java
/** * Initialize the graph and returns the containing JFrame. * * @return frame/*from w w w.ja va2s . c o m*/ */ @Override public JFrame init(final JFrame frame, final int bins, final double timeInc, final ICursorListener cursorListener) { final boolean create = false; if (null == _frame || !_frame.isVisible() || _bins != bins || _timeInc != timeInc) { // save incoming parameters _bins = bins; _timeInc = timeInc; _maxValue = timeInc * bins; _cursorListener = cursorListener; if (null != _frame) { // delete existing frame _frame.setVisible(false); _frame.dispose(); } // create the combined chart final JFreeChart chart = createCombinedChart(bins, timeInc); final ChartPanel panel = new ChartPanel(chart, true, true, true, false, true); panel.setDomainZoomable(false); panel.setRangeZoomable(false); panel.setPreferredSize(SIZE); // add start/stop vertical bar handling _dataStart = _transStop = null; final JXLayer<JComponent> layer = new JXLayer<JComponent>(panel); _startStopDraggingUI = new StartStopDraggingUI<JComponent>(panel, _decaySubPlot, this, _maxValue); layer.setUI(_startStopDraggingUI); // create a frame for the chart _frame = new JFrame(); final Container container = _frame.getContentPane(); container.setLayout(new BorderLayout()); container.add(layer, BorderLayout.CENTER); final JPanel miscPane = new JPanel(); miscPane.setLayout(new FlowLayout()); final JLabel label1 = new JLabel(CHI_SQUARE); miscPane.add(label1); _chiSqTextField = new JTextField(7); _chiSqTextField.setEditable(false); miscPane.add(_chiSqTextField); final JLabel label2 = new JLabel(PHOTON_COUNT); miscPane.add(label2); _photonTextField = new JTextField(7); _photonTextField.setEditable(false); miscPane.add(_photonTextField); _logCheckBox = new JCheckBox(LOGARITHMIC); _logCheckBox.setSelected(_logarithmic); _logCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { _logarithmic = _logCheckBox.isSelected(); NumberAxis photonAxis; if (_logarithmic) { photonAxis = new LogarithmicAxis(PHOTON_AXIS_LABEL); } else { photonAxis = new NumberAxis(PHOTON_AXIS_LABEL); } _decaySubPlot.setRangeAxis(photonAxis); } }); miscPane.add(_logCheckBox); container.add(miscPane, BorderLayout.SOUTH); // IJ.log("size from prefs " + getSizeFromPreferences()); // _frame.setSize(getSizeFromPreferences()); // _frame.setMaximumSize(MAX_SIZE); // doesn't work; bug in Java _frame.pack(); _frame.setLocationRelativeTo(frame); _frame.setVisible(true); _frame.addComponentListener(new ComponentListener() { @Override public void componentHidden(final ComponentEvent e) { } @Override public void componentMoved(final ComponentEvent e) { } @Override public void componentResized(final ComponentEvent e) { // constrain maximum size boolean resize = false; final Dimension size = _frame.getSize(); // IJ.log("COMPONENT RESIZED incoming size " + size); if (size.width > MAX_SIZE.width) { size.width = MAX_SIZE.width; resize = true; } if (size.height > MAX_SIZE.height) { size.height = MAX_SIZE.height; resize = true; } if (size.width < MIN_SIZE.width) { size.width = MIN_SIZE.width; resize = true; } if (size.height < MIN_SIZE.height) { size.height = MIN_SIZE.height; resize = true; } if (resize) { _frame.setSize(size); } // IJ.log("save resized " + resize + " size " + size); saveSizeInPreferences(size); } @Override public void componentShown(final ComponentEvent e) { } }); _frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { _cursorListener.hideCursor(); } }); _frame.setSize(getSizeFromPreferences()); } return _frame; }
From source file:org.wandora.application.gui.topicpanels.ProcessingTopicPanel.java
@Override public void init() { Wandora wandora = Wandora.getWandora(); if (options == null) { if (USE_LOCAL_OPTIONS) { options = new Options(wandora.getOptions()); } else {/*from w w w. j av a2 s . c o m*/ options = wandora.getOptions(); } } tm = wandora.getTopicMap(); initComponents(); this.addComponentListener(this); try { // JavaSyntaxKit syntaxKit = new JavaSyntaxKit(); // syntaxKit.install(processingEditor); DefaultSyntaxKit.initKit(); processingEditor.setContentType("text/java"); } catch (Exception e) { e.printStackTrace(); } /* EditorKit ek=processingEditor.getEditorKit(); if(ek instanceof DefaultSyntaxKit){ DefaultSyntaxKit sk=(DefaultSyntaxKit)ek; sk.setProperty("Action.parenthesis", null); sk.setProperty("Action.brackets", null); sk.setProperty("Action.quotes", null); sk.setProperty("Action.double-quotes", null); sk.setProperty("Action.close-curly", null); }*/ readOptions(); KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK); processingEditor.getInputMap().put(key, "saveOperation"); Action saveOperation = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { saveCurrentSketch(); } }; processingEditor.getActionMap().put("saveOperation", saveOperation); processingEditor.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n"); innerPanel.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } @Override public void componentMoved(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } @Override public void componentShown(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } @Override public void componentHidden(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } }); if (currentSketch != null) { processingEditor.setText(currentSketch); } else { processingEditor.setText(defaultMessage); } FileNameExtensionFilter sketchFilter = new FileNameExtensionFilter("Processing sketch files", "sketch"); fc = new JFileChooser(); fc.setFileFilter(sketchFilter); fc.setCurrentDirectory(new File(sketchPath)); }
From source file:nl.ru.ai.projects.parrot.biomav.editor.BehaviorEditor.java
public BehaviorEditor() { ///////// Graph stuff graphViewer.addKeyListener(new KeyListener() { @Override/*w w w. j a v a2 s . c om*/ public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { for (TransitionEdge edge : graphViewer.getPickedEdgeState().getPicked()) { graph.removeEdge(edge); } for (BehaviorVertex vertex : graphViewer.getPickedVertexState().getPicked()) { graph.removeVertex(vertex); } e.consume(); repaint(); } } }); graphViewer.setBackground(Color.GRAY); graphViewer.setGraphMouse(graphMouse); graphMouse.add(graphMouseEditPlugin); graphMouse.add(graphMouseTranslatePlugin); graphMouse.add(graphMousePickPlugin); // Set label renderer VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge> renderer = new VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge>( graphViewer.getRenderContext()); graphViewer.getRenderContext().setVertexShapeTransformer(renderer); graphViewer.getRenderer().setVertexLabelRenderer(renderer); // Set label contents graphViewer.getRenderContext().setVertexLabelTransformer(new Transformer<BehaviorVertex, String>() { @Override public String transform(BehaviorVertex v) { return v.getSelectedBehavior(); } }); graphViewer.getRenderContext().setEdgeLabelTransformer(new Transformer<TransitionEdge, String>() { @Override public String transform(TransitionEdge e) { return e.getTransition(); } }); // Set fonts graphViewer.getRenderContext().setVertexFontTransformer(new Transformer<BehaviorVertex, Font>() { @Override public Font transform(BehaviorVertex v) { return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 20); } }); graphViewer.getRenderContext().setEdgeFontTransformer(new Transformer<TransitionEdge, Font>() { @Override public Font transform(TransitionEdge arg0) { return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 16); } }); // Fill color dependent on vertex activity graphViewer.getRenderContext().setVertexFillPaintTransformer(new Transformer<BehaviorVertex, Paint>() { @Override public Paint transform(BehaviorVertex vertex) { return vertex.isActive() ? Color.ORANGE : Color.RED; } }); graphViewer.getPickedVertexState().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { BehaviorVertex vertex = (BehaviorVertex) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { setNewSelectedParameterControlInterface(vertex); } if (e.getStateChange() == ItemEvent.DESELECTED) { if (vertex == selectedPCInterface) { setNewSelectedParameterControlInterface(null); } } } }); graphViewer.getPickedEdgeState().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { TransitionEdge edge = (TransitionEdge) e.getItem(); if (e.getStateChange() == ItemEvent.SELECTED) { setNewSelectedParameterControlInterface(edge); } if (e.getStateChange() == ItemEvent.DESELECTED) { if (edge == selectedPCInterface) { setNewSelectedParameterControlInterface(null); } } } }); this.addComponentListener(new ComponentListener() { @Override public void componentShown(ComponentEvent e) { } @Override public void componentResized(ComponentEvent e) { graphViewer.getGraphLayout().setSize(graphViewer.getSize()); } @Override public void componentMoved(ComponentEvent e) { } @Override public void componentHidden(ComponentEvent e) { } }); ///////////// Side panel (parameter control) pcInterfacePanel.setPreferredSize(new Dimension(200, 0)); pcInterfacePanel.setLayout(new BorderLayout()); pcInterfacePanelContents.setLayout(new GridLayout(0, 2, 0, 5)); pcInterfacePanel.add(pcInterfacePanelContents, BorderLayout.NORTH); ///////////// [this] setLayout(new BorderLayout(10, 10)); add(graphViewer, BorderLayout.CENTER); add(pcInterfacePanel, BorderLayout.EAST); }
From source file:com.xilinx.kintex7.MainScreen.java
public void initialize(LandingPage l, String imgName, int mode) { lp = l;/* www. ja va2 s. com*/ blockDiagram = Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/com/xilinx/kintex7/" + imgName)); led1 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/green.png")); led2 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/ledoff.png")); led3 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/red.png")); this.mode = mode; setModeText(mode); dataMismatch0 = dataMismatch2 = errcnt0 = errcnt1 = false; di = null; di = new DriverInfo(); di.init(mode); int ret = di.get_PCIstate(); //ret = di.get_PowerStats(); test1_option = DriverInfo.ENABLE_LOOPBACK; test2_option = DriverInfo.ENABLE_LOOPBACK; // create a new jframe, and pack it frame = new JFrame("Kintex-7 Connectivity TRD Control & Monitoring Interface"); frame.pack(); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); final int m = mode; frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // check if tests are running or not if ((testStarted || testStarted1) && ((m != LandingPage.APPLICATION_MODE) || (m != LandingPage.APPLICATION_MODE_P2P))) { int confirmed = JOptionPane.showConfirmDialog(null, "This will stop the tests and uninstall the drivers. Do you want to continue?", "Exit", JOptionPane.YES_NO_OPTION); if (confirmed == JOptionPane.YES_OPTION) { if (testStarted) { di.stopTest(0, test1_option, Integer.parseInt(t1_psize.getText())); testStarted = false; } if (testStarted1) { di.stopTest(1, test2_option, Integer.parseInt(t2_psize.getText())); testStarted1 = false; } timer.cancel(); textArea.removeAll(); di.flush(); di = null; System.gc(); lp.uninstallDrivers(); showDialog("Removing Device Drivers...Please wait..."); } } else { int confirmed = JOptionPane.showConfirmDialog(null, "This will Uninstall the drivers. Do you want to continue?", "Exit", JOptionPane.YES_NO_OPTION); if (confirmed == JOptionPane.YES_OPTION) { timer.cancel(); textArea.removeAll(); di.flush(); di = null; System.gc(); lp.uninstallDrivers(); showDialog("Removing Device Drivers...Please wait..."); } } } }); // make the frame half the height and width Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); height = screenSize.height; width = screenSize.width; minWidth = 1000; minHeight = 700; minFrameWidth = 1024; minFrameHeight = 745; reqHeight = 745; if (width < 1280) reqWidth = 1024; else if (width == 1280) reqWidth = 1280; else if (width < 1600) { reqWidth = width - (width * 4) / 100; reqHeight = height - (height * 3) / 100; } else { reqWidth = reqHeight = height = height - (height * 10) / 100; } frame.setSize(new Dimension(minFrameWidth, minFrameHeight)); frame.setResizable(true); frame.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent ce) { frame.setSize(new Dimension(Math.max(minFrameWidth, frame.getWidth()), Math.max(minFrameHeight, frame.getHeight()))); } @Override public void componentMoved(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } @Override public void componentShown(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } @Override public void componentHidden(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } }); frame.setVisible(true); frame.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/kintex7/icon.png"))); // center the jframe on screen frame.setLocationRelativeTo(null); frame.setContentPane(createContentPane()); keyWord = new SimpleAttributeSet(); StyleConstants.setForeground(keyWord, Color.RED); StyleConstants.setBold(keyWord, true); logStatus = new SimpleAttributeSet(); StyleConstants.setForeground(logStatus, Color.BLACK); StyleConstants.setBold(logStatus, true); if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) { testStarted = testStarted1 = true; } if (mode == LandingPage.PERFORMANCE_MODE_RAW) { t1_o1.setSelected(true); t1_o2.setEnabled(false); t1_o3.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); } if (mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t1_o2.setEnabled(false); t1_o3.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); t1_o1.setSelected(true); } // initialize max packet size ret = di.get_EngineState(); EngState[] engData = di.getEngState(); maxpkt0 = engData[0].MaxPktSize; minpkt0 = engData[0].MinPktSize; minpkt1 = engData[2].MinPktSize; maxpkt1 = engData[2].MaxPktSize; t1_psize.setText(String.valueOf(maxpkt0)); t2_psize.setText(String.valueOf(maxpkt1)); t1_psize.setToolTipText(minpkt0 + "-" + maxpkt0); t2_psize.setToolTipText(minpkt1 + "-" + maxpkt1); updateLog(di.getPCIInfo().getVersionInfo(), logStatus); updateLog("Configuration: " + modeText, logStatus); // LED status di.get_LedStats(); lstats = di.getLedStats(); setLedStats(lstats); startTimer(); }
From source file:com.xilinx.virtex7.MainScreen.java
public void initialize(LandingPage l, String imgName, int mode) { lp = l;/* w ww . j a v a 2 s. c om*/ blockDiagram = Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/com/xilinx/virtex7/" + imgName)); led1 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/green.png")); led2 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/ledoff.png")); led3 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/red.png")); this.mode = mode; setModeText(mode); dataMismatch0 = dataMismatch2 = errcnt0 = errcnt1 = false; dataMismatch4 = dataMismatch6 = errcnt2 = errcnt3 = false; di = null; di = new DriverInfo(); di.init(mode); int ret = di.get_PCIstate(); //ret = di.get_PowerStats(); test1_option = DriverInfo.ENABLE_LOOPBACK; test2_option = DriverInfo.ENABLE_LOOPBACK; test3_option = DriverInfo.ENABLE_LOOPBACK; test4_option = DriverInfo.ENABLE_LOOPBACK; // create a new jframe, and pack it frame = new JFrame("Virtex-7 XT Connectivity TRD Control & Monitoring Interface"); frame.pack(); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); final int m = mode; frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // check if tests are running or not if ((testStarted || testStarted1 || testStarted2 || testStarted3) && ((m != LandingPage.APPLICATION_MODE) || (m != LandingPage.APPLICATION_MODE_P2P))) { int confirmed = JOptionPane.showConfirmDialog(null, "This will stop the tests and uninstall the drivers. Do you want to continue?", "Exit", JOptionPane.YES_NO_OPTION); if (confirmed == JOptionPane.YES_OPTION) { if (testStarted) { di.stopTest(0, test1_option, Integer.parseInt(t1_psize.getText())); testStarted = false; } if (testStarted1) { di.stopTest(1, test2_option, Integer.parseInt(t2_psize.getText())); testStarted1 = false; } if (testStarted2) { di.stopTest(2, test3_option, Integer.parseInt(t3_psize.getText())); testStarted2 = false; } if (testStarted3) { di.stopTest(3, test4_option, Integer.parseInt(t4_psize.getText())); testStarted3 = false; } timer.cancel(); textArea.removeAll(); di.flush(); di = null; System.gc(); lp.uninstallDrivers(); showDialog("Removing Device Drivers...Please wait..."); } } else { int confirmed = JOptionPane.showConfirmDialog(null, "This will Uninstall the drivers. Do you want to continue?", "Exit", JOptionPane.YES_NO_OPTION); if (confirmed == JOptionPane.YES_OPTION) { timer.cancel(); textArea.removeAll(); di.flush(); di = null; System.gc(); lp.uninstallDrivers(); showDialog("Removing Device Drivers...Please wait..."); } } } }); // make the frame half the height and width Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); height = screenSize.height; width = screenSize.width; minWidth = 1000; minHeight = 600; minFrameWidth = 1024; minFrameHeight = 745; reqHeight = 745; if (width < 1280) reqWidth = 1024; else if (width == 1280) reqWidth = 1280; else if (width < 1600) { reqWidth = width - (width * 4) / 100; reqHeight = height - (height * 3) / 100; } else { reqWidth = reqHeight = height = height - (height * 10) / 100; } frame.setSize(new Dimension(minFrameWidth, minFrameHeight)); frame.setResizable(true); frame.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent ce) { frame.setSize(new Dimension(Math.max(minFrameWidth, frame.getWidth()), Math.max(minFrameHeight, frame.getHeight()))); } @Override public void componentMoved(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } @Override public void componentShown(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } @Override public void componentHidden(ComponentEvent ce) { //throw new UnsupportedOperationException("Not supported yet."); } }); frame.setVisible(true); frame.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/virtex7/icon.png"))); // center the jframe on screen frame.setLocationRelativeTo(null); frame.setContentPane(createContentPane()); keyWord = new SimpleAttributeSet(); StyleConstants.setForeground(keyWord, Color.RED); StyleConstants.setBold(keyWord, true); logStatus = new SimpleAttributeSet(); StyleConstants.setForeground(logStatus, Color.BLACK); StyleConstants.setBold(logStatus, true); if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) { testStarted = testStarted1 = testStarted2 = testStarted3 = true; } if (mode == LandingPage.PERFORMANCE_MODE_RAW) { t1_o1.setSelected(true); t1_o2.setEnabled(false); t1_o3.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); } if (mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t1_o2.setEnabled(false); t1_o3.setEnabled(false); t2_o2.setEnabled(false); t2_o3.setEnabled(false); t1_o1.setSelected(true); } // initialize max packet size ret = di.get_EngineState(); EngState[] engData = di.getEngState(); maxpkt0 = engData[0].MaxPktSize; minpkt0 = engData[0].MinPktSize; minpkt1 = engData[2].MinPktSize; maxpkt1 = engData[2].MaxPktSize; maxpkt2 = engData[4].MaxPktSize; minpkt2 = engData[4].MinPktSize; minpkt3 = engData[6].MinPktSize; maxpkt3 = engData[6].MaxPktSize; t1_psize.setText(String.valueOf(maxpkt0)); t2_psize.setText(String.valueOf(maxpkt1)); t3_psize.setText(String.valueOf(maxpkt2)); t4_psize.setText(String.valueOf(maxpkt3)); t1_psize.setToolTipText(minpkt0 + "-" + maxpkt0); t2_psize.setToolTipText(minpkt1 + "-" + maxpkt1); t3_psize.setToolTipText(minpkt2 + "-" + maxpkt2); t4_psize.setToolTipText(minpkt3 + "-" + maxpkt3); updateLog(di.getPCIInfo().getVersionInfo(), logStatus); updateLog("Configuration: " + modeText, logStatus); // LED status di.get_LedStats(); lstats = di.getLedStats(); setLedStats(lstats); // if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) { t2_o1.setEnabled(true); t4_o1.setEnabled(true); } else { t2_o1.setEnabled(false); t4_o1.setEnabled(false); } t2_o2.setEnabled(false); t2_o3.setEnabled(false); t3_o2.setEnabled(false); t3_o3.setEnabled(false); t4_o2.setEnabled(false); t4_o3.setEnabled(false); startTimer(); }
From source file:com.mirth.connect.client.ui.Frame.java
public Frame() { // Load RSyntaxTextArea language support LanguageSupportFactory.get().addLanguageSupport(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, MirthJavaScriptLanguageSupport.class.getName()); rightContainer = new JXTitledPanel(); channelTagInfo = new ChannelTagInfo(); deployedChannelTagInfo = new ChannelTagInfo(); taskPaneContainer = new JXTaskPaneContainer(); StringBuilder titleText = new StringBuilder(); if (!StringUtils.isBlank(PlatformUI.SERVER_NAME)) { titleText.append(PlatformUI.SERVER_NAME); } else {//from w w w. j a v a 2 s . co m titleText.append(PlatformUI.SERVER_URL); } titleText.append(" - " + UIConstants.TITLE_TEXT); setTitle(titleText.toString()); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setIconImage(new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/mirth_32_ico.png")) .getImage()); makePaneContainer(); connectionError = false; this.addComponentListener(new ComponentListener() { public void componentResized(ComponentEvent e) { if (channelEditPanel != null && channelEditPanel.filterPane != null) { channelEditPanel.filterPane.resizePanes(); } if (channelEditPanel != null && channelEditPanel.transformerPane != null) { channelEditPanel.transformerPane.resizePanes(); } } public void componentHidden(ComponentEvent e) { } public void componentShown(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } }); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (logout(true)) { System.exit(0); } } }); keyEventDispatcher = new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { // Update the state of the accelerator key (CTRL on Windows) updateAcceleratorKeyPressed(e); return false; } }; KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyEventDispatcher); }