List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:com.juanhg.angularmdisk.AngularMDiskApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTiempo = new JPanel(); panelTiempo.setToolTipText(""); panelTiempo.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); btnPhase1 = new JButton("Lanzar Insecto"); btnPhase1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnPhase1Event();// w w w. j a va 2 s . c om } }); btnPhase1.setEnabled(false); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblDiskW = new JLabel("Velocidad Disco:"); lblDiskW.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblDiskWValue = new JLabel(); lblDiskWValue.setText("0"); lblDiskWValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblCriticRadius = new JLabel("Radio Cr\u00EDtico:"); lblCriticRadius.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblCriticRadiusValue = new JLabel(); lblCriticRadiusValue.setText("0"); lblCriticRadiusValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblCriticRadius, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE) .addGap(6)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblDiskW, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(26))) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblDiskWValue, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE) .addComponent(lblCriticRadiusValue, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE)) .addContainerGap(112, Short.MAX_VALUE))); gl_panelOutputs .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblDiskW).addComponent(lblDiskWValue)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblCriticRadius, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblCriticRadiusValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(121))); panelOutputs.setLayout(gl_panelOutputs); panel_1 = new JPanel(); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control .createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup() .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 396, GroupLayout.PREFERRED_SIZE) .addComponent(panelOutputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) .addComponent(panelTiempo, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)) .addGap(18)) .addGroup(gl_panel_control.createSequentialGroup() .addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 397, GroupLayout.PREFERRED_SIZE) .addContainerGap(17, Short.MAX_VALUE))))); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 202, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelTiempo, GroupLayout.PREFERRED_SIZE, 210, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, 15, Short.MAX_VALUE).addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panel_1.add(lblNewLabel); rdbtnCam1 = new JRadioButton("C\u00E1mara Fija"); rdbtnCam1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { rdbtnCam1Event(); } }); rdbtnCam1.setSelected(true); rdbtnCam2 = new JRadioButton("C\u00E1mara M\u00F3vil"); rdbtnCam2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { rdbtnCam2Event(); } }); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); btnPauseContinue = new JButton("Pausar"); btnPauseContinue.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnPauseContinue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnPauseContinueEvent(event); } }); panel = new JPanel(); panel.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); label = new JLabel("Datos de la Simulaci\u00F3n"); label.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(label); GroupLayout gl_panelTiempo = new GroupLayout(panelTiempo); gl_panelTiempo.setHorizontalGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup().addContainerGap() .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING, false) .addComponent(btnPhase1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING).addGroup(gl_panelTiempo .createSequentialGroup().addGap(52) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addComponent(rdbtnCam2).addComponent(rdbtnCam1, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelTiempo.createSequentialGroup().addGap(21).addComponent( btnPauseContinue, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE))) .addContainerGap(47, Short.MAX_VALUE)) .addComponent(panel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)); gl_panelTiempo.setVerticalGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup() .addComponent(panel, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE).addGap(22) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup().addComponent(rdbtnCam1) .addPreferredGap(ComponentPlacement.RELATED).addComponent(rdbtnCam2)) .addComponent(btnPhase1, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addComponent(btnPauseContinue, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE) .addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE)))); panelTiempo.setLayout(gl_panelTiempo); JLabel LabelBugMass = new JLabel("Masa del Insecto"); LabelBugMass.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelFallRadio = new JLabel("Radio de Ca\u00EDda"); labelFallRadio.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelBugVelocity = new JLabel("Velocidad del Insecto"); labelBugVelocity.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelDiskVelocity = new JLabel("Velocidad del Disco"); labelDiskVelocity.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblFallRadiusValue = new JLabel("10"); lblFallRadiusValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblBugVelocityValue = new JLabel("1"); lblBugVelocityValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVelocityValue = new JLabel("0.5"); lblVelocityValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblInitMassValue = new JLabel("30"); lblInitMassValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderBugInitMass = new JSlider(); sliderBugInitMass.setValue(30); sliderBugInitMass.setMinimum(20); sliderBugInitMass.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderBugInitMassEvent(); } }); sliderBugInitMass.setMaximum(70); sliderFallRadius = new JSlider(); sliderFallRadius.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderFallRadiusEvent(); } }); sliderFallRadius.setValue(10); sliderFallRadius.setMinorTickSpacing(1); sliderFallRadius.setMaximum(20); sliderBugVelocity = new JSlider(); sliderBugVelocity.setValue(10); sliderBugVelocity.setMaximum(20); sliderBugVelocity.setMinimum(5); sliderBugVelocity.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderBugVelocityEvent(); } }); sliderBugVelocity.setMinorTickSpacing(1); sliderDiskVelocity = new JSlider(); sliderDiskVelocity.setMaximum(10); sliderDiskVelocity.setMinimum(1); sliderDiskVelocity.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderDiskVelocityEvent(); } }); sliderDiskVelocity.setValue(5); sliderDiskVelocity.setMinorTickSpacing(1); JLabel lblCoeficienteDeRozamiento = new JLabel("Coef de Rozamiento"); lblCoeficienteDeRozamiento.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblFrictionValue = new JLabel("0.25"); lblFrictionValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderFriction = new JSlider(); sliderFriction.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderFrictionEvent(); } }); sliderFriction.setValue(25); sliderFriction.setMinorTickSpacing(1); sliderFriction.setMinimum(1); sliderFriction.setMaximum(90); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelInputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addComponent(labelBugVelocity, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelBugMass, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelFallRadio, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblInitMassValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblFallRadiusValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblBugVelocityValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(sliderFallRadius, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderBugInitMass, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderBugVelocity, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderDiskVelocity, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE)) .addGap(26)) .addGroup(gl_panelInputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(lblCoeficienteDeRozamiento, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE) .addComponent(labelDiskVelocity, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup() .addComponent(lblVelocityValue, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(204)) .addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup() .addComponent(lblFrictionValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(sliderFriction, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addGap(26)))) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(8) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelBugMass).addComponent(lblInitMassValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderBugInitMass, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelFallRadio).addComponent(lblFallRadiusValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderFallRadius, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup( gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelBugVelocity) .addComponent(lblBugVelocityValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderBugVelocity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelDiskVelocity).addComponent(lblVelocityValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderDiskVelocity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup().addGap(12) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblCoeficienteDeRozamiento, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblFrictionValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(sliderFriction, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGap(47))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 432, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 560, GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addComponent(panel_visualizar, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE) .addComponent(panel_control, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 598, Short.MAX_VALUE)) .addContainerGap())); GridBagLayout gbl_panel_visualizar = new GridBagLayout(); gbl_panel_visualizar.columnWidths = new int[] { 0, 0 }; gbl_panel_visualizar.rowHeights = new int[] { 0, 0, 0 }; gbl_panel_visualizar.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_panel_visualizar.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; panel_visualizar.setLayout(gbl_panel_visualizar); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); gbc_tabbedPane.gridheight = 2; gbc_tabbedPane.fill = GridBagConstraints.BOTH; gbc_tabbedPane.gridx = 0; gbc_tabbedPane.gridy = 0; panel_visualizar.add(tabbedPane, gbc_tabbedPane); panelSimulation = new JPanelGrafica(); tabbedPane.addTab("Simulacin", null, panelSimulation, null); panelSimulation.setBackground(Color.WHITE); getContentPane().setLayout(groupLayout); }
From source file:gtu._work.etc.EnglishTester.java
private void initGUI() { try {// ww w. ja va 2s .co m JCommonUtil.defaultToolTipDelay(); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.setPreferredSize(new java.awt.Dimension(462, 259)); jTabbedPane1.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { // XXX // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx jTabbedPane1.requestFocus();// FOCUS TODO // XXX // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx } }); jTabbedPane1.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { System.out.println("2===" + evt.getKeyCode()); if (evt.getKeyCode() == 49) {// 0 jTabbedPane1.setSelectedIndex(0); } if (evt.getKeyCode() == 50) {// 1 jTabbedPane1.setSelectedIndex(1); } if (evt.getKeyCode() == 10) {// enter skipBtnAction(); } if (evt.getKeyCode() == 32) {// removeBtnAction(); } } }); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("english", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(420, 141)); { englishArea = new JTextArea(); jScrollPane1.setViewportView(englishArea); englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, 22)); } } { jPanel5 = new JPanel(); jPanel1.add(jPanel5, BorderLayout.SOUTH); jPanel5.setPreferredSize(new java.awt.Dimension(402, 65)); { skipBtn = new JButton(); jPanel5.add(skipBtn); skipBtn.setText("skip"); skipBtn.setPreferredSize(new java.awt.Dimension(187, 24)); skipBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { skipBtnAction(); } }); } { removeBtn = new JButton(); jPanel5.add(removeBtn); removeBtn.setText("remove"); removeBtn.setPreferredSize(new java.awt.Dimension(180, 24)); removeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { removeBtnAction(); } }); } { questionCountLabel = new JLabel(); jPanel5.add(questionCountLabel); questionCountLabel.setPreferredSize(new java.awt.Dimension(47, 21)); questionCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); questionCountLabel.setToolTipText(""); } { propCountLabel = new JLabel(); jPanel5.add(propCountLabel); propCountLabel.setPreferredSize(new java.awt.Dimension(45, 21)); propCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); propCountLabel.setToolTipText(""); } { googleSearchBtn = new JButton(); jPanel5.add(googleSearchBtn); googleSearchBtn.setText("<html>GPic</html>"); googleSearchBtn.setPreferredSize(new java.awt.Dimension(58, 24)); googleSearchBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String word = currentWordIndex.trim(); ClipboardUtil.getInstance().setContents(word); word = word.replace(" ", "%20"); URI uri = new URI( "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q=" + word); //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + word); Desktop.getDesktop().browse(uri); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { yahooDicBtn = new JButton(); jPanel5.add(yahooDicBtn); yahooDicBtn.setText("<html>Dict</html>"); yahooDicBtn.setPreferredSize(new java.awt.Dimension(57, 24)); yahooDicBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { // URI uri = new // URI("http://tw.dictionary.yahoo.com/dictionary?p=" // + currentWord.trim()); URI uri = new URI("http://www.dreye.com/axis/ddict.jsp?ver=big5&dod=0102&w=" + currentWordIndex.trim() + "&x=0&y=0"); Desktop.getDesktop().browse(uri); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { pickBtn = new JButton(); jPanel5.add(pickBtn); pickBtn.setText("<html>+Pick</html>"); pickBtn.setPreferredSize(new java.awt.Dimension(60, 24)); pickBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String key = currentWordIndex; String value = englishProp.getProperty(currentWordIndex); if (StringUtils.isEmpty(value)) { JCommonUtil._jOptionPane_showMessageDialog_error( "add pick failed : no such word => " + key); } else { pickProp.setProperty(key, value); JCommonUtil._jOptionPane_showMessageDialog_info( "key=" + key + "\nvalue=" + value + "\nsize=" + pickProp.size(), "??"); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { scanPicBtn = new JButton(); scanPicBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); jPanel5.add(scanPicBtn); scanPicBtn.setPreferredSize(new java.awt.Dimension(46, 24)); scanPicBtn.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (picDir == null) { JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null"); return; } if (picSet != null && picSet.size() > 0) { try { Desktop.getDesktop().open(picSet.iterator().next()); } catch (IOException e) { JCommonUtil.handleException(e); } return; } try { String text = currentWordIndex.trim().toLowerCase(); ClipboardUtil.getInstance().setContents(text); text = text.replace(" ", "%20"); URI uri = new URI( "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q=" + text); //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + text); Desktop.getDesktop().browse(uri); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { showChineseOption = new JCheckBox(); showChineseOption.setSelected(true); jPanel5.add(showChineseOption); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("chinese", null, jPanel2, null); jPanel2.setPreferredSize(new java.awt.Dimension(420, 211)); { showEnglishText = new JTextField(); jPanel2.add(showEnglishText, BorderLayout.NORTH); showEnglishText.setEditable(false); } { jPanel10 = new JPanel(); jPanel2.add(jPanel10, BorderLayout.CENTER); } { answerBtn[0] = new JButton(); jPanel10.add(answerBtn[0]); answerBtn[0].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[0]); } }); } { answerBtn[1] = new JButton(); jPanel10.add(answerBtn[1]); answerBtn[1].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[1]); } }); } { answerBtn[2] = new JButton(); jPanel10.add(answerBtn[2]); answerBtn[2].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[2]); } }); } { answerBtn[3] = new JButton(); jPanel10.add(answerBtn[3]); answerBtn[3].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[3].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[3]); } }); } { for (int ii = 0; ii < 4; ii++) { answerBtn[ii].setFont(new java.awt.Font("", 0, 14)); } } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("word", null, jPanel3, null); { jScrollPane3 = new JScrollPane(); jPanel3.add(jScrollPane3, BorderLayout.CENTER); jScrollPane3.setPreferredSize(new java.awt.Dimension(420, 187)); { propTable = new JTable(); jScrollPane3.setViewportView(propTable); JTableUtil.defaultSetting(propTable); propTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JPopupMenuUtil.newInstance(propTable) .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems()) .applyEvent(evt).show(); } }); } } { saveBtn = new JButton(); jPanel3.add(saveBtn, BorderLayout.SOUTH); saveBtn.setText("save table"); saveBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultTableModel model = JTableUtil.newInstance(propTable).getModel(); for (int ii = 0; ii < model.getRowCount(); ii++) { String key = (String) model.getValueAt(ii, 0); String value = (String) model.getValueAt(ii, 1); if (!englishProp.containsKey(key)) { englishProp.setProperty(key, value); } } try { englishProp.store(new FileOutputStream(englishFile), "comment"); } catch (Exception e) { e.printStackTrace(); } JCommonUtil._jOptionPane_showMessageDialog_info("save file ok! \n" + englishFile); } }); } { queryText = new JTextField(); jPanel3.add(queryText, BorderLayout.NORTH); queryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { String text = JCommonUtil.getDocumentText(event); Pattern pattern = Pattern.compile(text); Matcher matcher = null; DefaultTableModel propTableModel = JTableUtil.createModel(false, "english", "chinese"); for (Enumeration<?> enu = englishProp.propertyNames(); enu .hasMoreElements();) { String key = (String) enu.nextElement(); String value = englishProp.getProperty(key); if (key.contains(text)) { propTableModel.addRow(new Object[] { key, value }); continue; } matcher = pattern.matcher(key); if (matcher.find()) { propTableModel.addRow(new Object[] { key, value }); continue; } } propTable.setModel(propTableModel); } })); } } { jPanel4 = new JPanel(); jTabbedPane1.addTab("config", null, jPanel4, null); { savePickBtn = new JButton(); jPanel4.add(savePickBtn); savePickBtn.setText("save pick"); savePickBtn.setPreferredSize(new java.awt.Dimension(116, 40)); savePickBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (englishFile == null) { File file = new File(// PropertiesUtil.getJarCurrentPath(EnglishTester.class), "temp.properties"); englishFile = file; } if (pickProp.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error("?!"); return; } String fileName = englishFile.getName().replaceAll("\\.properties", "_bak.properties"); File jarWhereFile = PropertiesUtil.getJarCurrentPath(EnglishTester.class); fileName = JCommonUtil._jOptionPane_showInputDialog("save target properties", fileName); if (StringUtils.isEmpty(fileName)) { JCommonUtil._jOptionPane_showMessageDialog_error("can't save!"); return; } if (fileName.equalsIgnoreCase(englishFile.getName())) { JCommonUtil._jOptionPane_showMessageDialog_error( "??englishFile???"); return; } if (!fileName.endsWith(".properties")) { fileName += ".properties"; } File newFile = new File(jarWhereFile, fileName); Properties oldProp = new Properties(); if (newFile.exists()) { try { oldProp.load(new FileInputStream(newFile)); } catch (Exception e) { e.printStackTrace(); } } oldProp.putAll(pickProp); try { oldProp.store(new FileOutputStream(newFile), "comment"); } catch (Exception e) { e.printStackTrace(); } JCommonUtil._jOptionPane_showMessageDialog_info("save file ok! \n" + newFile); } }); } { saveConfigBtn2 = new JButton(); jPanel4.add(saveConfigBtn2); saveConfigBtn2.setText("save config"); saveConfigBtn2.setPreferredSize(new java.awt.Dimension(108, 40)); saveConfigBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveConfigBtnAction(); } }); } { startAllBtn = new JButton(); jPanel4.add(startAllBtn); startAllBtn.setText("start all"); startAllBtn.setPreferredSize(new java.awt.Dimension(101, 40)); startAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Object[] files = fileList.getSelectedValues(); if (files == null || files.length == 0) { JCommonUtil ._jOptionPane_showMessageDialog_error("?properties"); return; } Properties allProp = new Properties(); Properties prop = new Properties(); for (Object ff : files) { try { prop.load(new FileInputStream((File) ff)); } catch (Exception e) { JCommonUtil.handleException(e); } allProp.putAll(prop); } englishProp = allProp; System.out.println("englishProp = " + englishProp.size()); startNow(); } }); } { startNow = new JButton(); jPanel4.add(startNow); startNow.setText("start now"); startNow.setPreferredSize(new java.awt.Dimension(101, 40)); startNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { startNow(); } }); } { picOnly = new JCheckBox(); jPanel4.add(picOnly); picOnly.setText("picOnly"); } { sortChkBox = new JCheckBox(); jPanel4.add(sortChkBox); sortChkBox.setText("sort"); } { showPicChkBox = new JCheckBox(); showPicChkBox.setSelected(true); jPanel4.add(showPicChkBox); showPicChkBox.setText("showPic"); } { JCommonUtil.defaultToolTipDelay(); fontSizeSliber = new JSlider(JSlider.HORIZONTAL); jPanel4.add(fontSizeSliber); fontSizeSliber.setPreferredSize(new java.awt.Dimension(419, 35)); fontSizeSliber.setValue(22); fontSizeSliber.setMinimum(22); fontSizeSliber.setMaximum(300); fontSizeSliber.setMajorTickSpacing(30); fontSizeSliber.setMinorTickSpacing(5); fontSizeSliber.setCursor(new Cursor(Cursor.HAND_CURSOR)); fontSizeSliber.setPaintTicks(false); fontSizeSliber.setPaintLabels(true); { picFolderDirText = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(picFolderDirText, true); jPanel4.add(picFolderDirText); picFolderDirText.setColumns(20); } fontSizeSliber.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int size = fontSizeSliber.getValue(); fontSizeSliber.setToolTipText("" + size); englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, size)); } }); } } { jPanel6 = new JPanel(); jTabbedPane1.addTab("files", null, jPanel6, null); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); { jScrollPane4 = new JScrollPane(); jPanel6.add(jScrollPane4, BorderLayout.CENTER); jScrollPane4.setPreferredSize(new java.awt.Dimension(420, 211)); { fileList = new JList(); reloadFileList(); jScrollPane4.setViewportView(fileList); fileList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { final File file = JListUtil.getLeadSelectionObject(fileList); if (JMouseEventUtil.buttonRightClick(1, evt)) { JPopupMenuUtil.newInstance(EnglishTester.this.fileList).applyEvent(evt)// .addJMenuItem("reload", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reloadFileList(); } })// .addJMenuItem("delete : " + file.getName(), new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean result = JCommonUtil ._JOptionPane_showConfirmDialog_yesNoOption( "delete : " + file.getName() + " ?", "confirm"); if (result) { file.delete(); reloadFileList(); } }// }).show(); return; } if (evt.getClickCount() == 1) { return; } if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "?,?\n" + file.getName(), "")) { loadEnglishFile(file); } } }); fileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(fileList).defaultJListKeyPressed(evt); } }); } } } { jPanel9 = new JPanel(); jTabbedPane1.addTab("pic", null, jPanel9, null); { picCheckText = new JTextField(); jPanel9.add(picCheckText); picCheckText.setPreferredSize(new java.awt.Dimension(177, 39)); } { picCheckBtn = new JButton(); jPanel9.add(picCheckBtn); picCheckBtn.setText("check"); picCheckBtn.setPreferredSize(new java.awt.Dimension(98, 43)); { jPanel11 = new JPanel(); jTabbedPane1.addTab("", null, jPanel11, null); jPanel11.setLayout(new BorderLayout(0, 0)); { inputTestArea2 = new JTextArea(); inputTestArea2.setFont(new Font("", Font.PLAIN, 12)); inputTestArea2.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { inputTestTrainer.keyin(e); } }); jPanel11.add(inputTestArea2, BorderLayout.SOUTH); } { inputTestArea1 = new JTextArea(); JTextAreaUtil.setWrapTextArea(inputTestArea1); inputTestArea1.setFont(new Font("", Font.PLAIN, 22)); jPanel11.add(inputTestArea1, BorderLayout.CENTER); } { panel = new JPanel(); jPanel11.add(panel, BorderLayout.NORTH); { inputTestLabel = new JLabel(""); panel.add(inputTestLabel); } { inputTestChk = new JCheckBox(""); inputTestChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { inputTestTrainer.initQuestion(); } }); panel.add(inputTestChk); } } } picCheckBtn.addActionListener(new ActionListener() { void scanPic(String searchWord, File file, Set<File> findFile) { if (file.isDirectory()) { File[] list = null; if ((list = file.listFiles()) != null) { for (File f : list) { scanPic(searchWord, f, findFile); } } } else { String text = searchWord; String name = file.getName().toLowerCase(); if (isMatch(name, text)) { findFile.add(file); } } } public void actionPerformed(ActionEvent evt) { picDir = new File(picFolderDirText.getText()); if (picDir == null) { JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null"); return; } if (!picDir.exists() || !picDir.isDirectory()) { JCommonUtil._jOptionPane_showMessageDialog_error("picDir "); return; } picCheckBtn.setText("search.."); String searchWord = picCheckText.getText().toLowerCase().trim(); Set<File> picSet2 = new HashSet<File>(); scanPic(searchWord, picDir, picSet2); if (picSet2 != null && picSet2.size() > 0) { picCheckBtn.setText("" + picSet2.size()); try { Desktop.getDesktop().open(picSet2.iterator().next()); } catch (IOException e) { JCommonUtil.handleException(e); } } else { picCheckBtn.setText("0"); } } }); } } } JCommonUtil.setJFrameIcon(this, "resource/images/ico/english_tester.ico"); pack(); this.setSize(423, 314); configHelper.init(); } catch (Exception e) { // add your error handling code here e.printStackTrace(); } }
From source file:geovista.network.gui.NodeLinkView.java
protected void addControls(final JPanel jp) { // Satellite/*from ww w. j a v a2 s . c om*/ // JComboBox modeBox = graphMouse.getModeComboBox(); // modeBox.addItemListener(((DefaultModalGraphMouse)satellite.getGraphMouse()).getModeListener()); // Control Panel jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); JPanel control_panel = new JPanel(new GridLayout(5, 1)); jp.add(control_panel, BorderLayout.EAST); // File_Layout Panel Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); jcb.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, vv)); jcb.setSelectedItem(FRLayout.class); final Box file_layout_panel = Box.createVerticalBox(); file_layout_panel.setBorder(BorderFactory.createTitledBorder("File_Layout")); final JComboBox graph_chooser = new JComboBox(g_names); graph_chooser.addActionListener(new GraphChooser(jcb)); JPanel layoutPanel = new JPanel(); jcb.setAlignmentX(Component.CENTER_ALIGNMENT); layoutPanel.add(jcb); graph_chooser.setAlignmentX(Component.CENTER_ALIGNMENT); layoutPanel.add(graph_chooser); file_layout_panel.add(layoutPanel); // Basic Operation Panel final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<Integer, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); // Tranform and picking part final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JButton collapse = new JButton("Collapse"); JButton expand = new JButton("Expand"); final Box basic_panel = Box.createVerticalBox(); basic_panel.setBorder(BorderFactory.createTitledBorder("Basic_Operation")); JPanel zoomPanel = new JPanel(); // plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); // minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); // modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(modeBox); // reset.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(reset); // collapse.setAlignmentY(Component.CENTER_ALIGNMENT); zoomPanel.add(collapse); // expand.setAlignmentY(Component.CENTER_ALIGNMENT); zoomPanel.add(expand); basic_panel.add(zoomPanel); // Vertex Part String[] vertexScoreType = { "VertexScore", "Degree", "BarycenterScorer", "BetweennessCentrality", "ClosenessCentrality", "DistanceCentralityScorer", "EigenvectorCentrality" }; final JComboBox vertexScoreList = new JComboBox(vertexScoreType); vertexScoreList.setSelectedIndex(0); vertexScoreList.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { // Renderer.VertexLabel.Position position = // (Renderer.VertexLabel.Position)e.getItem(); // vv.getRenderer().getVertexLabelRenderer().setPosition(position); if (vertexScoreList.getSelectedIndex() == 0) { // vertexScores = new VertexScoreTransformer<Integer, // Double>(voltage_scores); // vv.getRenderContext().setVertexShapeTransformer(new // ConstantTransformer(null)); // vssa.setScaling(false); vv.getRenderContext().setVertexLabelTransformer(nonvertexLabel); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 1) { // vertexScores = new VertexScoreTransformer<Integer, // Double>(degreeScorer); /* * vssa = new * VertexShapeSizeAspect<Integer,Number>((Graph<Integer * ,Number>)g, transformerDegree); * vv.getRenderContext().setVertexShapeTransformer(vssa); * vssa.setScaling(true); */ vv.getRenderContext().setVertexLabelTransformer(vertexLabelDegree); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 2) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerBarycenter); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelBarycenter); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 3) { // betweennessCentrality= new BetweennessCentrality(g); // voltages = new VertexScoreTransformer<Integer, // Double>(betweennessCentrality); vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerBetweenness); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelBetweenness); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 4) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerCloseness); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelCloseness); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 5) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerDistanceCentrality); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelDistanceCentrality); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 6) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerEigenvector); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelEigenvector); vv.repaint(); } } }); // cb.setSelectedItem(Renderer.VertexLabel.Position.SE); /* * v_shape = new JCheckBox("shape by degree"); * v_shape.addActionListener(this); v_size = new * JCheckBox("size by vertexScores"); v_size.addActionListener(this); * v_size.setSelected(true); v_aspect = new * JCheckBox("stretch by degree ratio"); * v_aspect.addActionListener(this); */ v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); e_labels = new JCheckBox("show edge labels"); e_labels.addActionListener(this); // Vertex Panel final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); // vertex_panel.add(v_stroke); vertex_panel.add(vertexScoreList); // vertex_panel.add(v_degree_labels); /* * vertex_panel.add(v_shape); vertex_panel.add(v_size); * vertex_panel.add(v_aspect); */ vertex_panel.add(v_small); // Edge Part final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); edge_panel.add(e_labels); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); // Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(g.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // Cluster Part final Box cluster_panel = Box.createVerticalBox(); cluster_panel.setBorder(BorderFactory.createTitledBorder("Cluster")); cluster_panel.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); cluster_panel.setBorder(sliderBorder); cluster_panel.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); cluster_panel.repaint(); vv.validate(); vv.repaint(); } } }); cluster_panel.add(groupVertices); control_panel.add(file_layout_panel); control_panel.add(vertex_panel); control_panel.add(edge_panel); control_panel.add(cluster_panel); control_panel.add(basic_panel); }
From source file:de.lazyzero.kkMulticopterFlashTool.KKMulticopterFlashTool.java
private void initGUI() { mainPanel = new JPanel(); // create the CellContraints CellConstraints cc = new CellConstraints(); // create the Layout for Panel this String panelColumns = "fill:pref:grow"; String panelRows = "3dlu,pref,3dlu,pref,3dlu,pref:grow"; FormLayout panelLayout = new FormLayout(panelColumns, panelRows); mainPanel.setLayout(panelLayout);/*www .j a va 2s . c o m*/ programmingPanel = ceateProgrammingPanel(); eepromPanel = createEEpromPanel(); tabbedPane.add(programmingPanel); programmerPanel = new ProgrammerPanel(this, programmers); controllerPanel = new ControllerPanel(this, avrs); mainPanel.add(programmerPanel, cc.xy(1, 2)); mainPanel.add(controllerPanel, cc.xy(1, 4)); mainPanel.add(tabbedPane, cc.xy(1, 6)); logger.log(Level.INFO, "Set the port from the properties [usb]: " + settings.getProperty("port", "usb")); programmerPanel.setPort(settings.getProperty("port", "usb")); programmerPanel.setRate(settings.getProperty("rate", "19200")); programmerPanel.setDefaultRate(new Boolean(settings.getProperty("defaultRate", "true"))); programmerPanel.setProgrammer(settings.getProperty("programmer", "usbasp")); controllerPanel.setController(settings.getProperty("controller", "Blackboard")); // testPanel = new TestPanel(); // tabbedPane.addTab(_("programmingPanel.title"), programmingPanel); tabbedPane.setBorder(new LineBorder(Color.WHITE)); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); tabbedPane.addTab(_("eepromPanel.title"), eepromPanel); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JTabbedPane sourceTabbedPane = (JTabbedPane) event.getSource(); if (sourceTabbedPane.getSelectedComponent().equals(eepromPanel)) { logger.info("changed to eepromPanel"); eepromResetPanel.firePropertyChange(ControllerPanel.CONTROLLER_CHANGED, 0, 1); } else if (sourceTabbedPane.getSelectedComponent().equals(programmingPanel)) { logger.info("changed to programmingPanel"); } } }); mainframe = new JFrame(_("title") + " " + VERSION + (isBeta ? " beta " + betaVersion : "") + " - " + mode); // mainframe.setPreferredSize(preferredSize); // mainframe.setSize(preferredSize); // mainframe.add(tabbedPane); mainframe.add(mainPanel); mainframe.setJMenuBar((new kkMenu(this, firmwareReader)).getBar()); mainframe.setIconImage(Icons.getImage(Icons.app, 16)); mainframe.pack(); mainframe.setLocationRelativeTo(getRootPane()); mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); firmwarePanel.firePropertyChange(ControllerPanel.CONTROLLER_CHANGED, 0, 1); }
From source file:com.juanhg.pot.PotApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); JLabel lblW = new JLabel("W:"); lblW.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblWValue = new JLabel(); lblWValue.setText("-"); lblWValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblQ = new JLabel("Q:"); lblQ.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblQValue = new JLabel(); lblQValue.setText("-"); lblQValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblT2 = new JLabel("T:"); lblT2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTOValue = new JLabel(); lblTOValue.setText("-"); lblTOValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblU = new JLabel("U:"); lblU.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblP = new JLabel("P:"); lblP.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVO = new JLabel("V:"); lblVO.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVOValue = new JLabel(); lblVOValue.setText("-"); lblVOValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblPValue = new JLabel(); lblPValue.setText("-"); lblPValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblUValue = new JLabel(); lblUValue.setText("-"); lblUValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(31).addGroup(gl_panelOutputs .createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblQ, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblWValue, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE) .addComponent(lblQValue, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))) .addGroup(Alignment.LEADING, gl_panelOutputs.createSequentialGroup() .addComponent(lblT2, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblTOValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))) .addGap(18)// w ww .ja va2s. co m .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblU, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(lblUValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblP, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblVO, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(lblVOValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))) .addGap(25))); gl_panelOutputs.setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs .createSequentialGroup().addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING).addGroup(gl_panelOutputs .createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblU, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblUValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(6) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblP, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(6) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblVO, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblVOValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelOutputs.createSequentialGroup().addGroup(gl_panelOutputs .createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblQ, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblWValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblQValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblT2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblTOValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)))) .addContainerGap())); panelOutputs.setLayout(gl_panelOutputs); JPanel panelLicense = new JPanel(); panelLicense.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control .setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(Alignment.TRAILING, gl_panel_control.createSequentialGroup().addContainerGap() .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addComponent(panelInputs, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelOutputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelLicense, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)) .addContainerGap())); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(24))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6 .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(69, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); lblT = new JLabel("Temperatura"); lblT.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblV = new JLabel("Volumen"); lblV.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMo = new JLabel("Masa Inicial"); lblMo.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblVValue = new JLabel("15"); lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMoValue = new JLabel("5"); lblMoValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTValue = new JLabel("300"); lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderT = new JSlider(); sliderT.setMinimum(280); sliderT.setMaximum(330); sliderT.setMinorTickSpacing(1); sliderT.setValue(300); sliderT.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderV = new JSlider(); sliderV.setMinimum(3); sliderV.setMaximum(30); sliderV.setMinorTickSpacing(1); sliderV.setValue(15); sliderV.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); sliderMo = new JSlider(); sliderMo.setMinimum(1); sliderMo.setMaximum(1000); sliderMo.setValue(5); sliderMo.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); lblM = new JLabel("Masa Final"); lblM.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMValue = new JLabel("4"); lblMValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderM = new JSlider(); sliderM.setMinimum(1); sliderM.setMaximum(1000); sliderM.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderM.setValue(4); sliderM.setMinorTickSpacing(1); lblType = new JLabel("Combustible"); lblType.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTypeValue = new JLabel("Madera"); lblTypeValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderType = new JSlider(); sliderType.setMinimum(1); sliderType.setMaximum(4); sliderType.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI5Event(); } }); sliderType.setValue(1); sliderType.setMinorTickSpacing(1); lblMc = new JLabel("Masa Combustible"); lblMc.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMcValue = new JLabel("10"); lblMcValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderMc = new JSlider(); sliderMc.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI6Event(); } }); sliderMc.setMinimum(1); sliderMc.setValue(10); sliderMc.setMinorTickSpacing(1); sliderMc.setMaximum(50); btn1 = new JButton("1"); btn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btn1function(); } }); btn2 = new JButton("2"); btn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btn1.setEnabled(true); btn2.setEnabled(false); btn3.setEnabled(true); lblT.setEnabled(true); lblTValue.setEnabled(true); sliderT.setEnabled(true); lblV.setEnabled(true); lblVValue.setEnabled(true); sliderV.setEnabled(true); lblMo.setEnabled(false); lblMoValue.setEnabled(false); sliderMo.setEnabled(false); lblM.setEnabled(false); lblMValue.setEnabled(false); sliderM.setEnabled(false); lblType.setEnabled(true); lblTypeValue.setEnabled(true); sliderType.setEnabled(true); lblMc.setEnabled(true); lblMcValue.setEnabled(true); sliderMc.setEnabled(true); model.setCurrentPhase(2); readInputs(); updateFire(); updateScrews(); updatePot(); updatePanels(); repaint(); } }); btn3 = new JButton("3"); btn3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btn1.setEnabled(true); btn2.setEnabled(true); btn3.setEnabled(false); lblT.setEnabled(true); lblTValue.setEnabled(true); sliderT.setEnabled(true); lblV.setEnabled(false); lblVValue.setEnabled(false); sliderV.setEnabled(false); lblMo.setEnabled(false); lblMoValue.setEnabled(false); sliderMo.setEnabled(false); lblM.setEnabled(true); lblMValue.setEnabled(true); sliderM.setEnabled(true); lblType.setEnabled(true); lblTypeValue.setEnabled(true); sliderType.setEnabled(true); lblMc.setEnabled(true); lblMcValue.setEnabled(true); sliderMc.setEnabled(true); model.setCurrentPhase(3); readInputs(); updateFire(); updateScrews(); updatePot(); updatePanels(); repaint(); } }); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) .addGroup(gl_panelInputs.createSequentialGroup().addGap(25) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs .createParallelGroup(Alignment.TRAILING).addGroup(gl_panelInputs .createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblV, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(lblMo, GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE) .addComponent(lblM, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(lblType, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(lblMc, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE)) .addGap(18)) .addComponent(lblT, GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblMoValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblTypeValue, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addComponent(lblMcValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)) .addGap(4).addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(sliderMc, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addComponent(sliderType, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addComponent(sliderM, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addComponent(sliderMo, GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE) .addComponent(sliderV, 0, 0, Short.MAX_VALUE) .addComponent(sliderT, 0, 0, Short.MAX_VALUE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btn3, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE))) .addContainerGap())); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE).addComponent(lblT) .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE).addComponent(lblV) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderV, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(lblMo) .addComponent(lblMoValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderMo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblM, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderM, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblType, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderType, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblTypeValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblMcValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblMc, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderMc, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(btn1, GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE) .addGap(12)) .addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(btn2, GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE) .addComponent(btn3, GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)) .addContainerGap())))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(UIManager.getColor("Button.background")); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 741, GroupLayout.PREFERRED_SIZE) .addContainerGap(31, Short.MAX_VALUE))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent( panel_visualizar, GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)) .addGroup(groupLayout.createSequentialGroup().addGap(12).addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, Short.MAX_VALUE))) .addContainerGap())); JPanel panel = new JPanel(); panel.setBounds(0, 0, 345, 568); panel.setBackground(Color.WHITE); panel.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_1 = new JPanel(); panel_1.setBounds(351, 0, 390, 568); panel_1.setBackground(Color.WHITE); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel33 = new JPanel(); panel33.setBounds(1, 38, 388, 529); panel33.setBackground(Color.WHITE); JPanel panel_5 = new JPanel(); panel_5.setBounds(1, 1, 388, 31); panel_5.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel lblGrficas = new JLabel("Gr\u00E1ficas"); lblGrficas.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_5.add(lblGrficas); panel_visualizar.setLayout(null); JPanel panel32 = new JPanel(); panel32.setBounds(1, 38, 343, 529); panel32.setBackground(Color.WHITE); JPanel panel_4 = new JPanel(); panel_4.setBounds(1, 1, 343, 31); panel_4.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel lblSimulacion = new JLabel("Simulaci\u00F3n"); lblSimulacion.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_4.add(lblSimulacion); panel_visualizar.add(panel); panel.setLayout(null); panel.add(panel_4); panel.add(panel32); panelPot = new JPanelGrafica(); panelPot.setBackground(Color.WHITE); GroupLayout gl_panel32 = new GroupLayout(panel32); gl_panel32.setHorizontalGroup(gl_panel32.createParallelGroup(Alignment.LEADING).addComponent(panelPot, GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)); gl_panel32.setVerticalGroup(gl_panel32.createParallelGroup(Alignment.LEADING).addComponent(panelPot, GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)); panel32.setLayout(gl_panel32); panel_visualizar.add(panel_1); panel_1.setLayout(null); panel_1.add(panel33); panelGraficas = new JPanelGrafica(); panelGraficas.setBackground(Color.WHITE); GroupLayout gl_panel33 = new GroupLayout(panel33); gl_panel33.setHorizontalGroup(gl_panel33.createParallelGroup(Alignment.LEADING).addComponent(panelGraficas, GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)); gl_panel33.setVerticalGroup(gl_panel33.createParallelGroup(Alignment.LEADING).addComponent(panelGraficas, GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)); panel33.setLayout(gl_panel33); panel_1.add(panel_5); getContentPane().setLayout(groupLayout); }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
/** * This method is called from within the constructor to initialize the form * components./*from w ww . j a v a2s. c o m*/ */ private void initComponents() { // Lee: for aesthetics and Linux won't display window controls on an untitled window. final String version = CopiedFromOtherJars.getVersion(); setTitle(CopiedFromOtherJars.getText("msg.title.mainWindow", version)); //$NON-NLS-1$ if (jbPathText == null) jbPathText = CopiedFromOtherJars.getText("msg.info.setJavaVersion"); //$NON-NLS-1$ if (jbMTJarText == null) jbMTJarText = CopiedFromOtherJars.getText("msg.info.selectMapToolJar"); //$NON-NLS-1$ if (mapToolJarName == null) mapToolJarName = CopiedFromOtherJars.getText("msg.info.selectMapToolJar"); //$NON-NLS-1$ final Container cp = getContentPane(); cp.setLayout(new BorderLayout()); final JPanel basicPanel = buildBasicPanel(); final JPanel langPanel = buildLanguagePanel(); final JPanel advancedPanel = buildAdvancedPanel(); final JPanel tsPanel = buildTroubleshootingPanel(); mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.basic"), basicPanel); //$NON-NLS-1$ mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.language"), langPanel); //$NON-NLS-1$ mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.advanced"), advancedPanel); //$NON-NLS-1$ mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.troubleshoot"), tsPanel); //$NON-NLS-1$ cp.add(mtlOptions, BorderLayout.CENTER); cp.add(jtfCommand, BorderLayout.SOUTH); // Lee: user must register MT executable jbLaunch.setEnabled( !mapToolJarName.equalsIgnoreCase(CopiedFromOtherJars.getText("msg.info.selectMapToolJar"))); //$NON-NLS-1$ jbLaunch.setText(CopiedFromOtherJars.getText("msg.info.launchMapTool")); //$NON-NLS-1$ jbLaunch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { jbLaunchActionPerformed(evt); } catch (final IOException e) { e.printStackTrace(); } } }); jtfCommand.setEditable(false); jtfCommand.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); jtfCommand.setText(CopiedFromOtherJars.getText("msg.info.cmdLineShownHere")); //$NON-NLS-1$ jtfCommand.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent arg0) { jtfCommand.selectAll(); } @Override public void focusLost(FocusEvent arg0) { jtfCommand.setCaretPosition(0); } }); jcbKeepOpen.setSelected(false); jcbKeepOpen.setText(CopiedFromOtherJars.getText("msg.info.keepLauncherOpen")); //$NON-NLS-1$ jcbKeepOpen.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.keepLauncherOpen")); //$NON-NLS-1$ final JPanel lowerPanel = new JPanel(); lowerPanel.setLayout(new GridLayout(3, 1)); lowerPanel.setBorder(new LineBorder(Color.BLACK)); lowerPanel.add(jbLaunch); lowerPanel.add(jcbKeepOpen); lowerPanel.add(jtfCommand); cp.add(lowerPanel, BorderLayout.SOUTH); mtlOptions.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { final JTabbedPane source = (JTabbedPane) e.getSource(); final String tabName = source.getTitleAt(source.getSelectedIndex()); if (jbLaunch.isEnabled()) { jbLaunch.requestFocusInWindow(); } else { if (tabName.equals(CopiedFromOtherJars.getText("msg.tab.basic"))) { //$NON-NLS-1$ jbMTJar.requestFocusInWindow(); } else if (tabName.equals(CopiedFromOtherJars.getText("msg.tab.language"))) { //$NON-NLS-1$ // This should work as long as there's at least one language in the list. langGroup.getElements().nextElement().requestFocusInWindow(); } else if (tabName.equals(CopiedFromOtherJars.getText("msg.tab.advanced"))) { //$NON-NLS-1$ jcbConsole.requestFocusInWindow(); jtfArgs.setText(extraArgs); } else { jcbEnableAssertions.requestFocusInWindow(); } } } }); Dimension d = new Dimension(advancedPanel.getPreferredSize().width, 25); jtfArgs.setPreferredSize(d); // mtlOptions.setPreferredSize(new Dimension(350, getPreferredSize().height)); d.width = -1; d.height = -1; JLabel tabLabel = null; int tabs = mtlOptions.getTabCount(); while (tabs-- > 0) { Component tab = mtlOptions.getTabComponentAt(tabs); if (tab == null) { if (tabLabel == null) tabLabel = new JLabel(); tabLabel.setText(mtlOptions.getTitleAt(tabs)); tab = tabLabel; } Dimension dim = tab.getPreferredSize(); d.width = Math.max(dim.width, d.width); d.height = Math.max(dim.height, d.height); } // Set width to width of largest tab * number of tabs, then add 20%. d.width = d.width * 120 / 100 * mtlOptions.getTabCount(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setIconImage(icon.getImage()); // To prevent the tabs from wrapping or scrolling setMinimumSize(new Dimension(d.width, getSize().height)); pack(); setResizable(true); }
From source file:davmail.ui.SettingsFrame.java
/** * DavMail settings frame.// w w w .j a v a 2 s . co m */ public SettingsFrame() { setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setTitle(BundleMessage.format("UI_DAVMAIL_SETTINGS")); try { setIconImage(DavGatewayTray.getFrameIcon()); } catch (NoSuchMethodError error) { DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_SET_ICON_IMAGE")); } JTabbedPane tabbedPane = new JTabbedPane(); // add help (F1 handler) tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F1"), "help"); tabbedPane.getActionMap().put("help", new AbstractAction() { public void actionPerformed(ActionEvent e) { DesktopBrowser.browse("http://davmail.sourceforge.net"); } }); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { boolean isSslEnabled = isSslEnabled(); popNoSSLCheckBox.setEnabled(Settings.getProperty("davmail.popPort") != null && isSslEnabled); imapNoSSLCheckBox.setEnabled(imapPortCheckBox.isSelected() && isSslEnabled); smtpNoSSLCheckBox.setEnabled(smtpPortCheckBox.isSelected() && isSslEnabled); caldavNoSSLCheckBox.setEnabled(caldavPortCheckBox.isSelected() && isSslEnabled); ldapNoSSLCheckBox.setEnabled(ldapPortCheckBox.isSelected() && isSslEnabled); } }); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(getSettingsPanel()); mainPanel.add(getDelaysPanel()); mainPanel.add(Box.createVerticalGlue()); tabbedPane.add(BundleMessage.format("UI_TAB_MAIN"), mainPanel); JPanel proxyPanel = new JPanel(); proxyPanel.setLayout(new BoxLayout(proxyPanel, BoxLayout.Y_AXIS)); proxyPanel.add(getProxyPanel()); proxyPanel.add(getNetworkSettingsPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_NETWORK"), proxyPanel); JPanel encryptionPanel = new JPanel(); encryptionPanel.setLayout(new BoxLayout(encryptionPanel, BoxLayout.Y_AXIS)); encryptionPanel.add(getKeystorePanel()); encryptionPanel.add(getSmartCardPanel()); // empty panel encryptionPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_ENCRYPTION"), encryptionPanel); JPanel loggingPanel = new JPanel(); loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS)); loggingPanel.add(getLoggingSettingsPanel()); // empty panel loggingPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_LOGGING"), loggingPanel); JPanel advancedPanel = new JPanel(); advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS)); advancedPanel.add(getOtherSettingsPanel()); // empty panel advancedPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_ADVANCED"), advancedPanel); if (OSXInfoPlist.isOSX()) { JPanel osxPanel = new JPanel(); osxPanel.setLayout(new BoxLayout(osxPanel, BoxLayout.Y_AXIS)); osxPanel.add(getOSXPanel()); // empty panel osxPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_OSX"), osxPanel); } add(BorderLayout.CENTER, tabbedPane); JPanel buttonPanel = new JPanel(); JButton cancel = new JButton(BundleMessage.format("UI_BUTTON_CANCEL")); JButton ok = new JButton(BundleMessage.format("UI_BUTTON_SAVE")); JButton help = new JButton(BundleMessage.format("UI_BUTTON_HELP")); ActionListener save = new ActionListener() { public void actionPerformed(ActionEvent evt) { // save options Settings.setProperty("davmail.url", urlField.getText()); Settings.setProperty("davmail.popPort", popPortCheckBox.isSelected() ? popPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecurepop", String.valueOf(popNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.imapPort", imapPortCheckBox.isSelected() ? imapPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecureimap", String.valueOf(imapNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.smtpPort", smtpPortCheckBox.isSelected() ? smtpPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecuresmtp", String.valueOf(smtpNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.caldavPort", caldavPortCheckBox.isSelected() ? caldavPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecurecaldav", String.valueOf(caldavNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.ldapPort", ldapPortCheckBox.isSelected() ? ldapPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecureldap", String.valueOf(ldapNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.keepDelay", keepDelayField.getText()); Settings.setProperty("davmail.sentKeepDelay", sentKeepDelayField.getText()); Settings.setProperty("davmail.caldavPastDelay", caldavPastDelayField.getText()); Settings.setProperty("davmail.imapIdleDelay", imapIdleDelayField.getText()); Settings.setProperty("davmail.useSystemProxies", String.valueOf(useSystemProxiesField.isSelected())); Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected())); Settings.setProperty("davmail.proxyHost", httpProxyField.getText()); Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText()); Settings.setProperty("davmail.proxyUser", httpProxyUserField.getText()); Settings.setProperty("davmail.proxyPassword", httpProxyPasswordField.getText()); Settings.setProperty("davmail.noProxyFor", noProxyForField.getText()); Settings.setProperty("davmail.bindAddress", bindAddressField.getText()); Settings.setProperty("davmail.clientSoTimeout", String.valueOf(clientSoTimeoutField.getText())); Settings.setProperty("davmail.allowRemote", String.valueOf(allowRemoteField.isSelected())); Settings.setProperty("davmail.server.certificate.hash", certHashField.getText()); Settings.setProperty("davmail.disableUpdateCheck", String.valueOf(disableUpdateCheck.isSelected())); Settings.setProperty("davmail.caldavEditNotifications", String.valueOf(caldavEditNotificationsField.isSelected())); Settings.setProperty("davmail.caldavAlarmSound", String.valueOf(caldavAlarmSoundField.getText())); Settings.setProperty("davmail.forceActiveSyncUpdate", String.valueOf(forceActiveSyncUpdateCheckBox.isSelected())); Settings.setProperty("davmail.defaultDomain", String.valueOf(defaultDomainField.getText())); Settings.setProperty("davmail.showStartupBanner", String.valueOf(showStartupBannerCheckBox.isSelected())); Settings.setProperty("davmail.disableGuiNotifications", String.valueOf(disableGuiNotificationsCheckBox.isSelected())); Settings.setProperty("davmail.imapAutoExpunge", String.valueOf(imapAutoExpungeCheckBox.isSelected())); Settings.setProperty("davmail.popMarkReadOnRetr", String.valueOf(popMarkReadOnRetrCheckBox.isSelected())); String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem(); String enableEws; if (EWS.equals(selectedEwsMode)) { enableEws = "true"; } else if (WEBDAV.equals(selectedEwsMode)) { enableEws = "false"; } else { enableEws = "auto"; } Settings.setProperty("davmail.enableEws", enableEws); Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected())); Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem()); Settings.setProperty("davmail.ssl.keystoreFile", keystoreFileField.getText()); Settings.setProperty("davmail.ssl.keystorePass", String.valueOf(keystorePassField.getPassword())); Settings.setProperty("davmail.ssl.keyPass", String.valueOf(keyPassField.getPassword())); Settings.setProperty("davmail.ssl.clientKeystoreType", (String) clientKeystoreTypeCombo.getSelectedItem()); Settings.setProperty("davmail.ssl.clientKeystoreFile", clientKeystoreFileField.getText()); Settings.setProperty("davmail.ssl.clientKeystorePass", String.valueOf(clientKeystorePassField.getPassword())); Settings.setProperty("davmail.ssl.pkcs11Library", pkcs11LibraryField.getText()); Settings.setProperty("davmail.ssl.pkcs11Config", pkcs11ConfigField.getText()); Settings.setLoggingLevel("rootLogger", (Level) rootLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("davmail", (Level) davmailLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("org.apache.commons.httpclient", (Level) httpclientLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("httpclient.wire", (Level) wireLoggingLevelField.getSelectedItem()); Settings.setProperty("davmail.logFilePath", logFilePathField.getText()); Settings.setProperty("davmail.logFileSize", logFileSizeField.getText()); setVisible(false); Settings.save(); if (osxHideFromDockCheckBox != null) { OSXInfoPlist.setOSXHideFromDock(osxHideFromDockCheckBox.isSelected()); } // restart listeners with new config DavGateway.restart(); } }; ok.addActionListener(save); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { reload(); setVisible(false); } }); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DesktopBrowser.browse("http://davmail.sourceforge.net"); } }); buttonPanel.add(ok); buttonPanel.add(cancel); buttonPanel.add(help); add(BorderLayout.SOUTH, buttonPanel); pack(); //setResizable(false); // center frame setLocation(getToolkit().getScreenSize().width / 2 - getSize().width / 2, getToolkit().getScreenSize().height / 2 - getSize().height / 2); urlField.requestFocus(); }
From source file:FirstForm.java
private void initSpinners() { defaultBorder = this.indiceSpinner.getBorder(); this.indiceSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 30.0, 0.1)); this.faseModuladoraSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.fasePortadoraSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.amplitudModuladoraSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.amplitudPortadoraSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.frecuenciaPortadoraSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.frecuenciaModuladoraSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.sensibilidadSpinner.setModel(new SpinnerNumberModel(0.0, 0.0, 100000.0, 0.1)); this.sensibilidadSpinner.addChangeListener(new ChangeListener() { @Override/*ww w . ja va 2 s . c om*/ public void stateChanged(ChangeEvent e) { indiceOrSensibility = false; indiceSpinner.setBorder(defaultBorder); sensibilidadSpinner.setBorder(BorderFactory.createLineBorder(new Color(39, 174, 96))); } }); this.indiceSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { indiceOrSensibility = true; sensibilidadSpinner.setBorder(defaultBorder); indiceSpinner.setBorder(BorderFactory.createLineBorder(new Color(39, 174, 96))); } }); this.indiceSpinner.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. indiceOrSensibility = true; sensibilidadSpinner.setBorder(defaultBorder); indiceSpinner.setBorder(BorderFactory.createLineBorder(new Color(39, 174, 96))); } @Override public void focusLost(FocusEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); this.sensibilidadSpinner.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. indiceOrSensibility = false; indiceSpinner.setBorder(defaultBorder); sensibilidadSpinner.setBorder(BorderFactory.createLineBorder(new Color(39, 174, 96))); } @Override public void focusLost(FocusEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelTesting.java
/** * Initialises the interface of the results panel. *//* w ww . j a v a 2s . com*/ protected void initialize() { setLayout(null); isSimulated = false; lblExportChartTo = new JLabel("Export chart to ..."); lblExportChartTo.setBounds(436, 479, 144, 14); lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblExportChartTo.setVisible(false); add(lblExportChartTo); btnCsv = new JButton("CSV"); btnCsv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String csv; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("csv")) { csv = ""; } else { csv = ".csv"; } String csvPath = file.getAbsolutePath() + csv; double[] selectedValues; OMRoom[] rooms = new OMRoom[7]; rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem(); rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem(); rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem(); rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem(); rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem(); rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem(); rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem(); int start = sliderStartTime.getValue(); final int day = 24; File csvFile = new File(csvPath); try { OMCampaign campaign; if (isResult) { campaign = getResultCampaign(); } else { campaign = new OMCampaign(start, rooms, 0); } FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); csvOutput.write("\"ID\";\"Room\";\"Radon\""); csvOutput.newLine(); selectedValues = campaign.getValueChain(); int x = 0; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[0].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[1].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[2].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[3].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[4].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[5].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } start = start + day; for (int i = start; i < start + day; i++) { csvOutput.write("\"" + i + "\";\"" + rooms[6].getId() + "\";\"" + (int) selectedValues[x] + "\""); csvOutput.newLine(); x++; } JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success", JOptionPane.INFORMATION_MESSAGE); csvOutput.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnCsv.setBounds(590, 475, 70, 23); btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnCsv.setVisible(false); add(btnCsv); btnPdf = new JButton("PDF"); btnPdf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String pdf; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("pdf")) { pdf = ""; } else { pdf = ".pdf"; } String pdfPath = file.getAbsolutePath() + pdf; OMRoom[] rooms = new OMRoom[7]; rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem(); rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem(); rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem(); rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem(); rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem(); rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem(); rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem(); int start = sliderStartTime.getValue(); OMCampaign campaign; try { if (isResult) { campaign = getResultCampaign(); } else { campaign = new OMCampaign(start, rooms, 0); } JFreeChart chart = OMCharts.createCampaignChart(campaign, false); String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + start; int height = (int) PageSize.A4.getWidth(); int width = (int) PageSize.A4.getHeight(); try { OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title); JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to create chart!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnPdf.setBounds(670, 475, 70, 23); btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnPdf.setVisible(false); add(btnPdf); lblSelectProject = new JLabel("Select Project"); lblSelectProject.setBounds(10, 65, 132, 14); lblSelectProject.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(lblSelectProject); lblSelectRooms = new JLabel("Select Rooms"); lblSelectRooms.setBounds(10, 94, 132, 14); lblSelectRooms.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(lblSelectRooms); lblStartTime = new JLabel("Start Time"); lblStartTime.setBounds(10, 123, 132, 14); lblStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(lblStartTime); lblWarning = new JLabel("Select 6 rooms and 1 cellar!"); lblWarning.setForeground(Color.RED); lblWarning.setBounds(565, 123, 175, 14); lblWarning.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblWarning.setVisible(false); add(lblWarning); sliderStartTime = new JSlider(); sliderStartTime.setMaximum(0); sliderStartTime.setBounds(152, 119, 285, 24); sliderStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(sliderStartTime); spnrStartTime = new JSpinner(); spnrStartTime.setModel(new SpinnerNumberModel(0, 0, 0, 1)); spnrStartTime.setBounds(447, 120, 108, 22); spnrStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(spnrStartTime); btnRefresh = new JButton("Load"); btnRefresh.setBounds(616, 61, 124, 23); btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(btnRefresh); btnMaximize = new JButton("Fullscreen"); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(btnMaximize); panelCampaign = new JPanel(); panelCampaign.setBounds(10, 150, 730, 315); panelCampaign.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(panelCampaign); progressBar = new JProgressBar(); progressBar.setBounds(10, 475, 730, 23); progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11)); progressBar.setVisible(false); add(progressBar); lblOpenOmbfile = new JLabel("Open OMB-File"); lblOpenOmbfile.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblOpenOmbfile.setBounds(10, 36, 132, 14); add(lblOpenOmbfile); lblHelp = new JLabel("Select an OMB-Object file to manually simulate virtual campaigns."); lblHelp.setForeground(Color.GRAY); lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); txtOmbFile = new JTextField(); txtOmbFile.setFont(new Font("SansSerif", Font.PLAIN, 11)); txtOmbFile.setColumns(10); txtOmbFile.setBounds(152, 33, 454, 20); add(txtOmbFile); btnBrowse = new JButton("Browse"); btnBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnBrowse.setBounds(616, 32, 124, 23); add(btnBrowse); comboBoxRoom1 = new JComboBox<OMRoom>(); comboBoxRoom1.setBounds(152, 90, 75, 22); comboBoxRoom1.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom1); comboBoxRoom2 = new JComboBox<OMRoom>(); comboBoxRoom2.setBounds(237, 90, 75, 22); comboBoxRoom2.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom2); comboBoxRoom3 = new JComboBox<OMRoom>(); comboBoxRoom3.setBounds(323, 90, 75, 22); comboBoxRoom3.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom3); comboBoxRoom4 = new JComboBox<OMRoom>(); comboBoxRoom4.setBounds(408, 90, 75, 22); comboBoxRoom4.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom4); comboBoxRoom5 = new JComboBox<OMRoom>(); comboBoxRoom5.setBounds(494, 90, 75, 22); comboBoxRoom5.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom5); comboBoxRoom6 = new JComboBox<OMRoom>(); comboBoxRoom6.setBounds(579, 90, 75, 22); comboBoxRoom6.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom6); comboBoxRoom7 = new JComboBox<OMRoom>(); comboBoxRoom7.setBounds(665, 90, 75, 22); comboBoxRoom7.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxRoom7); comboBoxProjects = new JComboBox<OMBuilding>(); comboBoxProjects.setBounds(152, 61, 454, 22); comboBoxProjects.setFont(new Font("SansSerif", Font.PLAIN, 11)); add(comboBoxProjects); comboBoxRoom1.addActionListener(this); comboBoxRoom1.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom2.addActionListener(this); comboBoxRoom2.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom3.addActionListener(this); comboBoxRoom3.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom4.addActionListener(this); comboBoxRoom4.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom5.addActionListener(this); comboBoxRoom5.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom6.addActionListener(this); comboBoxRoom6.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); comboBoxRoom7.addActionListener(this); comboBoxRoom7.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validateCampaign(); } }); sliderStartTime.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (comboBoxProjects.isEnabled() || isResult) { if (comboBoxProjects.getSelectedItem() != null) { spnrStartTime.setValue((int) sliderStartTime.getValue()); updateChart(); } } } }); spnrStartTime.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (comboBoxProjects.isEnabled() || isResult) { if (comboBoxProjects.getSelectedItem() != null) { sliderStartTime.setValue((Integer) spnrStartTime.getValue()); updateChart(); } } } }); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("") && !txtOmbFile.getText().equals(" ")) { txtOmbFile.setBackground(Color.WHITE); String ombPath = txtOmbFile.getText(); String omb; String[] tmpFileName = ombPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(ombPath + omb); setOmbFile(ombPath + omb); File ombFile = new File(ombPath + omb); if (ombFile.exists()) { txtOmbFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxProjects.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); progressBar.setIndeterminate(true); progressBar.setStringPainted(true); refreshTask = new Refresh(); refreshTask.execute(); } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { OMRoom[] rooms = new OMRoom[7]; rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem(); rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem(); rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem(); rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem(); rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem(); rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem(); rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem(); int start = sliderStartTime.getValue(); String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + start; OMCampaign campaign; if (isResult) { campaign = getResultCampaign(); } else { campaign = new OMCampaign(start, rooms, 0); } JPanel campaignChart = createCampaignPanel(campaign, false, true); JFrame chartFrame = new JFrame(); chartFrame.getContentPane().add(campaignChart); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight()); chartFrame.setTitle(title); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } catch (IOException ioe) { ioe.printStackTrace(); } } }); txtOmbFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { setOmbFile(txtOmbFile.getText()); } }); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String omb; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(file.getAbsolutePath() + omb); setOmbFile(file.getAbsolutePath() + omb); } } }); }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Setup the GUI components/*from w w w . j ava2s .c o m*/ */ private void setupGui() { setTitle("jSEA - Superposed Epoch Analysis"); getContentPane().setLayout(new MigLayout("", "[1200px,grow,fill]", "[][600px,grow,fill]")); initActions(); setupMenu(); setupToolbar(); this.setIconImage(Builder.getApplicationIcon()); { JSplitPane splitPane = new JSplitPane(); splitPane.setOneTouchExpandable(true); getContentPane().add(splitPane, "cell 0 1,alignx left,aligny top"); splitPane.setLeftComponent(contentPanel); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPanel.setLayout(new MigLayout("", "[grow,fill]", "[78.00][][][grow][]")); { JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Input Files", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel, "cell 0 0,grow"); panel.setLayout(new MigLayout("", "[][][grow][]", "[][]")); { JLabel lblContinuousTimeSeries = new JLabel("Continuous time series file:"); panel.add(lblContinuousTimeSeries, "cell 0 0,alignx trailing"); } { HelpTipButton label = new HelpTipButton( "Continuous time series data files should be two column comma seperated (CSV) text files. Column one should contains the years (in sequence), and column two should contain the data values. If there are header lines or comments in the file, these lines should beginning with a *"); panel.add(label, "cell 1 0,alignx trailing"); } { txtTimeSeriesFile = new JTextField(); txtwrapper = new TextComponentWrapper(txtTimeSeriesFile, PrefKey.JSEA_CONTINUOUS_TIME_SERIES_FILE, ""); txtTimeSeriesFile.setEditable(true); panel.add(txtTimeSeriesFile, "cell 2 0,growx"); txtTimeSeriesFile.setColumns(10); } { btnTimeSeriesFile = new JButton(); btnTimeSeriesFile.setIcon(Builder.getImageIcon("fileopen16.png")); btnTimeSeriesFile.setActionCommand("TimeSeriesFileBrowse"); btnTimeSeriesFile.addActionListener(this); btnTimeSeriesFile.setPreferredSize(new Dimension(25, 25)); btnTimeSeriesFile.setMaximumSize(new Dimension(25, 25)); btnTimeSeriesFile.putClientProperty("JButton.buttonType", "segmentedTextured"); btnTimeSeriesFile.putClientProperty("JButton.segmentPosition", "middle"); panel.add(btnTimeSeriesFile, "cell 3 0"); } { JLabel lblEventListFile = new JLabel("Event list file:"); panel.add(lblEventListFile, "cell 0 1,alignx trailing"); } { HelpTipButton helpTipButton = new HelpTipButton( "Event data files should be a text file with a single column of integer year values. If there are any header or comment lines, these should begin with a *"); panel.add(helpTipButton, "cell 1 1,alignx trailing"); } { txtEventListFile = new JTextField(); new TextComponentWrapper(txtEventListFile, PrefKey.JSEA_EVENT_LIST_FILE, ""); txtEventListFile.setEditable(false); panel.add(txtEventListFile, "cell 2 1,growx"); txtEventListFile.setColumns(10); } { btnEventListFile = new JButton(); btnEventListFile.setIcon(Builder.getImageIcon("fileopen16.png")); btnEventListFile.setActionCommand("EventListFileBrowse"); btnEventListFile.addActionListener(this); btnEventListFile.setPreferredSize(new Dimension(25, 25)); btnEventListFile.setMaximumSize(new Dimension(25, 25)); btnEventListFile.putClientProperty("JButton.buttonType", "segmentedTextured"); btnEventListFile.putClientProperty("JButton.segmentPosition", "middle"); panel.add(btnEventListFile, "cell 3 1"); } } { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Window, Simulation and Statistics", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel, "cell 0 1,grow"); panel.setLayout(new MigLayout("", "[right][][fill][10px:10px:10px][right][][90.00,grow,fill]", "[grow][][][]")); { JLabel lblYears = new JLabel("Years to analyse:"); panel.add(lblYears, "cell 0 0"); } { HelpTipButton helpTipButton = new HelpTipButton( "Specify which years from the dataset to analyse."); panel.add(helpTipButton, "cell 1 0"); } { JPanel panel_1 = new JPanel(); panel.add(panel_1, "cell 2 0 5 1,grow"); panel_1.setLayout(new MigLayout("fill, insets 0", "[80px:80px][][80px:80px,fill][grow]", "[]")); { spnFirstYear = new JSpinner(); spnFirstYear.setEnabled(false); panel_1.add(spnFirstYear, "cell 0 0,growx"); spnFirstYear.setModel(new SpinnerNumberModel(new Integer(0), null, null, new Integer(1))); spnFirstYear.setEditor(new JSpinner.NumberEditor(spnFirstYear, "#")); new SpinnerWrapper(spnFirstYear, PrefKey.JSEA_FIRST_YEAR, 0); } { JLabel lblTo = new JLabel("-"); panel_1.add(lblTo, "cell 1 0"); } { spnLastYear = new JSpinner(); spnLastYear.setEnabled(false); panel_1.add(spnLastYear, "cell 2 0"); spnLastYear.setModel(new SpinnerNumberModel(new Integer(2020), null, null, new Integer(1))); spnLastYear.setEditor(new JSpinner.NumberEditor(spnLastYear, "#")); new SpinnerWrapper(spnLastYear, PrefKey.JSEA_LAST_YEAR, 2020); } { chkAllYears = new JCheckBox("all years in series"); chkAllYears.setSelected(true); chkAllYears.setActionCommand("AllYearsCheckbox"); chkAllYears.addActionListener(this); panel_1.add(chkAllYears, "cell 3 0"); } } { JLabel lblLagsPriorTo = new JLabel("Lags prior to event:"); panel.add(lblLagsPriorTo, "cell 0 1"); } { HelpTipButton helpTipButton = new HelpTipButton(""); panel.add(helpTipButton, "cell 1 1"); } { spnLagsPrior = new JSpinner(); new SpinnerWrapper(spnLagsPrior, PrefKey.JSEA_LAGS_PRIOR_TO_EVENT, 6); panel.add(spnLagsPrior, "cell 2 1,growx"); // spnLagsPrior.setModel(new SpinnerNumberModel(6, 1, 100, 1)); spnLagsPrior.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { segmentationPanel.table.tableModel.clearSegments(); validateForm(); } }); } { JLabel lblSimulationsToRun = new JLabel("Simulations:"); panel.add(lblSimulationsToRun, "cell 4 1"); } { HelpTipButton helpTipButton = new HelpTipButton( "Number of simulations to run. Increasing the number of simulations increases the analysis time."); panel.add(helpTipButton, "cell 5 1"); } { spnSimulationsToRun = new JSpinner(); new SpinnerWrapper(spnSimulationsToRun, PrefKey.JSEA_SIMULATION_COUNT, 1000); panel.add(spnSimulationsToRun, "cell 6 1"); spnSimulationsToRun.setModel(new SpinnerNumberModel(1000, 1, 10096, 1)); } { JLabel lblLagsFollowingThe = new JLabel("Lags following the event:"); panel.add(lblLagsFollowingThe, "cell 0 2"); } { HelpTipButton helpTipButton = new HelpTipButton(""); panel.add(helpTipButton, "cell 1 2"); } { spnLagsAfter = new JSpinner(); new SpinnerWrapper(spnLagsAfter, PrefKey.JSEA_LAGS_AFTER_EVENT, 4); panel.add(spnLagsAfter, "cell 2 2,growx"); spnLagsAfter.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { segmentationPanel.table.tableModel.clearSegments(); validateForm(); } }); } { JLabel lblSeedNumber = new JLabel("Seed number:"); panel.add(lblSeedNumber, "cell 4 2"); } { HelpTipButton helpTipButton = new HelpTipButton( "The analysis requires a pseudo-random component which is seeded with the seed number (a large integer value). Running analyses with the same seed number enables produces the same results. You can leave the seed as the default number unless you specifically want to generate results from a different randomised pool."); panel.add(helpTipButton, "cell 5 2"); } { spnSeedNumber = new JSpinner(); new SpinnerWrapper(spnSeedNumber, PrefKey.JSEA_SEED_NUMBER, 30188); panel.add(spnSeedNumber, "cell 6 2"); spnSeedNumber.setModel(new SpinnerNumberModel(30188, 10000, 1000000, 1)); } { JLabel lblIncludeIncompleteWindow = new JLabel("Include incomplete epoch:"); panel.add(lblIncludeIncompleteWindow, "cell 0 3"); } { HelpTipButton helpTipButton = new HelpTipButton(""); panel.add(helpTipButton, "cell 1 3"); } { chkIncludeIncompleteWindow = new JCheckBox(""); new CheckBoxWrapper(chkIncludeIncompleteWindow, PrefKey.JSEA_INCLUDE_INCOMPLETE_WINDOW, false); panel.add(chkIncludeIncompleteWindow, "cell 2 3"); } { JLabel lblPvalue = new JLabel("p-value:"); panel.add(lblPvalue, "cell 4 3"); } { HelpTipButton helpTipButton = new HelpTipButton( "The cutoff value to use for statistical significance"); panel.add(helpTipButton, "cell 5 3,alignx trailing"); } { cbxPValue = new JComboBox(); panel.add(cbxPValue, "cell 6 3"); cbxPValue.setModel(new DefaultComboBoxModel(new Double[] { 0.05, 0.01, 0.001 })); } } { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Chart Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel, "cell 0 2,grow"); panel.setLayout(new MigLayout("", "[right][][grow]", "[][]")); { JLabel lblTitleOfChart = new JLabel("Title of chart:"); panel.add(lblTitleOfChart, "cell 0 0,alignx trailing"); } { HelpTipButton helpTipButton = new HelpTipButton( "Title to use on the chart. The placeholder {segment} is replaced with the years of the segment being plotted."); panel.add(helpTipButton, "cell 1 0,alignx trailing"); } { txtChartTitle = new JTextField(); txtChartTitle.setToolTipText("<html>Title to be displayed on the<br/>" + "chart output"); new TextComponentWrapper(txtChartTitle, PrefKey.JSEA_CHART_TITLE, "Chart title {segment}"); panel.add(txtChartTitle, "cell 2 0,growx,aligny top"); txtChartTitle.setColumns(10); } { JLabel lblYaxisLabel = new JLabel("Continuous series (y-axis) label"); panel.add(lblYaxisLabel, "cell 0 1,alignx trailing"); } { txtYAxisLabel = new JTextField(); txtYAxisLabel .setToolTipText("<html>Label to be displayed on the<br/> " + "continuous series axis"); new TextComponentWrapper(txtYAxisLabel, PrefKey.JSEA_YAXIS_LABEL, "Y Axis"); panel.add(txtYAxisLabel, "cell 2 1,growx"); txtYAxisLabel.setColumns(10); } } { // Segmentation implementation used from FHSampleSize segmentationPanel = new SegmentationPanel(); segmentationPanel.chkSegmentation.setText("Process subset or segments of events?"); segmentationPanel.chkSegmentation.setActionCommand("SegmentationMode"); segmentationPanel.chkSegmentation.addActionListener(this); contentPanel.add(segmentationPanel, "cell 0 3,grow"); } { tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); splitPane.setRightComponent(tabbedPane); { summaryPanel = new JPanel(); tabbedPane.addTab("Summary ", Builder.getImageIcon("info.png"), summaryPanel, null); summaryPanel.setLayout(new BorderLayout(0, 0)); { scrollPane = new JScrollPane(); summaryPanel.add(scrollPane); { txtSummary = new JTextArea(); txtSummary.setEditable(false); scrollPane.setViewportView(txtSummary); JMenuItem mntmCopy = new JMenuItem(actionCopy); JPopupMenu popup = new JPopupMenu(); addPopup(scrollPane, popup); popup.add(mntmCopy); } } } { dataPanel = new JPanel(); tabbedPane.addTab("Data ", Builder.getImageIcon("table.png"), dataPanel, null); dataPanel.setLayout(new MigLayout("", "[grow,fill]", "[grow]")); { JSplitPane splitPaneDataTables = new JSplitPane(); splitPaneDataTables.setResizeWeight(0.5); splitPaneDataTables.setOneTouchExpandable(true); splitPaneDataTables.setOrientation(JSplitPane.VERTICAL_SPLIT); dataPanel.add(splitPaneDataTables, "cell 0 0,grow"); { JPanel panel = new JPanel(); splitPaneDataTables.setLeftComponent(panel); panel.setBorder(new TitledBorder(null, "Actual key events", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setLayout(new MigLayout("", "[227.00px,grow,fill]", "[68.00px,grow,fill]")); { JScrollPane scrollPane = new JScrollPane(); panel.add(scrollPane, "cell 0 0,grow"); { tblActual = new JXTable(); adapterActualTable = new JTableSpreadsheetByRowAdapter(tblActual); scrollPane.setViewportView(tblActual); tblActual.setSortable(false); JMenuItem mntmCopy = new JMenuItem(actionCopy); JPopupMenu popup = new JPopupMenu(); addPopup(tblActual, popup); popup.add(mntmCopy); } } } { JPanel panel = new JPanel(); splitPaneDataTables.setRightComponent(panel); panel.setBorder(new TitledBorder(null, "Simulation results", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setLayout(new MigLayout("", "[grow,fill]", "[grow,fill]")); { JScrollPane scrollPane = new JScrollPane(); panel.add(scrollPane, "cell 0 0,grow"); { tblSimulation = new JXTable(); adapterSimulationTable = new JTableSpreadsheetByRowAdapter(tblSimulation); scrollPane.setViewportView(tblSimulation); tblSimulation.setSortable(false); JMenuItem mntmCopy = new JMenuItem(actionCopy); JPopupMenu popup = new JPopupMenu(); addPopup(tblSimulation, popup); popup.add(mntmCopy); } } } splitPaneDataTables.setDividerLocation(0.5f); } } { chartPanel = new JPanel(); tabbedPane.addTab("Chart ", Builder.getImageIcon("barchart.png"), chartPanel, null); chartPanel.setLayout(new MigLayout("", "[][grow]", "[][grow]")); { segmentComboBox = new JComboBox(); segmentComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { if (segmentComboBox.getItemCount() > 0) { barChart = new JSEABarChart( jsea.getChartList().get(segmentComboBox.getSelectedIndex())); barChart.setMaximumDrawHeight(MAX_DRAW_HEIGHT); barChart.setMaximumDrawWidth(MAX_DRAW_WIDTH); chartPanel.removeAll(); chartPanel.add(plotSegmentLabel, "cell 0 0,alignx center,aligny center"); chartPanel.add(segmentComboBox, "cell 1 0,growx,aligny center"); chartPanel.add(barChart, "cell 0 1 2 1,grow"); chartPanel.revalidate(); chartPanel.repaint(); } } }); { plotSegmentLabel = new JLabel("Plot Segment: "); chartPanel.add(plotSegmentLabel, "cell 0 0,alignx center,aligny center"); } chartPanel.add(segmentComboBox, "cell 1 0,growx,aligny center"); } } } } pack(); validateForm(); setAnalysisAvailable(false); setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); }