List of usage examples for javax.swing JLabel setText
@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.") public void setText(String text)
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java
private void setCurPosition() { if (totalLine != 0) { log.debug("setCurPosition selectSnippetNum : " + selectSnippetNum); JLabel jLabelPosition = null; int curPosY = 0; if (totalLine > 0 && getSimilarSnippets().size() > 0) { curPosY = getSimilarSnippets().get(selectSnippetNum).getLeftSnippet().getFirstLine() * getJSplitPaneSourceCode().getHeight() / totalLine; }//from w ww .ja va2s . c o m jLabelPosition = new JLabel(); jLabelPosition.setPreferredSize(new Dimension(15, 15)); jLabelPosition.setLocation(new Point(35, curPosY)); jLabelPosition.setSize(new Dimension(15, 15)); jLabelPosition.setText(""); getJPanMatchedSourceViewLeft().getJPanelNavigator().add(jLabelPosition, null); } }
From source file:com.smanempat.controller.ControllerClassification.java
public void showClassificationResult(JTable tableResult, JTable tablePreview, String[] knnValue, int rowCountData, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan, JYearChooser jYearChooser1, JYearChooser jYearChooser2, int kValue) { DefaultTableModel tableModelResult = new DefaultTableModel(); tableModelResult = (DefaultTableModel) tableResult.getModel(); int jumlahSiswaIPA = 0; int jumlahSiswaIPS = 0; for (int i = 0; i < rowCountData; i++) { if (knnValue[i].equals("IPA")) { jumlahSiswaIPA = jumlahSiswaIPA + 1; } else if (knnValue[i].equalsIgnoreCase("IPS")) { jumlahSiswaIPS = jumlahSiswaIPS + 1; }/*from w w w . j a v a 2 s. c o m*/ String nis = tablePreview.getValueAt(i, 0).toString(); String nama = tablePreview.getValueAt(i, 1).toString(); String jenKel = tablePreview.getValueAt(i, 2).toString(); String nilaiUN = tablePreview.getValueAt(i, 3).toString(); String ptBindo = tablePreview.getValueAt(i, 4).toString(); String ptMtk = tablePreview.getValueAt(i, 5).toString(); String ptBing = tablePreview.getValueAt(i, 6).toString(); String ptIpa = tablePreview.getValueAt(i, 7).toString(); String minat = tablePreview.getValueAt(i, 8).toString(); String jurusan = knnValue[i]; Object[] resultData = { nis, nama, jenKel, nilaiUN, ptBindo, ptMtk, ptBing, ptIpa, minat, jurusan }; tableModelResult.addRow(resultData); } tableResult.setModel(tableModelResult); labelSiswaIPA.setText(jumlahSiswaIPA + ""); labelSiswaIPS.setText(jumlahSiswaIPS + ""); labelKeterangan.setText("Hasil Klasifikasi Penjurusan Siswa Pada Tahun Ajaran " + jYearChooser1.getYear() + "/" + jYearChooser2.getYear() + ", dengan paramater K = " + kValue + " adalah sebagai berikut "); }
From source file:org.eclipse.swt.snippets.Snippet319.java
public void go() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 319"); shell.setBounds(10, 10, 600, 200);/*from www .j a va2s. c om*/ /* Create SWT controls and add drag source */ final Label swtLabel = new Label(shell, SWT.BORDER); swtLabel.setBounds(10, 10, 580, 50); swtLabel.setText("SWT drag source"); DragSource dragSource = new DragSource(swtLabel, DND.DROP_COPY); dragSource.setTransfer(new MyTypeTransfer()); dragSource.addDragListener(new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent event) { MyType object = new MyType(); object.name = "content dragged from SWT"; object.time = System.currentTimeMillis(); event.data = object; } }); /* Create AWT/Swing controls */ Composite embeddedComposite = new Composite(shell, SWT.EMBEDDED); embeddedComposite.setBounds(10, 100, 580, 50); embeddedComposite.setLayout(new FillLayout()); Frame frame = SWT_AWT.new_Frame(embeddedComposite); final JLabel jLabel = new JLabel("AWT/Swing drop target"); frame.add(jLabel); /* Register the custom data flavour */ final DataFlavor flavor = new DataFlavor(MIME_TYPE, "MyType custom flavor"); /* * Note that according to jre/lib/flavormap.properties, the preferred way to * augment the default system flavor map is to specify the AWT.DnD.flavorMapFileURL * property in an awt.properties file. * * This snippet uses the alternate approach below in order to provide a simple * stand-alone snippet that demonstrates the functionality. This implementation * works well, but if the instanceof check below fails for some reason when used * in a different context then the drop will not be accepted. */ FlavorMap map = SystemFlavorMap.getDefaultFlavorMap(); if (map instanceof SystemFlavorMap) { SystemFlavorMap systemMap = (SystemFlavorMap) map; systemMap.addFlavorForUnencodedNative(MIME_TYPE, flavor); } /* add drop target */ DropTargetListener dropTargetListener = new DropTargetAdapter() { @Override public void drop(DropTargetDropEvent dropTargetDropEvent) { try { dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY); ByteArrayInputStream inStream = (ByteArrayInputStream) dropTargetDropEvent.getTransferable() .getTransferData(flavor); int available = inStream.available(); byte[] bytes = new byte[available]; inStream.read(bytes); MyType object = restoreFromByteArray(bytes); String string = object.name + ": " + new Date(object.time).toString(); jLabel.setText(string); } catch (Exception e) { e.printStackTrace(); } } }; new DropTarget(jLabel, dropTargetListener); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
/** * This method is called from within the constructor to initialize the form * components.// ww w . j a v a2 s. c om */ 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:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void chooseServer() { final TwoObjectsX<String, String> serverAndClientId = new TwoObjectsX<String, String>( iliasProperties.getIliasServerURL(), iliasProperties.getIliasClient()); final boolean noConfigDoneYet = serverAndClientId.getObjectA() == null || serverAndClientId.getObjectA().trim().isEmpty(); final JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final JLabel labelServer = new JLabel("Server: " + serverAndClientId.getObjectA()); final JLabel labelClientId = new JLabel("Client Id: " + serverAndClientId.getObjectB()); JComboBox<LoginType> comboboxLoginType = null; JComboBox<DownloadMethod> comboboxDownloadMethod = null; final Runnable findOutClientId = new Runnable() { @Override/*from w w w .j a va 2s.c om*/ public void run() { try { String s = IliasUtil.findClientByLoginPageOrWebserviceURL(serverAndClientId.getObjectA()); serverAndClientId.setObjectB(s); labelClientId.setText("Client Id: " + s); } catch (Exception e1) { showError("Client Id konnte nicht ermittelt werden", e1); } } }; final Runnable promptInputServer = new Runnable() { @Override public void run() { String s = JOptionPane.showInputDialog(panel, "Geben Sie die Ilias Loginseitenadresse oder Webserviceadresse ein", serverAndClientId.getObjectA()); if (s != null) { try { s = IliasUtil.findSOAPWebserviceByLoginPage(s.trim()); if (!s.toLowerCase().startsWith("https://")) { JOptionPane.showMessageDialog(mainFrame, "Achtung! Die von Ihnen angegebene Adresse beginnt nicht mit 'https://'.\nDie Verbindung ist daher nicht ausreichend gesichert. Ein Angreifer knnte Ihre Ilias Daten und Ihr Passwort abgreifen", "Achtung, nicht geschtzt", JOptionPane.WARNING_MESSAGE); } serverAndClientId.setObjectA(s); labelServer.setText("Server: " + serverAndClientId.getObjectA()); if (noConfigDoneYet) { findOutClientId.run(); } } catch (IliasException e1) { showError( "Bitte geben Sie die Adresse der Ilias Loginseite oder die des Webservice an. Die Adresse der Loginseite muss 'login.php' enthalten", e1); } } } }; { JPanel panel2 = new JPanel(new BorderLayout()); panel2.add(labelServer, BorderLayout.NORTH); panel2.add(labelClientId, BorderLayout.SOUTH); panel.add(panel2, BorderLayout.NORTH); } { JPanel panel2 = new JPanel(new BorderLayout()); JPanel panel3 = new JPanel(new GridLayout()); { JButton b = new JButton("Server ndern"); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { promptInputServer.run(); } }); panel3.add(b); b = new JButton("Client Id ndern"); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String s = JOptionPane.showInputDialog(panel, "Client Id eingeben", serverAndClientId.getObjectB()); if (s != null) { serverAndClientId.setObjectB(s); labelClientId.setText("Client Id: " + serverAndClientId.getObjectB()); } } }); panel3.add(b); b = new JButton("Client Id automatisch ermitteln"); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findOutClientId.run(); } }); panel3.add(b); } panel2.add(panel3, BorderLayout.NORTH); panel3 = new JPanel(new GridLayout(0, 2, 5, 2)); { panel3.add(new JLabel("Loginmethode: ")); comboboxLoginType = new JComboBox<LoginType>(); FunctionsX.setComboBoxLayoutString(comboboxLoginType, new ObjectDoInterface<LoginType, String>() { @Override public String doSomething(LoginType loginType) { switch (loginType) { case DEFAULT: return "Standard"; case LDAP: return "LDAP"; case CAS: return "CAS"; default: return "<Fehler>"; } } }); val model = ((DefaultComboBoxModel<LoginType>) comboboxLoginType.getModel()); for (LoginType loginType : LoginType.values()) { model.addElement(loginType); } model.setSelectedItem(iliasProperties.getLoginType()); panel3.add(comboboxLoginType); JLabel label = new JLabel("Dateien herunterladen ber:"); label.setToolTipText("Die restliche Kommunikation luft immer ber den SOAP Webservice"); panel3.add(label); comboboxDownloadMethod = new JComboBox<DownloadMethod>(); FunctionsX.setComboBoxLayoutString(comboboxDownloadMethod, new ObjectDoInterface<DownloadMethod, String>() { @Override public String doSomething(DownloadMethod downloadMethod) { switch (downloadMethod) { case WEBSERVICE: return "SOAP Webservice (Standard)"; case WEBDAV: return "WEBDAV"; default: return "<Fehler>"; } } }); val model2 = ((DefaultComboBoxModel<DownloadMethod>) comboboxDownloadMethod.getModel()); for (DownloadMethod downloadMethod : DownloadMethod.values()) { model2.addElement(downloadMethod); } model2.setSelectedItem(iliasProperties.getDownloadMethod()); panel3.add(comboboxDownloadMethod); } panel2.add(panel3, BorderLayout.WEST); panel.add(panel2, BorderLayout.SOUTH); } if (noConfigDoneYet) { promptInputServer.run(); } if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Server konfigurieren", JOptionPane.OK_CANCEL_OPTION)) { if (syncService != null) { syncService.logoutIfLoggedIn(); } iliasProperties.setIliasServerURL(serverAndClientId.getObjectA()); iliasProperties.setIliasClient(serverAndClientId.getObjectB()); iliasProperties.setLoginType((LoginType) comboboxLoginType.getSelectedItem()); iliasProperties.setDownloadMethod((DownloadMethod) comboboxDownloadMethod.getSelectedItem()); saveProperties(iliasProperties); updateTitleCaption(); } }
From source file:com.awesomecoding.minetestlauncher.Main.java
private void initialize() { fileGetter = new FileGetter(userhome + "\\minetest\\temp\\"); latest = fileGetter.getContents("http://socialmelder.com/minetest/latest.txt", true); currentVersion = latest.split("\n")[0]; changelog = fileGetter.getContents("http://socialmelder.com/minetest/changelog.html", false); try {//from w w w. ja v a 2 s . c om UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } frmMinetestLauncherV = new JFrame(); frmMinetestLauncherV.setResizable(false); frmMinetestLauncherV.setIconImage(Toolkit.getDefaultToolkit() .getImage(Main.class.getResource("/com/awesomecoding/minetestlauncher/icon.png"))); frmMinetestLauncherV.setTitle("Minetest Launcher (Version 0.1)"); frmMinetestLauncherV.setBounds(100, 100, 720, 480); frmMinetestLauncherV.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpringLayout springLayout = new SpringLayout(); frmMinetestLauncherV.getContentPane().setLayout(springLayout); final JProgressBar progressBar = new JProgressBar(); springLayout.putConstraint(SpringLayout.WEST, progressBar, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, progressBar, -10, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, progressBar, -130, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(progressBar); final JButton btnDownloadPlay = new JButton("Play!"); springLayout.putConstraint(SpringLayout.WEST, btnDownloadPlay, 6, SpringLayout.EAST, progressBar); springLayout.putConstraint(SpringLayout.SOUTH, btnDownloadPlay, 0, SpringLayout.SOUTH, progressBar); springLayout.putConstraint(SpringLayout.EAST, btnDownloadPlay, -10, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(btnDownloadPlay); final JLabel label = new JLabel("Ready to play!"); springLayout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, btnDownloadPlay, 0, SpringLayout.NORTH, label); springLayout.putConstraint(SpringLayout.SOUTH, label, -37, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, progressBar, 6, SpringLayout.SOUTH, label); frmMinetestLauncherV.getContentPane().add(label); JTextPane txtpnNewFeatures = new JTextPane(); txtpnNewFeatures.setBackground(SystemColor.window); springLayout.putConstraint(SpringLayout.NORTH, txtpnNewFeatures, 10, SpringLayout.NORTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, txtpnNewFeatures, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, txtpnNewFeatures, -10, SpringLayout.NORTH, btnDownloadPlay); springLayout.putConstraint(SpringLayout.EAST, txtpnNewFeatures, 0, SpringLayout.EAST, btnDownloadPlay); txtpnNewFeatures.setEditable(false); txtpnNewFeatures.setContentType("text/html"); txtpnNewFeatures.setText(changelog); txtpnNewFeatures.setFont(new Font("Tahoma", Font.PLAIN, 12)); frmMinetestLauncherV.getContentPane().add(txtpnNewFeatures); File file = new File(userhome + "\\minetest\\version.txt"); if (!file.exists()) newVersion = true; else { String version = fileGetter.getLocalContents(file, false); if (!version.equals(currentVersion)) newVersion = true; } if (newVersion) { label.setText("New Version Available! (" + currentVersion + ")"); btnDownloadPlay.setText("Download & Play"); btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Thread t = new Thread() { public void run() { File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); try { FileUtils.deleteDirectory(new File(userhome + "\\minetest\\minetest-" + version)); } catch (Exception e) { e.printStackTrace(); } fileGetter.download(latest.split("\n")[1], userhome + "\\minetest\\temp\\", "minetest.zip", label, progressBar, btnDownloadPlay, currentVersion); try { label.setText("Cleaning up..."); btnDownloadPlay.setText("Cleaning up..."); FileUtils.deleteDirectory(new File(userhome + "\\minetest\\temp")); } catch (IOException e) { e.printStackTrace(); } System.exit(0); } }; t.start(); } }); } else { btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { label.setText("Launching..."); btnDownloadPlay.setEnabled(false); btnDownloadPlay.setText("Launching..."); File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); Runtime.getRuntime() .exec(userhome + "\\minetest\\minetest-" + version + "\\bin\\minetest.exe"); System.exit(0); } catch (IOException e) { e.printStackTrace(); } } }); progressBar.setValue(100); } }
From source file:com.declarativa.interprolog.gui.Ini2.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);//w ww . j a v a2 s . c o m mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); }
From source file:org.forester.archaeopteryx.ControlPanel.java
private void buildJSlider(int width, int min, int max) { _color_branches_edpl_slider = new JSlider(min, max); Dimension d = _color_branches_edpl_slider.getSize(); d.width = width;//from w w w . jav a2s . co m d.height = 100; _color_branches_edpl_slider.setPreferredSize(d); // _color_branches_edpl_slider.setLayout(null); // slider popup with cutoff value _slider_popup = new JPopupMenu(); JLabel text = new JLabel(); text.setText(String.valueOf(_edpl_current_cutoff)); _slider_popup.add(text); if (!_configuration.isUseNativeUI()) { _color_branches_edpl_slider.setBackground(ControlPanel.jcb_background_color); _color_branches_edpl_slider.setForeground(ControlPanel.jcb_text_color); } _color_branches_edpl_slider.setToolTipText("Set cutoff for EDPL (0.5-1.0)"); _color_branches_edpl_slider.setMinorTickSpacing(10); _color_branches_edpl_slider.setMajorTickSpacing(50); _color_branches_edpl_slider.setPaintTicks(true); _color_branches_edpl_slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // get Treepanel function final TreePanel tp = getMainPanel().getCurrentTreePanel(); if (tp == null) { return; } Phylogeny phy = tp.getPhylogeny(); _edpl_next_cutoff = ((double) ((JSlider) (e.getSource())).getValue() / 100.0); tp.edplSliderMovement(_edpl_next_cutoff, _edpl_current_cutoff); _edpl_current_cutoff = _edpl_next_cutoff; // System.out.println("Neuer Wert: "+ // ((JSlider)(e.getSource())).getValue()); } }); _color_branches_edpl_slider.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { if (_color_branches_edpl_slider.isEnabled()) { _slider_popup.setVisible(false); } } @Override public void mouseDragged(MouseEvent e) { if (_color_branches_edpl_slider.isEnabled()) { // Point p = getMainPanel().getMainFrame().getLocation(); Point p = _color_branches_edpl_slider.getLocationOnScreen(); JLabel text = (JLabel) _slider_popup.getComponent(0); text.setText(String.valueOf(_edpl_current_cutoff)); int x = (int) p.getX() + 18; int y = (int) p.getY() - 25; _slider_popup.setLocation(x, y); _slider_popup.setVisible(true); } } }); }
From source file:com.declarativa.interprolog.gui.Ini3.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);/* w w w . j ava 2 s . c o m*/ mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo che setta il TreeMap oefos_path con i valori del nodo selezionato * e aggiorna il label che descrive il path dei nodi selezionati * * @param e L'albero sul quale ricercare il path selezionato *///from w w w .jav a 2 s . c o m private void setOEFOS(JTree e, String sequence, String panelname) throws Exception { try { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastSelectedPathComponent(); String completePath = ""; //OefosPaths path = new OefosPaths(panelname, sequence); BookImporter.getInstance() .createComponentMap(BookImporter.getInstance().metadatapanels.get(panelname).getPanel()); Component controls = BookImporter.getInstance().getComponentByName("classification_path---" + sequence); //Se e' una foglia aggiorna il path nell'interfaccia e oefos_path if (node != null) { TreePath selpath = new TreePath(node.getPath()); e.setSelectionPath(selpath); Object[] nodes = selpath.getPath(); TreeMap<Integer, Integer> single_path = new TreeMap<Integer, Integer>(); for (int i = 1; i < nodes.length; i++) { Object nodeInfo = nodes[i]; DefaultMutableTreeNode nodeC = (DefaultMutableTreeNode) nodeInfo; ClassNode c = (ClassNode) nodeC.getUserObject(); single_path.put(i, Integer.parseInt(c.getKey().toString())); completePath += nodes[i].toString(); completePath += (i != nodes.length - 1) ? "/" : ""; } this.oefos_path.put(panelname + "----" + sequence, single_path); } else { this.oefos_path.put(panelname + "----" + sequence, null); } JLabel label = (JLabel) controls; if (completePath.length() > 120) { label.setText(completePath.substring(0, 120)); } else { label.setText(completePath); } label.revalidate(); } catch (Exception ex) { throw new Exception("Exception in setOEFOS: " + ex.getStackTrace() + "\n"); } }