List of usage examples for javax.swing JTextField setText
@BeanProperty(bound = false, description = "the text of this component") public void setText(String t)
TextComponent
to the specified text. From source file:GUI.MainWindow.java
private void EditHostnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditHostnameActionPerformed System.out.println("Edit Hostname Selected"); DefaultMutableTreeNode node = (DefaultMutableTreeNode) this.VulnTree.getLastSelectedPathComponent(); if (node == null) { return;/*from w w w. j a v a 2s. c o m*/ } Object vuln_obj = node.getUserObject(); if (!(vuln_obj instanceof Vulnerability)) { return; } Vulnerability current = (Vulnerability) vuln_obj; int row = this.VulnAffectedHostsTable.getSelectedRow(); row = this.VulnAffectedHostsTable.convertRowIndexToModel(row); Object obj = this.VulnAffectedHostsTable.getModel().getValueAt(row, 0); if (obj instanceof Host) { Host previous = (Host) obj; JTextField hostname = new JTextField(); hostname.setText(previous.getHostname()); Object[] message = { "Hostname:", hostname }; String new_hostname = null; while (new_hostname == null) { int option = JOptionPane.showConfirmDialog(null, message, "Modify Hostname", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { new_hostname = hostname.getText(); Host modified = previous.clone(); // Clone the previous one modified.setHostname(new_hostname); new TreeUtils().modifyHostname((DefaultMutableTreeNode) this.VulnTree.getModel().getRoot(), previous, modified); //current.modifyAffectedHost(previous, modified); // Update the Vulnerability object // Update the affected hosts table DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel(); // Clear the existing table dtm.setRowCount(0); // Set affected hosts into table Enumeration enums = current.getAffectedHosts().elements(); while (enums.hasMoreElements()) { Object obj2 = enums.nextElement(); if (obj instanceof Host) { Host host = (Host) obj2; Vector row2 = host.getAsVector(); // Gets the first two columns from the host dtm.addRow(row2); } } } else { return; // user cancelled or closed the prompt } } } }
From source file:GUI.MainWindow.java
public void addReference(JTree tree, JList list, Reference current) { DefaultMutableTreeNode node = ((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()); if (node == null) { return;//from w w w .java2 s. c om } Object obj = node.getUserObject(); if (!(obj instanceof Vulnerability)) { return; // here be monsters, most likely in the merge tree } Vulnerability vuln = (Vulnerability) obj; DefaultListModel dlm = (DefaultListModel) list.getModel(); // Build Input Field and display it JTextField description = new JTextField(); JTextField url = new JTextField(); // If current is not null then pre-set the description and risk if (current != null) { description.setText(current.getDescription()); url.setText(current.getUrl()); } JLabel error = new JLabel( "A valid URL needs to be supplied including the protocol i.e. http://www.github.com"); error.setForeground(Color.red); Object[] message = { "Description:", description, "URL:", url }; String url_string = null; Reference newref = null; while (url_string == null) { int option = JOptionPane.showConfirmDialog(null, message, "Add Reference", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { System.out.println("User clicked ok, validating data"); String ref_desc = description.getText(); String ref_url = url.getText(); if (!ref_desc.equals("") || !ref_url.equals("")) { // Both have values // Try to validate URL try { URL u = new URL(url.getText()); u.toURI(); url_string = url.getText(); // Causes loop to end with a valid url } catch (MalformedURLException ex) { url_string = null; //ex.printStackTrace(); } catch (URISyntaxException ex) { url_string = null; //ex.printStackTrace(); } } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { System.out.println("User clicked cancel/close"); return; // ends the loop without making any chages } if (url_string == null) { // We need to show an error saying that the url failed to parse Object[] message2 = { error, "Description:", description, "URL:", url }; message = message2; } } // If you get here there is a valid reference URL and description Reference ref = new Reference(description.getText(), url.getText()); if (current == null) { // Add it to the vuln vuln.addReference(ref); // Add it to the GUI dlm.addElement(ref); System.out.println("Valid reference added: " + ref); } else { // Modify it in the vuln vuln.modifyReference(current, ref); // Update the GUI dlm.removeElement(current); dlm.addElement(ref); System.out.println("Valid reference modified: " + ref); } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
/** * Handles mouse dragging events: panning, sliding sections, sliding tracks, * and trackpad based zooming.// w w w. ja va 2s . c o m */ public void mouseDragged(final MouseEvent e) { Point currentPos = e.getPoint(); int dX = currentPos.x - prePos.x; int dY = currentPos.y - prePos.y; float sx, sy; float w, h; canvasLock.lock(); w = SceneGraph.getCanvasWidth(canvasId); h = SceneGraph.getCanvasHeight(canvasId); sx = w / canvas.getWidth(); sy = h / canvas.getHeight(); this.convertMousePointToSceneSpace(currentPos, scenePos); // play a bit measuring test if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) { SceneGraph.positionMouse(scenePos[0], scenePos[1]); // some work for panning // automatically pan mode canvas.setCursor(new Cursor(Cursor.MOVE_CURSOR)); SceneGraph.panScene(-dX * sx, -dY * sy); canvasLock.unlock(); prePos = currentPos; CorelyzerApp.getApp().updateGLWindows(); return; } else if (canvasMode == CorelyzerApp.APP_CLAST_MODE || canvasMode == CorelyzerApp.APP_CUT_MODE) { SceneGraph.positionMouse(scenePos[0], scenePos[1]); // Don't have a selected section, just pan if (selectedTrackSection == -1) { canvas.setCursor(new Cursor(Cursor.MOVE_CURSOR)); SceneGraph.panScene(-dX * sx, -dY * sy); } canvasLock.unlock(); prePos = currentPos; CorelyzerApp.getApp().updateGLWindows(); return; } // check focused marker manipulation if (MANIPULATE_MODE == 1) { float dx, dy; dx = scenePos[0] - prescenePos[0]; dy = scenePos[1] - prescenePos[1]; prescenePos[0] = scenePos[0]; prescenePos[1] = scenePos[1]; SceneGraph.manipulateMarker(canvasId, dx, dy); SceneGraph.positionMouse(scenePos[0], scenePos[1]); canvasLock.unlock(); prePos = currentPos; CorelyzerApp.getApp().updateGLWindows(); return; } else { if (e.isAltDown()) // slide track section { // TODO consider separate move of section image and graph // moveSectionImage & moveSectionGraph if (selectedTrack >= 0 && selectedTrackSection >= 0) { if (canvas.getCursor().getType() != Cursor.HAND_CURSOR) { canvas.setCursor(new Cursor(Cursor.HAND_CURSOR)); } // depth orientation float tX = SceneGraph.getDepthOrientation() ? dX * sx : dY * sy; // allow vertical movements? float tY = 0; // float tY = SceneGraph.getDepthOrientation() ? // (dY * sy) : (-dX * sx); if (selectedGraph >= 0) { // moving graph instead of whole section SceneGraph.moveSectionGraph(selectedTrack, selectedTrackSection, tX, tY); } else { Object[] sections = CorelyzerApp.getApp().getSectionList().getSelectedValues(); int[] secids = new int[sections.length]; for (int i = 0; i < sections.length; i++) { CoreSection cs = (CoreSection) sections[i]; secids[i] = (cs != null ? cs.getId() : -1); } SceneGraph.moveSections(selectedTrack, secids, tX, tY); } // broadcast event to plugins String msg = ""; msg = msg + selectedTrack + "\t" + selectedTrackSection; msg = msg + "\t" + dX * sx / SceneGraph.getCanvasDPIX(canvasId) + "\t0"; CorelyzerApp.getApp().getPluginManager() .broadcastEventToPlugins(CorelyzerPluginEvent.SECTION_MOVED, msg); } } else if (e.isShiftDown()) { // slide track if (selectedTrack >= 0) { if (canvas.getCursor().getType() != Cursor.HAND_CURSOR) { canvas.setCursor(new Cursor(Cursor.HAND_CURSOR)); } // fine tune allows depth movements if (isFineTune() && finetuneDialog != null) { // depth orientation if (SceneGraph.getDepthOrientation()) { // landscape SceneGraph.moveTrack(selectedTrack, dX * sx, dY * sy); } else { // Portrait SceneGraph.moveTrack(selectedTrack, dY * sy, -dX * sx); } float currentTrackPosX = SceneGraph.getTrackXPos(selectedTrack); float canvasDPIX = SceneGraph.getCanvasDPIX(0); JTextField fineTuneCoreADepthStatus = finetuneDialog.getCoreAAdjustedDepthTextField(); JTextField fineTuneCoreBDepthStatus = finetuneDialog.getCoreBAdjustedDepthTextField(); int coreANativeID = finetuneDialog.getCoreANativeID(); int coreBNativeID = finetuneDialog.getCoreBNativeID(); float coreAOrigDepth = finetuneDialog.getCoreAOrigDepth(); float coreBOrigDepth = finetuneDialog.getCoreBOrigDepth(); if (fineTuneCoreADepthStatus != null && coreANativeID == selectedTrack) { float depth = coreAOrigDepth + 2.54f * currentTrackPosX / (100 * canvasDPIX); fineTuneCoreADepthStatus.setText(String.valueOf(depth)); } if (fineTuneCoreBDepthStatus != null && coreBNativeID == selectedTrack) { float depth = coreBOrigDepth + 2.54f * currentTrackPosX / (100 * canvasDPIX); fineTuneCoreBDepthStatus.setText(String.valueOf(depth)); } } else { // normal // depth orientation if (SceneGraph.getDepthOrientation()) { SceneGraph.moveTrack(selectedTrack, 0.0f, dY * sy); } else { SceneGraph.moveTrack(selectedTrack, 0.0f, -dX * sx); } } // broadcast message to plugins String msg = ""; msg = msg + selectedTrack; msg = msg + "\t0\t" + dY * sx / SceneGraph.getCanvasDPIY(canvasId); CorelyzerApp.getApp().getPluginManager() .broadcastEventToPlugins(CorelyzerPluginEvent.TRACK_MOVED, msg); } } else if (e.isControlDown()) // zooming { sy = (float) dY / (float) canvas.getHeight(); SceneGraph.scaleScene(1.0f + sy); } else if (PAN_MODE == 1) { // automatically pan mode canvas.setCursor(new Cursor(Cursor.MOVE_CURSOR)); SceneGraph.panScene(-dX * sx, -dY * sy); } } // end of else (manipulation mode) SceneGraph.positionMouse(scenePos[0], scenePos[1]); canvasLock.unlock(); prePos = currentPos; CorelyzerApp.getApp().updateGLWindows(); }
From source file:Creator.WidgetPanel.java
private void _List_WidgetCodeListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event__List_WidgetCodeListValueChanged // _ScrollPane_WidgetSettings if (!evt.getValueIsAdjusting()) { // Load the variables of the widget String widgetCodeStr;/*from w ww. j ava 2 s . c o m*/ WidgetCode wc = null; WidgetLink wl = null; if (!_JTree_WidgetLinks.isSelectionEmpty()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) _JTree_WidgetLinks .getLastSelectedPathComponent(); if (node == null) //Nothing is selected. { return; } if (node.getParent() != null) { String s = node.getParent().toString() + "-" + node.getUserObject().toString(); if (ws.containsKey(s)) { wl = ws.get(s); wc = widgetList.get(wl.getWidgetCodeName()); } } } if (wc == null) { // No selected item on the JTree widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString(); wc = widgetList.get(widgetCodeStr); } else { // Make sure the item selected matches the code in the widget link // This makes selecting if (!wc.getWidgetName().equals(_List_WidgetCodeList.getSelectedValue().toString())) { widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString(); wc = widgetList.get(widgetCodeStr); } } GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 5; if (widgetCodeSettings == null) { widgetCodeSettings = new HashMap<>(); } else { widgetCodeSettings.clear(); } _Panel_WidgetSettings.removeAll(); _Panel_WidgetSettings.setLayout(gbl); for (String name : wc.getVariables()) { JLabel label = new JLabel(name); label.setFont(new Font("Arial", Font.BOLD, 13)); label.setHorizontalAlignment(SwingConstants.CENTER); JTextField textfield = new JTextField(""); textfield.setHorizontalAlignment(SwingConstants.CENTER); if (wl != null) { textfield.setText(wl.getVariables().get(name)); } textfield.setFont(new Font("Arial", Font.BOLD, 15)); widgetCodeSettings.put(label.getText(), textfield); _Panel_WidgetSettings.add(label, c); c.gridy += 1; _Panel_WidgetSettings.add(textfield, c); c.gridy += 1; } _ScrollPane_WidgetSettings.revalidate(); _ScrollPane_WidgetSettings.repaint(); } }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Hist2DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);// w w w. j av a2 s .c o m listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:org.gwaspi.gui.reports.SampleQAHetzygPlotZoom.java
private void initGUI(final JFreeChart zoomChart, final ChartPanel zoomPanel) throws IOException { // setCursor(CursorUtils.WAIT_CURSOR); final JPanel pnl_ChartNavigator = new JPanel(); final JPanel pnl_Chart = new JPanel(); final JScrollPane scrl_Chart = new JScrollPane(); final JPanel pnl_Footer = new JPanel(); final JPanel pnl_FooterGroup1 = new JPanel(); final JPanel pnl_FooterGroup0 = new JPanel(); final JButton btn_Save = new JButton(); final JButton btn_Reset = new JButton(); final JLabel lbl_thresholds = new JLabel(); final JLabel lbl_hetzy = new JLabel(); final JTextField txt_hetzy = new JTextField(); final JButton btn_redraw = new JButton(); final JLabel lbl_missing = new JLabel(); final JTextField txt_missing = new JTextField(); final String titlePlot = Text.Reports.smplHetzyVsMissingRat; pnl_ChartNavigator.setBorder(GWASpiExplorerPanel.createMainTitledBorder(titlePlot)); // NOI18N pnl_Chart.setBorder(GWASpiExplorerPanel.createLineBorder()); scrl_Chart.getViewport().add(zoomPanel); pnl_Chart.add(scrl_Chart, BorderLayout.CENTER); // <editor-fold defaultstate="expanded" desc="LAYOUT1"> GroupLayout pnl_ChartLayout = new GroupLayout(pnl_Chart); pnl_Chart.setLayout(pnl_ChartLayout); pnl_ChartLayout.setHorizontalGroup(pnl_ChartLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(scrl_Chart, GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); pnl_ChartLayout.setVerticalGroup(pnl_ChartLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(scrl_Chart, GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); GroupLayout pnl_ChartNavigatorLayout = new GroupLayout(pnl_ChartNavigator); pnl_ChartNavigator.setLayout(pnl_ChartNavigatorLayout); pnl_ChartNavigatorLayout.setHorizontalGroup(pnl_ChartNavigatorLayout .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, pnl_ChartNavigatorLayout .createSequentialGroup().addContainerGap().addComponent(pnl_Chart, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); pnl_ChartNavigatorLayout/*from ww w. ja va 2 s . com*/ .setVerticalGroup(pnl_ChartNavigatorLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_ChartNavigatorLayout .createSequentialGroup().addContainerGap().addComponent(pnl_Chart, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); // </editor-fold> lbl_thresholds.setText(Text.Reports.thresholds); lbl_hetzy.setText(Text.Reports.heterozygosity); txt_hetzy.setText(hetzyThreshold.toString()); lbl_missing.setText(Text.Reports.missRatio); txt_missing.setText(missingThreshold.toString()); btn_redraw.setAction(new RedrawAction(txt_hetzy, txt_missing)); final MatrixMetadata rdMatrixMetadata = getMatrixService().getMatrix(operationKey.getParentMatrixKey()); final String originFriendlyName = rdMatrixMetadata.getFriendlyName(); btn_Save.setAction(new SaveAsAction( "SampleQA_hetzyg-missingrat_" + Utils.stripNonAlphaNumeric(originFriendlyName) + ".png", scrl_Chart, zoomChart, this)); btn_Reset.setAction(new ResetAction()); //<editor-fold defaultstate="expanded" desc="FOOTER"> GroupLayout pnl_FooterGroup0Layout = new GroupLayout(pnl_FooterGroup0); pnl_FooterGroup0.setLayout(pnl_FooterGroup0Layout); pnl_FooterGroup0Layout.setHorizontalGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup0Layout.createSequentialGroup().addContainerGap() .addGroup(pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup0Layout.createSequentialGroup() .addGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(lbl_hetzy).addComponent(lbl_missing)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(txt_hetzy, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) .addGroup(pnl_FooterGroup0Layout.createSequentialGroup() .addComponent(txt_missing, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) .addGap(6, 6, 6).addComponent(btn_redraw, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))) .addComponent(lbl_thresholds)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pnl_FooterGroup0Layout.setVerticalGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterGroup0Layout.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(lbl_thresholds) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lbl_hetzy).addComponent(txt_hetzy, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(btn_redraw, GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lbl_missing).addComponent(txt_missing))))); GroupLayout pnl_FooterGroup1Layout = new GroupLayout(pnl_FooterGroup1); pnl_FooterGroup1.setLayout(pnl_FooterGroup1Layout); pnl_FooterGroup1Layout .setHorizontalGroup(pnl_FooterGroup1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup1Layout.createSequentialGroup().addContainerGap() .addComponent(btn_Reset, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pnl_FooterGroup1Layout.linkSize(SwingConstants.HORIZONTAL, new Component[] { btn_Reset, btn_Save }); pnl_FooterGroup1Layout .setVerticalGroup(pnl_FooterGroup1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup1Layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(btn_Reset).addComponent(btn_Save))); pnl_FooterGroup1Layout.linkSize(SwingConstants.VERTICAL, new Component[] { btn_Reset, btn_Save }); GroupLayout pnl_FooterLayout = new GroupLayout(pnl_Footer); pnl_Footer.setLayout(pnl_FooterLayout); pnl_FooterLayout .setHorizontalGroup(pnl_FooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterLayout.createSequentialGroup() .addComponent(pnl_FooterGroup0, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 174, Short.MAX_VALUE) .addComponent(pnl_FooterGroup1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); pnl_FooterLayout.setVerticalGroup(pnl_FooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterLayout.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(pnl_FooterLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(pnl_FooterGroup0, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(pnl_FooterGroup1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); //</editor-fold> //<editor-fold defaultstate="expanded" desc="LAYOUT"> GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(pnl_ChartNavigator, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnl_Footer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout.createSequentialGroup() .addComponent(pnl_ChartNavigator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(pnl_Footer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); //</editor-fold> // setCursor(CursorUtils.DEFAULT_CURSOR); }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Plot1DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);/*from w ww . j a v a2s.com*/ listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:br.com.bgslibrary.gui.MainFrame.java
private void reloadParam(String pname, javax.swing.JTextField textField, String filePath) { String p = getParam(pname, filePath); textField.setText(p); }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void openUIOptionsDialog() { JPanel options = new JPanel(new GridLayout(0, 1)); options.setName("User Interface"); // Button size ActionListener buttonSizeRadioListener = new ActionListener() { @Override/*from w ww . j a v a2s . co m*/ public void actionPerformed(ActionEvent e) { prefs.setButtonSize(e.getActionCommand()); } }; JRadioButton small = new JRadioButton("Small"); small.setActionCommand(BUTTON_SIZE_SMALL); small.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_SMALL.equals(prefs.getButtonSize())) small.setSelected(true); JRadioButton medium = new JRadioButton("Medium"); medium.setActionCommand(BUTTON_SIZE_MEDIUM); medium.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_MEDIUM.equals(prefs.getButtonSize())) medium.setSelected(true); JRadioButton large = new JRadioButton("Large"); large.setActionCommand(BUTTON_SIZE_LARGE); large.addActionListener(buttonSizeRadioListener); if (BUTTON_SIZE_LARGE.equals(prefs.getButtonSize())) large.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(small); group.add(medium); group.add(large); // Close windows on stop final JCheckBox closeAllWindowsOnStopCheckBox = new JCheckBox("Close all windows on Stop"); closeAllWindowsOnStopCheckBox.setSelected(prefs.isCloseAllWindowsOnStop()); // Refresh interval JPanel refreshIntervalPanel = new JPanel(); final JTextField refreshIntervalField = new JTextField(5); refreshIntervalPanel.add(new JLabel("Refresh interval for cpu, screen, etc. (ms):")); refreshIntervalField.setText("" + prefs.getRefreshIntervalMs()); refreshIntervalPanel.add(refreshIntervalField); // Setup panel options.add(new JLabel("Button size :")); options.add(small); options.add(medium); options.add(large); options.add(closeAllWindowsOnStopCheckBox); options.add(refreshIntervalPanel); options.add(new JLabel("Larger value greatly increases emulation speed")); if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, options, "Preferences", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) { // save prefs.setButtonSize(group.getSelection().getActionCommand()); prefs.setCloseAllWindowsOnStop(closeAllWindowsOnStopCheckBox.isSelected()); int refreshIntervalMs = 0; try { refreshIntervalMs = Integer.parseInt(refreshIntervalField.getText()); } catch (NumberFormatException e) { // noop } refreshIntervalMs = Math.max(Math.min(refreshIntervalMs, 10000), 10); prefs.setRefreshIntervalMs(refreshIntervalMs); applyPrefsToUI(); } }
From source file:DecimalFormatDemo.java
public DecimalFormatDemo() { availableLocales = new LocaleGroup(); inputFormatter = NumberFormat.getNumberInstance(); String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000", "'hello'###.##" }; currentPattern = patternExamples[0]; // Set up the UI for entering a number. JLabel numberLabel = new JLabel("Enter the number to format:"); numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JTextField numberField = new JTextField(); numberField.setEditable(true);/*from w w w . ja v a2 s . co m*/ numberField.setAlignmentX(Component.LEFT_ALIGNMENT); NumberListener numberListener = new NumberListener(); numberField.addActionListener(numberListener); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox patternList = new JComboBox(patternExamples); patternList.setSelectedIndex(0); patternList.setEditable(true); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); PatternListener patternListener = new PatternListener(); patternList.addActionListener(patternListener); // Set up the UI for selecting a locale. JLabel localeLabel = new JLabel("Select a Locale from the list:"); localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox localeList = new JComboBox(availableLocales.getStrings()); localeList.setSelectedIndex(0); localeList.setAlignmentX(Component.LEFT_ALIGNMENT); LocaleListener localeListener = new LocaleListener(); localeList.addActionListener(localeListener); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Result", JLabel.LEFT); resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT); result = new JLabel(" "); result.setForeground(Color.black); result.setAlignmentX(Component.LEFT_ALIGNMENT); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything JPanel numberPanel = new JPanel(); numberPanel.setLayout(new GridLayout(0, 1)); numberPanel.add(numberLabel); numberPanel.add(numberField); JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternPanel.add(patternList); JPanel localePanel = new JPanel(); localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS)); localePanel.add(localeLabel); localePanel.add(localeList); JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT); numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT); localePanel.setAlignmentX(Component.CENTER_ALIGNMENT); resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT); add(numberPanel); add(Box.createVerticalStrut(10)); add(patternPanel); add(Box.createVerticalStrut(10)); add(localePanel); add(Box.createVerticalStrut(10)); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); numberField.setText(result.getText()); }