Java Code Examples for javax.swing.JTextField#setEditable()
The following examples show how to use
javax.swing.JTextField#setEditable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelativePathAccessory.java From RobotBuilder with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void addComponents() { setLayout(new GridLayout(4, 1)); relative = new JRadioButton("Use path relative to the RobotBuilder save file."); relative.setSelected(true); relativePreview = new JTextField("."); relativePreview.setEditable(false); relativePreview.setEnabled(false); relativePreview.setForeground(Color.BLACK); absolute = new JRadioButton("Use absolute path."); absolutePreview = new JTextField(""); absolutePreview.setEditable(false); absolutePreview.setEnabled(false); absolutePreview.setForeground(Color.BLACK); options = new ButtonGroup(); options.add(relative); options.add(absolute); add(relative); add(relativePreview); add(absolute); add(absolutePreview); }
Example 2
Source File: CaretakerController.java From JavaMainRepo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent e) { JTextField textLabel = (JTextField) e.getSource(); if (textLabel== frame.nameTextField) { name = textLabel.getText(); textLabel.setEditable(false); frame.idTextField.requestFocus(); } else if (textLabel == frame.idTextField) { id = textLabel.getText(); textLabel.setEditable(false); frame.salaryTextField.requestFocus(); } else if (textLabel == frame.salaryTextField) { salary = textLabel.getText(); textLabel.setEditable(false); frame.workingHoursTextField.requestFocus(); } else if (textLabel == frame.workingHoursTextField) { workingHours = textLabel.getText(); textLabel.setEditable(false); frame.isDeadYesCheckBox.requestFocus(); } }
Example 3
Source File: CategoryDetailsPane.java From OpERP with MIT License | 6 votes |
public CategoryDetailsPane() { dialog.setTitle("Category Details"); pane = new JPanel(); pane.setLayout(new MigLayout("", "[][grow]", "[][][][]")); JLabel lblCategoryId = new JLabel("Category ID"); pane.add(lblCategoryId, "cell 0 0,alignx trailing"); categoryIdField = new JTextField(); categoryIdField.setEditable(false); pane.add(categoryIdField, "cell 1 0,growx"); categoryIdField.setColumns(30); JLabel lblCategoryName = new JLabel("Category Name"); pane.add(lblCategoryName, "cell 0 1,alignx trailing"); categoryNameField = new JTextField(); categoryNameField.setEditable(false); pane.add(categoryNameField, "cell 1 1,growx"); categoryNameField.setColumns(30); }
Example 4
Source File: FileChooserEditor.java From niftyeditor with Apache License 2.0 | 5 votes |
private JPanel createAccessor(){ JPanel result = new JPanel(); BoxLayout layout = new BoxLayout(result, BoxLayout.Y_AXIS); result.setLayout(layout); absolute = new JRadioButton("Absolute path"); relative = new JRadioButton("Relative to Assets folder"); copy = new JRadioButton("Copy file in Assets folder"); copy.addActionListener(this); JTextField absText = new JTextField(); absText.setEditable(false); JTextField relText = new JTextField(); relText.setEditable(false); copyText = new JTextField(); copyText.setMaximumSize(new Dimension(400, 25)); copyText.setEnabled(false); group = new ButtonGroup(); group.add(copy); group.add(relative); group.add(absolute); absolute.setSelected(true); result.add(new ImagePreview(jFileChooser1)); result.add(absolute); result.add(relative); result.add(copy); result.add(copyText); result.add(new JPanel()); return result; }
Example 5
Source File: HasLockIcon.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates the main frame for <code>this</code> sample. */ public HasLockIcon() { super("Has lock icon"); this.setLayout(new BorderLayout()); final JTextField jtf = new JTextField("sample text"); jtf.setEditable(false); jtf.setColumns(20); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(jtf); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasLockIcon = new JCheckBox("Has lock icon"); hasLockIcon.addActionListener((ActionEvent e) -> SubstanceCortex.ComponentScope .setLockIconVisible(jtf, hasLockIcon.isSelected())); controls.add(hasLockIcon); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 6
Source File: TreePosTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** Create a test field. */ private JTextField createTextField(int width) { JTextField f = new JTextField(width); f.setEditable(false); f.setBorder(null); return f; }
Example 7
Source File: CheckAttributedTree.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** Create a test field. */ private JTextField createTextField(int width) { JTextField f = new JTextField(width); f.setEditable(false); f.setBorder(null); return f; }
Example 8
Source File: ColorSelector.java From gpx-animator with Apache License 2.0 | 5 votes |
/** * Create the panel. */ public ColorSelector() { final ResourceBundle resourceBundle = Preferences.getResourceBundle(); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); colorTextField = new JTextField(); colorTextField.setEditable(false); colorTextField.setMaximumSize(new Dimension(2147483647, 21)); colorTextField.setPreferredSize(new Dimension(55, 21)); add(colorTextField); colorTextField.setColumns(10); final Component rigidArea = Box.createRigidArea(new Dimension(5, 0)); add(rigidArea); selectButton = new JButton(resourceBundle.getString("ui.dialog.color.button.select")); selectButton.addActionListener(e -> { final JColorChooser chooserPane = new JColorChooser(); chooserPane.setColor(colorTextField.getBackground()); final ActionListener okListener = e1 -> setColor(chooserPane.getColor()); final JDialog colorChooser = JColorChooser.createDialog( ColorSelector.this, resourceBundle.getString("ui.dialog.color.title"), true, chooserPane, okListener, null); colorChooser.setVisible(true); }); add(selectButton); }
Example 9
Source File: FileChooserPanel.java From binnavi with Apache License 2.0 | 5 votes |
public FileChooserPanel(final String defaultText, final ActionListener listener, final String buttonText, final int width, final int height, final int buttonWidth) { super(new BorderLayout()); setBorder(new LineBorder(Color.GRAY)); inputField = new JTextField(defaultText); inputField.setEditable(false); if ((width > 0) || (height > 0)) { setPreferredSize(new Dimension(width, height)); } final JPanel p1extBt = new JPanel(new BorderLayout()); browseButton = new JButton(buttonText); browseButton.setBorder(new MatteBorder(0, 1, 0, 0, Color.GRAY)); final Dimension prefSide = browseButton.getPreferredSize(); browseButton.setPreferredSize(new Dimension(prefSide.width + 15, prefSide.height)); if (buttonWidth > 0) { browseButton.setPreferredSize(new Dimension(buttonWidth, height)); } p1extBt.add(browseButton, BorderLayout.CENTER); browseButton.setFocusable(false); add(inputField, BorderLayout.CENTER); add(p1extBt, BorderLayout.EAST); browseButton.addActionListener(listener); ToolTipManager.sharedInstance().registerComponent(inputField); inputField.setToolTipText(getText()); }
Example 10
Source File: CheckAttributedTree.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** Create a test field. */ private JTextField createTextField(int width) { JTextField f = new JTextField(width); f.setEditable(false); f.setBorder(null); return f; }
Example 11
Source File: CheckAttributedTree.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** Create a test field. */ private JTextField createTextField(int width) { JTextField f = new JTextField(width); f.setEditable(false); f.setBorder(null); return f; }
Example 12
Source File: Main.java From blog with Apache License 2.0 | 4 votes |
public void createAndShowUI() { BoundedRangeModel progressModel = new DefaultBoundedRangeModel(); BoundedRangeProgress progressAdapter = new BoundedRangeProgress(progressModel); Document resultDocument = new PlainDocument(); ComponentVisibility progressBarVisibility = new ComponentVisibility("enabled", false); progressBarVisibility.setInvisibleDelay(1, TimeUnit.SECONDS); ProgressCancelAction cancelAction = new ProgressCancelAction(); cancelAction.putValue(Action.NAME, "Cancel"); ProgressSimulationAction progressAction = new ProgressSimulationAction(); progressAction.addProgressAware(progressAdapter); progressAction.addProgressAware(cancelAction); progressAction.addPropertyChangeListener(progressBarVisibility); progressAction.putValue(Action.NAME, "Start"); progressAction.setResultDocument(resultDocument); JFrame mainFrame = new JFrame("Progress Object Pattern with Java Swing"); mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); mainFrame.setMinimumSize(new Dimension(600, 120)); JProgressBar progressBar = new JProgressBar(progressModel); progressBar.setVisible(false); progressBar.setStringPainted(true); progressBarVisibility.setComponent(progressBar); JButton startProgressButton = new JButton(progressAction); JButton cancelButton = new JButton(cancelAction); JTextField resultTextField = new JTextField(40); resultTextField.setEditable(false); resultTextField.setDocument(resultDocument); JPanel mainPanel = new JPanel(); mainPanel.add(startProgressButton); mainPanel.add(cancelButton); mainPanel.add(resultTextField); Container contentPane = mainFrame.getContentPane(); contentPane.add(mainPanel); contentPane.add(progressBar, BorderLayout.SOUTH); mainFrame.pack(); mainFrame.setLocationRelativeTo(null); mainFrame.setVisible(true); }
Example 13
Source File: Main.java From AndroidDrawableFactory with MIT License | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private void initUI() { //create components imageCanvas = new JLabel(); //image to be used imageCanvas.setIcon(new ImageIcon(getClass().getResource("/res/placeholder.png"))); imageCanvas.setBackground(Color.decode("#33B5E5")); imageCanvas.setBorder(BorderFactory.createLineBorder(Color.black)); imageCanvas.setToolTipText("Click to select an Image"); projectPathChooser = new JFileChooser(); //Launch directory selection projectPathField = new JTextField(); //Retains the path selected with JFileChooser projectPathField.setEditable(false); projectPathField.setText("project path"); projectPathButton = new JButton("Browse"); //Button that launch JFileChooser sourceDensityLabel = new JLabel("Source Density"); //Label for the source density field sourceDensityComboBox = new JComboBox<String>(AndroidDrawableFactory.DENSITIES); //selector for the source density sourceSizeLabel = new JLabel("Source Size"); //Label for source image's size sourceSizeTextField = new JTextField(); //Field for source image's size sourceSizeTextField.setEditable(false); densitiesCheckBox = new LinkedHashMap<String, JCheckBox>(); //checkbox Map with densities createButton = new JButton("make"); //button to begin drawable conversion densitiesPanel = new JPanel(); //initialize checkboxes for(int i = 0; i < AndroidDrawableFactory.DENSITIES.length; i++) { String density = AndroidDrawableFactory.DENSITIES[i]; densitiesCheckBox.put(density, new JCheckBox(density)); } for(JCheckBox e : densitiesCheckBox.values()) { e.setSelected(true); densitiesPanel.add(e); } densitiesPanel.add(createButton); //create and set LayoutManager this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS)); mainPanel = new JPanel(); GroupLayout gp = new GroupLayout(mainPanel); gp.setAutoCreateContainerGaps(true); gp.setAutoCreateGaps(true); mainPanel.setLayout(gp); //set alignment criteria GroupLayout.Alignment hAlign = GroupLayout.Alignment.TRAILING; GroupLayout.Alignment vAlign = GroupLayout.Alignment.BASELINE; //add component into layout //set horizontal group gp.setHorizontalGroup(gp.createSequentialGroup() .addGroup(gp.createParallelGroup(hAlign) .addComponent(imageCanvas, 80, 80, 80)) .addGroup(gp.createParallelGroup(hAlign) .addComponent(projectPathField, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE) //.addComponent(projectPathField) .addComponent(sourceDensityLabel, Alignment.LEADING) .addComponent(sourceSizeLabel, Alignment.LEADING)) .addGroup(gp.createParallelGroup(hAlign) .addComponent(projectPathButton) .addComponent(sourceDensityComboBox,GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(sourceSizeTextField,GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 50)) ); //set vertical group gp.setVerticalGroup(gp.createSequentialGroup() .addGroup(gp.createParallelGroup(vAlign) .addComponent(imageCanvas, 80, 80, 80) .addGroup(gp.createSequentialGroup() .addGroup(gp.createParallelGroup(vAlign) .addComponent(projectPathField) .addComponent(projectPathButton)) .addGroup(gp.createParallelGroup(vAlign) .addComponent(sourceDensityLabel) .addComponent(sourceDensityComboBox)) .addGroup(gp.createParallelGroup(vAlign) .addComponent(sourceSizeLabel) .addComponent(sourceSizeTextField))) ) ); this.add(mainPanel); this.add(densitiesPanel); }
Example 14
Source File: ConstantAddPane.java From ApkToolPlus with Apache License 2.0 | 4 votes |
protected void setupComponent() { addButton = new JButton("Add Constant"); dropdown = new JComboBox(); mainText = new JTextField(15); sndText = new JTextField(15); thirdText = new JTextField(15); mainTextLabel = new JLabel(); sndTextLabel = new JLabel(); thirdTextLabel = new JLabel(); buttonLabel = new JLabel(); dropdownLabel = new JLabel("Constant type"); dropdown.addItem("Class"); dropdown.addItem("Method"); dropdown.addItem("Interface Method"); dropdown.addItem("Field reference"); dropdown.addItem("Float"); dropdown.addItem("Double"); dropdown.addItem("Integer"); dropdown.addItem("Long"); dropdown.addItem("String"); dropdown.addItem("Name and type"); dropdown.addItem("utf8"); JPanel dropdownPanel = new JPanel(); dropdownPanel.setLayout(new GridLayout(2, 1)); dropdownPanel.add(dropdownLabel); dropdownPanel.add(dropdown); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(2, 1)); mainPanel.add(mainTextLabel); mainPanel.add(mainText); JPanel sndPanel = new JPanel(); sndPanel.setLayout(new GridLayout(2, 1)); sndPanel.add(sndTextLabel); sndPanel.add(sndText); JPanel thirdPanel = new JPanel(); thirdPanel.setLayout(new GridLayout(2, 1)); thirdPanel.add(thirdTextLabel); thirdPanel.add(thirdText); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(2, 1)); buttonPanel.add(buttonLabel); buttonPanel.add(addButton); mainTextLabel.setText("Class name"); add(dropdownPanel); add(mainPanel); add(sndPanel); add(thirdPanel); add(buttonPanel); sndText.setEditable(false); thirdText.setEditable(false); Border simpleBorder = BorderFactory.createEtchedBorder(); Border border = BorderFactory.createTitledBorder(simpleBorder, "Add constant"); this.setBorder(border); dropdown.addActionListener(this); dropdown.setActionCommand("select"); addButton.addActionListener(this); addButton.setActionCommand("add"); }
Example 15
Source File: CEDefinitionPanel.java From open-ig with GNU Lesser General Public License v3.0 | 4 votes |
/** Initialize the content. */ void initComponents() { JLabel directoryLabel = new JLabel(get("definition.Directory")); directory = new JTextField(); directory.setEditable(false); JButton openDir = new JButton(get("definition.Directory.Open")); JPanel panel2 = new JPanel(); GroupLayout gl = new GroupLayout(panel2); panel2.setLayout(gl); gl.setAutoCreateContainerGaps(true); gl.setAutoCreateGaps(true); gl.setHorizontalGroup( gl.createParallelGroup() .addGroup( gl.createSequentialGroup() .addComponent(directoryLabel) .addComponent(directory) .addComponent(openDir) ) ); gl.setVerticalGroup( gl.createSequentialGroup() .addGroup( gl.createParallelGroup(Alignment.BASELINE) .addComponent(directoryLabel) .addComponent(directory, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(openDir) ) ); tabs = new JTabbedPane(); tabs.addTab(get("definition.Texts"), createTextsPanel()); tabs.addTab(get("definition.References"), createReferencesPanel()); tabs.addTab(get("definition.Properties"), createPropertiesPanel()); setLayout(new BorderLayout()); add(panel2, BorderLayout.PAGE_START); add(tabs, BorderLayout.CENTER); // --------------------------------- openDir.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (Desktop.isDesktopSupported()) { Desktop d = Desktop.getDesktop(); try { d.open(context.dataManager().getDefinitionDirectory().getCanonicalFile()); } catch (IOException e1) { Exceptions.add(e1); } } } }); }
Example 16
Source File: GeneralPreferencesPanel.java From bigtable-sql with Apache License 2.0 | 4 votes |
private JPanel createPathsPanel() { final JPanel pnl = new JPanel(); // i18n[GeneralPreferencesPanel.paths=SQuirreL paths] pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("GeneralPreferencesPanel.paths"))); pnl.setLayout(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(2, 4, 2, 4); gbc.anchor = GridBagConstraints.NORTHWEST; ApplicationFiles appFiles = new ApplicationFiles(); String userDir = appFiles.getUserSettingsDirectory().getPath(); String homeDir = appFiles.getSquirrelHomeDir().getPath(); gbc.gridx = 0; gbc.gridy = 0; // i18n[GeneralPreferencesPanel.squirrelHomePath=Home directory: -home {0}] JTextField homePathField = new JTextField(s_stringMgr.getString("GeneralPreferencesPanel.squirrelHomePath", homeDir)); homePathField.setEditable(false); homePathField.setBackground(pnl.getBackground()); homePathField.setBorder(null); pnl.add(homePathField, gbc); ++gbc.gridy; // i18n[GeneralPreferencesPanel.squirrelUserPath=User directory: -userdir {0}] JTextField userPathField = new JTextField(s_stringMgr.getString("GeneralPreferencesPanel.squirrelUserPath", userDir)); userPathField.setEditable(false); userPathField.setBackground(pnl.getBackground()); userPathField.setBorder(null); pnl.add(userPathField, gbc); gbc.weightx = 1.0; gbc.gridy = 0; ++gbc.gridx; pnl.add(new JPanel(), gbc); ++gbc.gridy; pnl.add(new JPanel(), gbc); return pnl; }
Example 17
Source File: GeneralSettingsPanel.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public GeneralSettingsPanel(final Program program, final SettingsDialog optionsDialog) { super(program, optionsDialog, DialoguesSettings.get().general(), Images.DIALOG_SETTINGS.getIcon()); jEnterFilters = new JCheckBox(DialoguesSettings.get().enterFilter()); jHighlightSelectedRow = new JCheckBox(DialoguesSettings.get().highlightSelectedRow()); jFocusEveOnline = new JCheckBox(DialoguesSettings.get().focusEveOnline()); JLabel jFocusEveOnlineLinuxHelp = new JLabel(DialoguesSettings.get().focusEveOnlineLinuxHelp()); jFocusEveOnlineLinuxHelp.setVisible(Platform.isLinux()); JTextField jFocusEveOnlineLinuxCmd = new JTextField(DialoguesSettings.get().focusEveOnlineLinuxCmd()); jFocusEveOnlineLinuxCmd.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { jFocusEveOnlineLinuxCmd.selectAll(); } }); jFocusEveOnlineLinuxCmd.setEditable(false); jFocusEveOnlineLinuxCmd.setVisible(Platform.isLinux()); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jEnterFilters) .addComponent(jHighlightSelectedRow) .addComponent(jFocusEveOnline) .addGroup(layout.createSequentialGroup() .addGap(30) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jFocusEveOnlineLinuxHelp) .addComponent(jFocusEveOnlineLinuxCmd) ) ) ); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(jEnterFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jHighlightSelectedRow, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFocusEveOnline, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFocusEveOnlineLinuxHelp, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFocusEveOnlineLinuxCmd, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) ); }
Example 18
Source File: AbstractGradientDescentDemo.java From COMP6237 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@SuppressWarnings("deprecation") @Override public Component getComponent(int width, int height) throws IOException { final JPanel base = new JPanel(); base.setOpaque(false); base.setPreferredSize(new Dimension(width, height)); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); chartDataset = new DefaultXYDataset(); X = createData(); chartDataset.addSeries("points", X); final double[][] lineData = computeLineData(); chartDataset.addSeries("line", lineData); chart = ChartFactory.createXYLineChart(null, "x", "y", chartDataset, PlotOrientation.VERTICAL, false, false, false); ((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesLinesVisible(0, false); ((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesShapesVisible(0, true); ((NumberAxis) chart.getXYPlot().getDomainAxis()).setRange(-5, 5); ((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(-10, 10); ((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setStroke(new BasicStroke(2.5f)); chartContainer = new ImageContainer(chart.createBufferedImage(width, height / 2)); base.add(chartContainer); final JPanel bottomPane = new JPanel(); bottomPane.setPreferredSize(new Dimension(width, height / 2)); base.add(bottomPane); final JPanel controlsdata = new JPanel(); controlsdata.setLayout(new BoxLayout(controlsdata, BoxLayout.X_AXIS)); bottomPane.add(controlsdata); final JButton button = new JButton("Go"); controlsdata.add(button); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button.setEnabled(false); base.requestFocus(); new Thread(AbstractGradientDescentDemo.this).start(); } }); paramsField = new JTextField(20); paramsField.setOpaque(false); paramsField.setFont(Font.decode("Monaco-24")); paramsField.setHorizontalAlignment(JTextField.CENTER); paramsField.setEditable(false); paramsField.setBorder(null); paramsField.setText(String.format("%2.2f, %2.2f", params[0], params[1])); controlsdata.add(paramsField); errorDataset = new DefaultXYDataset(); errorSeries = new double[][] { { 0 }, { computeError() } }; errorDataset.addSeries("data", errorSeries); errorChart = ChartFactory.createXYLineChart("Error over time", "Iteration", "Error", errorDataset, PlotOrientation.VERTICAL, false, false, false); ((NumberAxis) errorChart.getXYPlot().getDomainAxis()).setRange(0, 1); ((NumberAxis) errorChart.getXYPlot().getRangeAxis()).setRange(0, computeError()); errorContainer = new ImageContainer(errorChart.createBufferedImage((width - 5) / 2, (height - 5) / 2)); bottomPane.add(errorContainer); return base; }
Example 19
Source File: TypesConfigFrame.java From ontopia with Apache License 2.0 | 4 votes |
private JPanel createIconPanel() { JPanel iconPanel = new JPanel(); iconPanel.setLayout(new BoxLayout(iconPanel, BoxLayout.X_AXIS)); iconPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory .createEtchedBorder(), Messages.getString("Viz.IconBorderTitle"))); iconPanel.add(Box.createHorizontalStrut(10)); iconPanel.add(new JLabel(Messages.getString("Viz.IconFilename"))); iconPanel.add(Box.createHorizontalStrut(10)); filenameField = new JTextField(15); // Stupid ... stupid ... stupid ... This is the only way I would get the components to layout correctly ! filenameField.setMaximumSize(new Dimension((int) (filenameField .getMaximumSize().getWidth()), (int) (filenameField.getPreferredSize() .getHeight()))); filenameField.setEditable(false); iconPanel.add(filenameField); iconPanel.add(Box.createHorizontalStrut(10)); // Must be final to refer to in inner class. final Component thisComponent = this; JButton fileButton = new JButton(Messages.getString("Viz.IconBrowseButton")); fileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String filename = promptForFile(); if (filename != null) { setSelectedIconFilename(filename); setIconFilename(filename); } } catch (java.security.AccessControlException exception) { ErrorDialog.showError(thisComponent, Messages.getString( "Viz.FileBrowseFailure")); } } }); iconPanel.add(fileButton); iconPanel.add(Box.createHorizontalStrut(10)); clearButton = new JButton(Messages.getString("Viz.IconClear")); clearButton.setEnabled(false); clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent anE) { setSelectedIconFilename(null); setIconFilename(null); } }); iconPanel.add(clearButton); return iconPanel; }
Example 20
Source File: CancelOrderDialog.java From btdex with GNU General Public License v3.0 | 4 votes |
public CancelOrderDialog(JFrame owner, Market market, AssetOrder order, ContractState state) { super(owner, ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setTitle(tr("canc_cancel_order")); isToken = market.getTokenID()!=null; this.market = market; this.order = order; this.state = state; conditions = new JTextPane(); conditions.setContentType("text/html"); conditions.setPreferredSize(new Dimension(80, 160)); conditions.setEditable(false); acceptBox = new JCheckBox(tr("dlg_accept_terms")); // Create a button JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT)); pin = new JPasswordField(12); pin.addActionListener(this); calcelButton = new JButton(tr("dlg_cancel")); okButton = new JButton(tr("dlg_ok")); getRootPane().setDefaultButton(okButton); calcelButton.addActionListener(this); okButton.addActionListener(this); if(Globals.getInstance().usingLedger()) { ledgerStatus = new JTextField(26); ledgerStatus.setEditable(false); buttonPane.add(new Desc(tr("ledger_status"), ledgerStatus)); LedgerService.getInstance().setCallBack(this); } else buttonPane.add(new Desc(tr("dlg_pin"), pin)); buttonPane.add(new Desc(" ", calcelButton)); buttonPane.add(new Desc(" ", okButton)); // set action listener on the button JPanel content = (JPanel)getContentPane(); content.setBorder(new EmptyBorder(4, 4, 4, 4)); JPanel conditionsPanel = new JPanel(new BorderLayout()); conditionsPanel.setBorder(BorderFactory.createTitledBorder(tr("dlg_terms_and_conditions"))); conditionsPanel.add(new JScrollPane(conditions), BorderLayout.CENTER); conditionsPanel.add(acceptBox, BorderLayout.PAGE_END); JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.add(conditionsPanel, BorderLayout.PAGE_END); content.add(centerPanel, BorderLayout.CENTER); content.add(buttonPane, BorderLayout.PAGE_END); suggestedFee = Globals.getInstance().getNS().suggestFee().blockingGet(); boolean isBuy = false; if(order!=null && order.getType() == AssetOrder.OrderType.BID) isBuy = true; if(state!=null && state.getType() == ContractType.BUY) isBuy = true; StringBuilder terms = new StringBuilder(); terms.append(PlaceOrderDialog.HTML_STYLE); terms.append("<h3>").append(tr("canc_terms_brief", isBuy ? tr("token_buy") : tr("token_sell"), market, isToken ? order.getId() : state.getAddress().getRawAddress())).append("</h3>"); if(isToken) { terms.append("<p>").append(tr("canc_terms_token", NumberFormatting.BURST.format(suggestedFee.getPriorityFee().longValue()))).append("</p>"); } else { terms.append("<p>").append(tr("canc_terms_contract", state.getBalance().toUnformattedString(), NumberFormatting.BURST.format(state.getActivationFee() + suggestedFee.getPriorityFee().longValue())) ).append("</p>"); } conditions.setText(terms.toString()); conditions.setCaretPosition(0); pack(); }