List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java
private void initLayout() { Container content = this.getContentPane(); JComponent controls = Box.createVerticalBox(); {//from ww w . ja v a 2 s . c om JPanel filePanel = new JPanel(new BorderLayout()); { filePanel.setBorder(BorderFactory.createTitledBorder("Stock Market Trading Data")); JPanel dataButtons = new JPanel(new GridLayout(2, 1)); { dataButtons.add(this.loadFileButton); dataButtons.add(this.viewDataButton); } filePanel.add(dataButtons, BorderLayout.EAST); JPanel fileControls = new JPanel(new FlowLayout()); { fileControls.add(new JLabel("Stock data File:")); fileControls.add(this.fileField); fileControls.add(this.fileBrowseButton); fileControls.add(new JLabel(" Stock data format:")); fileControls.add(this.fileFormatCombo); } filePanel.add(fileControls, BorderLayout.CENTER); } controls.add(filePanel); JComponent simPanel = new JPanel(new BorderLayout()); { simPanel.setBorder(BorderFactory.createTitledBorder("Simulation Run")); simPanel.add(this.runButton, BorderLayout.EAST); JComponent simControlsPanel = Box.createVerticalBox(); { JPanel accountControls = new JPanel(new FlowLayout()); { accountControls.add(new JLabel("Initial Cash:")); accountControls.add(this.initialCashField); accountControls.add(new JLabel(" Per Trade Fee:")); accountControls.add(this.perTradeFeeField); accountControls.add(new JLabel(" Per Share Trade Commission:")); accountControls.add(this.perShareTradeCommissionField); accountControls.add(new JLabel(" Compare:")); accountControls.add(this.compareIndexSymbolField); } simControlsPanel.add(accountControls); JPanel runControls = new JPanel(new FlowLayout()); { runControls.add(this.strategyField); runControls.add(new JLabel("Start Date:")); runControls.add(this.startDateField); runControls.add(new JLabel(" End Date:")); runControls.add(this.endDateField); runControls.add(new JLabel(" Strategy:")); runControls.add(this.strategyField); runControls.add(this.editButton); runControls.add(this.compileButton); } simControlsPanel.add(runControls); } simPanel.add(simControlsPanel, BorderLayout.CENTER); } controls.add(simPanel); } content.add(controls, BorderLayout.NORTH); JSplitPane vSplit = this.vSplit; { vSplit.setResizeWeight(0.5); vSplit.add(this.chartPanel, JSplitPane.TOP); JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); { hSplit.setResizeWeight(0.5); // enough for no hscrollbar in 1024 width JSplitPane reportSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); { reportSplit.setResizeWeight(0.5); JScrollPane reportScroll = new JScrollPane(this.reportArea); { reportScroll.setBorder(BorderFactory.createTitledBorder("Report")); } reportSplit.add(reportScroll, JSplitPane.TOP); JScrollPane monthScroll = new JScrollPane(this.monthlyLogArea); { monthScroll.setBorder(BorderFactory.createTitledBorder("Monthly Log")); } reportSplit.add(monthScroll, JSplitPane.BOTTOM); } hSplit.add(reportSplit, JSplitPane.LEFT); JScrollPane tradeScroll = new JScrollPane(this.tradeLogArea); { tradeScroll.setBorder(BorderFactory.createTitledBorder("Trade Log")); } hSplit.add(tradeScroll, JSplitPane.RIGHT); } vSplit.add(hSplit, JSplitPane.BOTTOM); } content.add(vSplit, BorderLayout.CENTER); }
From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java
/** * @param nObj/* w w w . j a va2 s . co m*/ * @param panel * @return true if a form was effectively rendered, i.e. when at least 1 * parameter was available * @throws IllegalActionException */ private boolean renderModelComponent(final boolean deep, final NamedObj nObj, final JPanel panel) { if (logger.isDebugEnabled()) { logger.debug("renderModelComponent() - Entity " + nObj.getFullName()); //$NON-NLS-1$ //$NON-NLS-2$ } if (nObj instanceof CompositeActor && deep) { return renderCompositeModelComponent((CompositeActor) nObj, panel); } else { renderModelComponentAnnotations(nObj, panel); final IPasserelleEditorPaneFactory epf = getEditorPaneFactoryForComponent(nObj); Component component = null; // XXX: temp need to use the new isencia api final IPasserelleQuery passerelleQuery = epf.createEditorPaneWithAuthorizer(nObj, this, this); if (!passerelleQuery.hasAutoSync()) { try { final Set<ParameterToWidgetBinder> queryBindings = passerelleQuery.getParameterBindings(); for (final ParameterToWidgetBinder parameterToWidgetBinder : queryBindings) { hmiFields.put(parameterToWidgetBinder.getBoundParameter().getFullName(), parameterToWidgetBinder); } } catch (final Exception exception) { throw new RuntimeException("Error creating bindings for passerelleQuery", exception); } } final IPasserelleComponent passerelleComponent = passerelleQuery.getPasserelleComponent(); if (!(passerelleComponent instanceof Component)) { return false; } component = (Component) passerelleComponent; // System.out.println("renderModelComponent "+passerelleComponent); // Component c = // EditorPaneFactory.createEditorPaneWithAuthorizer(nObj, this, // this); if (component != null && !(component instanceof PasserelleEmptyQuery)) { final String name = ModelUtils.getFullNameButWithoutModelName(getCurrentModel(), nObj); component.setName(name); final JPanel globalPanel = new JPanel(new BorderLayout()); // Panel for title final JPanel titlePanel = createTitlePanel(name); // Add a nice background to panels titlePanel.setBackground(panel.getBackground()); ((JComponent) component).setBackground(panel.getBackground()); // Border final Border loweredbevel = BorderFactory.createLoweredBevelBorder(); final TitledBorder border = BorderFactory.createTitledBorder(loweredbevel/* ,name */); globalPanel.setBorder(border); globalPanel.add(titlePanel, BorderLayout.NORTH); globalPanel.add(component, BorderLayout.CENTER); panel.add(globalPanel); // StateMachine stuff StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, name, component); StateMachine.getInstance().compile(); return true; } return false; } }
From source file:com.rapidminer.gui.graphs.GraphViewer.java
private JComponent createControlPanel() { // === mouse behaviour === if (graphMouse != null) { vv.setGraphMouse(graphMouse);/*from w w w . j a v a2 s. c o m*/ vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); } transformAction.setEnabled(false); pickingAction.setEnabled(true); vv.addGraphMouseListener(new GraphMouseListener<V>() { @Override public void graphClicked(V vertex, MouseEvent arg1) { } @Override public void graphPressed(V arg0, MouseEvent arg1) { } @Override public void graphReleased(V vertex, MouseEvent arg1) { if (currentMode.equals(ModalGraphMouse.Mode.TRANSFORMING)) { if (graphCreator.getObjectViewer() != null) { vv.getPickedVertexState().clear(); vv.getPickedVertexState().pick(vertex, true); graphCreator.getObjectViewer().showObject(graphCreator.getObject(vertex)); } } } }); JPanel controls = new JPanel(); GridBagLayout gbLayout = new GridBagLayout(); controls.setLayout(gbLayout); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.insets = new Insets(4, 4, 4, 4); c.weightx = 1; c.weighty = 0; // zooming JToolBar zoomBar = new ExtendedJToolBar(); zoomBar.setLayout(new FlowLayout(FlowLayout.CENTER)); zoomBar.add(new ZoomInAction(this, IconSize.SMALL)); zoomBar.add(new ZoomOutAction(this, IconSize.SMALL)); zoomBar.setBorder(BorderFactory.createTitledBorder("Zoom")); c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(zoomBar, c); controls.add(zoomBar); // mode JToolBar modeBar = new ExtendedJToolBar(); modeBar.setLayout(new FlowLayout(FlowLayout.CENTER)); modeBar.add(transformAction); modeBar.add(pickingAction); modeBar.setBorder(BorderFactory.createTitledBorder("Mode")); c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(modeBar, c); controls.add(modeBar); // layout selection c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(layoutSelection, c); controls.add(layoutSelection); // show node labels JCheckBox nodeLabels = new JCheckBox("Node Labels", graphCreator.showVertexLabelsDefault()); nodeLabels.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { togglePaintVertexLabels(); } }); c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(nodeLabels, c); controls.add(nodeLabels); // show edge labels JCheckBox edgeLabels = new JCheckBox("Edge Labels", graphCreator.showEdgeLabelsDefault()); edgeLabels.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { togglePaintEdgeLabels(); } }); c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(edgeLabels, c); controls.add(edgeLabels); // option components for (int i = 0; i < graphCreator.getNumberOfOptionComponents(); i++) { JComponent optionComponent = graphCreator.getOptionComponent(this, i); if (optionComponent != null) { c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(optionComponent, c); controls.add(optionComponent); } } // save image JButton imageButton = new JButton("Save Image..."); imageButton.setToolTipText("Saves an image of the current graph."); imageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final Component tosave = vv; new ExportImageAction(false) { private static final long serialVersionUID = 1L; @Override protected PrintableComponent getPrintableComponent() { return new SimplePrintableComponent(tosave, "Graph"); } }.actionPerformed(e); } }); c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(imageButton, c); controls.add(imageButton); // help JButton help = new JButton("Help"); help.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, INSTRUCTIONS); } }); c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(help, c); controls.add(help); JPanel fillPanel = new JPanel(); c.weighty = 1.0d; c.gridwidth = GridBagConstraints.REMAINDER; gbLayout.setConstraints(fillPanel, c); controls.add(fillPanel); return controls; }
From source file:com.declarativa.interprolog.gui.Ini2BCKP.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from w ww. ja va2s . c o m*/ layout = new TreeLayout<String, Integer>(graph); radialLayout = new BalloonLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Ini2BCKP.Rings(radialLayout); System.out.println("test"); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); Container content = getContentPane(); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); // content.add(controls, BorderLayout.SOUTH); //JFrame frame = new JFrame(); //content = frame.getContentPane(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jLayeredPane1.add(vv); jLayeredPane1.updateUI(); jLayeredPane1.setVisible(true); }
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * Creates a tab pane for the given GridJob. * /*from ww w . j a va 2s .co m*/ * @param jobId JobId */ protected void createJobTab(final String jobId) { // Request Job Profile final InternalClusterJobService jobService = ClusterManager.getInstance().getJobService(); final GridJobProfile profile = jobService.getProfile(jobId); // Job Start Time final long startTime = System.currentTimeMillis(); final JPanel jobPanel = new JPanel(); jobPanel.setLayout(new BorderLayout(10, 10)); // Progess Panel JPanel progressPanel = new JPanel(); progressPanel.setLayout(new BorderLayout(10, 10)); progressPanel.setBorder(BorderFactory.createTitledBorder("Progress")); jobPanel.add(progressPanel, BorderLayout.NORTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressPanel.add(progressBar, BorderLayout.CENTER); addUIElement("jobs." + jobId + ".progress", progressBar); // Add to components map // Buttons Panel JPanel buttonsPanel = new JPanel(); jobPanel.add(buttonsPanel, BorderLayout.SOUTH); buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); // Terminate Button JButton terminateButton = new JButton("Terminate"); terminateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new Thread(new Runnable() { public void run() { // Job Name = Class Name String name = profile.getJob().getClass().getSimpleName(); // Request user confirmation int option = JOptionPane.showConfirmDialog(ClusterMainUI.this, "Are you sure to terminate GridJob " + name + "?", "Nebula - Terminate GridJob", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.NO_OPTION) return; // Attempt Cancel boolean result = profile.getFuture().cancel(); // Notify results if (result) { JOptionPane.showMessageDialog(ClusterMainUI.this, "Grid Job '" + name + "terminated successfully.", "Nebula - Job Terminated", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(ClusterMainUI.this, "Failed to terminate Grid Job '" + name, "Nebula - Job Termination Failed", JOptionPane.WARNING_MESSAGE); } } }).start(); } }); buttonsPanel.add(terminateButton); addUIElement("jobs." + jobId + ".terminate", terminateButton); // Add to components map // Close Tab Button JButton closeButton = new JButton("Close Tab"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { removeJobTab(jobId); } }); } }); closeButton.setEnabled(false); buttonsPanel.add(closeButton); addUIElement("jobs." + jobId + ".closetab", closeButton); // Add to components map JPanel centerPanel = new JPanel(); centerPanel.setLayout(new GridBagLayout()); jobPanel.add(centerPanel, BorderLayout.CENTER); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weightx = 1.0; /* -- Job Information -- */ JPanel jobInfoPanel = new JPanel(); jobInfoPanel.setBorder(BorderFactory.createTitledBorder("Job Information")); jobInfoPanel.setLayout(new GridBagLayout()); c.gridy = 0; c.ipady = 30; centerPanel.add(jobInfoPanel, c); GridBagConstraints c1 = new GridBagConstraints(); c1.fill = GridBagConstraints.BOTH; c1.weightx = 1; c1.weighty = 1; // Name jobInfoPanel.add(new JLabel("Name :"), c1); JLabel jobNameLabel = new JLabel(); jobInfoPanel.add(jobNameLabel, c1); jobNameLabel.setText(profile.getJob().getClass().getSimpleName()); addUIElement("jobs." + jobId + ".job.name", jobNameLabel); // Add to components map // Gap jobInfoPanel.add(new JLabel(), c1); // Type jobInfoPanel.add(new JLabel("Type :"), c1); JLabel jobType = new JLabel(); jobType.setText(getJobType(profile.getJob())); jobInfoPanel.add(jobType, c1); addUIElement("jobs." + jobId + ".job.type", jobType); // Add to components map // Job Class Name c1.gridy = 1; c1.gridwidth = 1; jobInfoPanel.add(new JLabel("GridJob Class :"), c1); c1.gridwidth = GridBagConstraints.REMAINDER; JLabel jobClassLabel = new JLabel(); jobClassLabel.setText(profile.getJob().getClass().getName()); jobInfoPanel.add(jobClassLabel, c1); addUIElement("jobs." + jobId + ".job.class", jobClassLabel); // Add to components map /* -- Execution Information -- */ JPanel executionInfoPanel = new JPanel(); executionInfoPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics")); executionInfoPanel.setLayout(new GridBagLayout()); c.gridy = 1; c.ipady = 30; centerPanel.add(executionInfoPanel, c); GridBagConstraints c3 = new GridBagConstraints(); c3.weightx = 1; c3.weighty = 1; c3.fill = GridBagConstraints.BOTH; // Start Time executionInfoPanel.add(new JLabel("Job Status :"), c3); final JLabel statusLabel = new JLabel("Initializing"); executionInfoPanel.add(statusLabel, c3); addUIElement("jobs." + jobId + ".execution.status", statusLabel); // Add to components map // Status Update Listener profile.getFuture().addGridJobStateListener(new GridJobStateListener() { public void stateChanged(final GridJobState newState) { SwingUtilities.invokeLater(new Runnable() { public void run() { statusLabel.setText(StringUtils.capitalize(newState.toString().toLowerCase())); } }); } }); executionInfoPanel.add(new JLabel(), c3); // Space Holder // Percent Complete executionInfoPanel.add(new JLabel("Completed % :"), c3); final JLabel percentLabel = new JLabel("-N/A-"); executionInfoPanel.add(percentLabel, c3); addUIElement("jobs." + jobId + ".execution.percentage", percentLabel); // Add to components map c3.gridy = 1; // Start Time executionInfoPanel.add(new JLabel("Start Time :"), c3); JLabel startTimeLabel = new JLabel(DateFormat.getInstance().format(new Date(startTime))); executionInfoPanel.add(startTimeLabel, c3); addUIElement("jobs." + jobId + ".execution.starttime", startTimeLabel); // Add to components map executionInfoPanel.add(new JLabel(), c3); // Space Holder // Elapsed Time executionInfoPanel.add(new JLabel("Elapsed Time :"), c3); JLabel elapsedTimeLabel = new JLabel("-N/A-"); executionInfoPanel.add(elapsedTimeLabel, c3); addUIElement("jobs." + jobId + ".execution.elapsedtime", elapsedTimeLabel); // Add to components map c3.gridy = 2; // Tasks Deployed (Count) executionInfoPanel.add(new JLabel("Tasks Deployed :"), c3); JLabel tasksDeployedLabel = new JLabel("-N/A-"); executionInfoPanel.add(tasksDeployedLabel, c3); addUIElement("jobs." + jobId + ".execution.tasks", tasksDeployedLabel); // Add to components map executionInfoPanel.add(new JLabel(), c3); // Space Holder // Results Collected (Count) executionInfoPanel.add(new JLabel("Results Collected :"), c3); JLabel resultsCollectedLabel = new JLabel("-N/A-"); executionInfoPanel.add(resultsCollectedLabel, c3); addUIElement("jobs." + jobId + ".execution.results", resultsCollectedLabel); // Add to components map c3.gridy = 3; // Remaining Tasks (Count) executionInfoPanel.add(new JLabel("Remaining Tasks :"), c3); JLabel remainingTasksLabel = new JLabel("-N/A-"); executionInfoPanel.add(remainingTasksLabel, c3); addUIElement("jobs." + jobId + ".execution.remaining", remainingTasksLabel); // Add to components map executionInfoPanel.add(new JLabel(), c3); // Space Holder // Failed Tasks (Count) executionInfoPanel.add(new JLabel("Failed Tasks :"), c3); JLabel failedTasksLabel = new JLabel("-N/A-"); executionInfoPanel.add(failedTasksLabel, c3); addUIElement("jobs." + jobId + ".execution.failed", failedTasksLabel); // Add to components map /* -- Submitter Information -- */ UUID ownerId = profile.getOwner(); GridNodeDelegate owner = ClusterManager.getInstance().getClusterRegistrationService() .getGridNodeDelegate(ownerId); JPanel ownerInfoPanel = new JPanel(); ownerInfoPanel.setBorder(BorderFactory.createTitledBorder("Owner Information")); ownerInfoPanel.setLayout(new GridBagLayout()); c.gridy = 2; c.ipady = 10; centerPanel.add(ownerInfoPanel, c); GridBagConstraints c2 = new GridBagConstraints(); c2.fill = GridBagConstraints.BOTH; c2.weightx = 1; c2.weighty = 1; // Host Name ownerInfoPanel.add(new JLabel("Host Name :"), c2); JLabel hostNameLabel = new JLabel(owner.getProfile().getName()); ownerInfoPanel.add(hostNameLabel, c2); addUIElement("jobs." + jobId + ".owner.hostname", hostNameLabel); // Add to components map // Gap ownerInfoPanel.add(new JLabel(), c2); // Host IP Address ownerInfoPanel.add(new JLabel("Host IP :"), c2); JLabel hostIPLabel = new JLabel(owner.getProfile().getIpAddress()); ownerInfoPanel.add(hostIPLabel, c2); addUIElement("jobs." + jobId + ".owner.hostip", hostIPLabel); // Add to components map // Owner UUID c2.gridy = 1; c2.gridx = 0; ownerInfoPanel.add(new JLabel("Owner ID :"), c2); JLabel ownerIdLabel = new JLabel(profile.getOwner().toString()); c2.gridx = 1; c2.gridwidth = 4; ownerInfoPanel.add(ownerIdLabel, c2); addUIElement("jobs." + jobId + ".owner.id", ownerIdLabel); // Add to components map SwingUtilities.invokeLater(new Runnable() { public void run() { // Create Tab addUIElement("jobs." + jobId, jobPanel); JTabbedPane tabs = getUIElement("tabs"); tabs.addTab(profile.getJob().getClass().getSimpleName(), jobPanel); tabs.revalidate(); } }); // Execution Information Updater Thread new Thread(new Runnable() { boolean initialized = false; boolean unbounded = false; public void run() { // Unbounded, No Progress Supported if ((!initialized) && profile.getJob() instanceof UnboundedGridJob<?>) { SwingUtilities.invokeLater(new Runnable() { public void run() { progressBar.setIndeterminate(true); progressBar.setStringPainted(false); // Infinity Symbol percentLabel.setText(String.valueOf('\u221e')); } }); initialized = true; unbounded = true; } // Update Job Info while (true) { try { // 500ms Interval Thread.sleep(500); } catch (InterruptedException e) { log.warn("Interrupted Progress Updater Thread", e); } final int totalCount = profile.getTotalTasks(); final int tasksRem = profile.getTaskCount(); final int resCount = profile.getResultCount(); final int failCount = profile.getFailedCount(); showBusyIcon(); // Task Information JLabel totalTaskLabel = getUIElement("jobs." + jobId + ".execution.tasks"); totalTaskLabel.setText(String.valueOf(totalCount)); // Result Count JLabel resCountLabel = getUIElement("jobs." + jobId + ".execution.results"); resCountLabel.setText(String.valueOf(resCount)); // Remaining Task Count JLabel remLabel = getUIElement("jobs." + jobId + ".execution.remaining"); remLabel.setText(String.valueOf(tasksRem)); // Failed Task Count JLabel failedLabel = getUIElement("jobs." + jobId + ".execution.failed"); failedLabel.setText(String.valueOf(failCount)); // Elapsed Time JLabel elapsedLabel = getUIElement("jobs." + jobId + ".execution.elapsedtime"); elapsedLabel.setText(TimeUtils.timeDifference(startTime)); // Job State final JLabel statusLabel = getUIElement("jobs." + jobId + ".execution.status"); // If not in Executing Mode if ((!profile.getFuture().isJobFinished()) && profile.getFuture().getState() != GridJobState.EXECUTING) { SwingUtilities.invokeLater(new Runnable() { public void run() { // Progress Bar progressBar.setIndeterminate(true); progressBar.setStringPainted(false); // Status Text String state = profile.getFuture().getState().toString(); statusLabel.setText(StringUtils.capitalize(state.toLowerCase())); // Percentage Label percentLabel.setText(String.valueOf('\u221e')); } }); } else { // Executing Mode : Progress Information // Job Finished, Stop if (profile.getFuture().isJobFinished()) { showIdleIcon(); return; } // Double check for status label if (!statusLabel.getText().equalsIgnoreCase("executing")) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String newstate = profile.getFuture().getState().toString(); statusLabel.setText(StringUtils.capitalize(newstate.toLowerCase())); } }); } if (!unbounded) { final int percentage = (int) (profile.percentage() * 100); //final int failCount = profile.get SwingUtilities.invokeLater(new Runnable() { public void run() { // If finished at this point, do not update if (progressBar.getValue() == 100) { return; } // If ProgressBar is in indeterminate if (progressBar.isIndeterminate()) { progressBar.setIndeterminate(false); progressBar.setStringPainted(true); } // Update Progress Bar / Percent Label progressBar.setValue(percentage); percentLabel.setText(percentage + " %"); } }); } } } } }).start(); // Job End Hook to Execute Job End Actions ServiceEventsSupport.addServiceHook(new ServiceHookCallback() { public void onServiceEvent(final ServiceMessage event) { SwingUtilities.invokeLater(new Runnable() { public void run() { JButton close = getUIElement("jobs." + jobId + ".closetab"); JButton terminate = getUIElement("jobs." + jobId + ".terminate"); terminate.setEnabled(false); close.setEnabled(true); JProgressBar progress = getUIElement("jobs." + jobId + ".progress"); JLabel percentage = getUIElement("jobs." + jobId + ".execution.percentage"); progress.setEnabled(false); // If Successfully Finished if (event.getType() == ServiceMessageType.JOB_END) { if (profile.getFuture().getState() != GridJobState.FAILED) { // If Not Job Failed progress.setValue(100); percentage.setText("100 %"); } else { // If Failed percentage.setText("N/A"); } // Stop (if) Indeterminate Progress Bar if (progress.isIndeterminate()) { progress.setIndeterminate(false); progress.setStringPainted(true); } } else if (event.getType() == ServiceMessageType.JOB_CANCEL) { if (progress.isIndeterminate()) { progress.setIndeterminate(false); progress.setStringPainted(false); percentage.setText("N/A"); } } showIdleIcon(); } }); } }, jobId, ServiceMessageType.JOB_CANCEL, ServiceMessageType.JOB_END); }
From source file:SuitaDetails.java
private void initComponents(ArrayList<String[]> descriptions) { global = new JPanel(); global.setBackground(Color.WHITE); initGlobal();/*from www . j a va2 s . c o m*/ initTCOptions(); initSummary(); definitions.clear(); border = BorderFactory.createTitledBorder("Global options"); setBorder(border); scroll = new JScrollPane(); // setMinimumSize(new Dimension(10,10)); // setMaximumSize(new Dimension(1000,1000)); // setPreferredSize(new Dimension(100,100)); defsContainer = new JPanel(); setLayout(new BorderLayout()); defsContainer.setBackground(Color.WHITE); defsContainer.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); defsContainer.setLayout(new BoxLayout(defsContainer, BoxLayout.Y_AXIS)); defsContainer.add(suiteoptions); scroll.setViewportView(global); add(scroll, BorderLayout.CENTER); JLabel l = new JLabel("test"); FontMetrics metrics = l.getFontMetrics(l.getFont()); int width = 0; for (int i = 0; i < descriptions.size(); i++) { if (width < metrics.stringWidth(descriptions.get(i)[RunnerRepository.LABEL])) { width = metrics.stringWidth(descriptions.get(i)[RunnerRepository.LABEL]); } } for (int i = 0; i < descriptions.size(); i++) { String button = descriptions.get(i)[RunnerRepository.SELECTED]; DefPanel define = new DefPanel(descriptions.get(i)[RunnerRepository.LABEL], button, descriptions.get(i)[RunnerRepository.ID], width, i, this); definitions.add(define); defsContainer.add(define); } }
From source file:ConfigFiles.java
public JPanel addPanel(String title, String description, final JTextField textfield, String fieldtext, int Y, boolean withbutton, ActionListener actionlistener) { JPanel p1 = new JPanel(); p1.setBackground(Color.WHITE); TitledBorder border = BorderFactory.createTitledBorder(title); border.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p1.setBorder(border);/*ww w .jav a2 s .c o m*/ p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS)); p1.setBounds(80, Y, 800, 75); paths.add(p1); JTextArea tcpath = new JTextArea(description); tcpath.setWrapStyleWord(true); tcpath.setLineWrap(true); tcpath.setEditable(false); tcpath.setCursor(null); tcpath.setOpaque(false); tcpath.setFocusable(false); tcpath.setFont(new Font("Arial", Font.PLAIN, 12)); tcpath.setBackground(getBackground()); tcpath.setMaximumSize(new Dimension(170, 22)); tcpath.setPreferredSize(new Dimension(170, 22)); tcpath.setBorder(null); JPanel p11 = new JPanel(); p11.setBackground(Color.WHITE); p11.setLayout(new GridLayout()); p11.add(tcpath); p11.setMaximumSize(new Dimension(700, 18)); p11.setPreferredSize(new Dimension(700, 18)); textfield.setMaximumSize(new Dimension(340, 27)); textfield.setPreferredSize(new Dimension(340, 27)); textfield.setText(fieldtext); JButton b = null; if (withbutton) { b = new JButton("..."); if (!PermissionValidator.canChangeFWM()) { b.setEnabled(false); } b.setMaximumSize(new Dimension(50, 20)); b.setPreferredSize(new Dimension(50, 20)); if (actionlistener == null) { b.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent ev) { Container c; if (RunnerRepository.container != null) c = RunnerRepository.container.getParent(); else c = RunnerRepository.window; try { new MySftpBrowser(RunnerRepository.host, RunnerRepository.user, RunnerRepository.password, textfield, c, false); } catch (Exception e) { System.out.println("There was a problem in opening sftp browser!"); e.printStackTrace(); } } }); } else { b.addActionListener(actionlistener); b.setText("Save"); b.setMaximumSize(new Dimension(70, 20)); b.setPreferredSize(new Dimension(70, 20)); } } JPanel p12 = new JPanel(); p12.setBackground(Color.WHITE); p12.add(textfield); if (withbutton) p12.add(b); p12.setMaximumSize(new Dimension(700, 32)); p12.setPreferredSize(new Dimension(700, 32)); p1.add(p11); p1.add(p12); return p12; }
From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java
private JPanel createAutoUpdatePanel() { JPanel pnl = new JPanel(new GridBagLayout()); pnl.setBorder(BorderFactory.createTitledBorder(i18n.AUTO_BORDER_LABEL)); final GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); gbc.gridx = 0;/*from w w w. java 2 s.com*/ gbc.gridy = 0; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; pnl.add(_enableAutoUpdateChk, gbc); gbc.gridwidth = 1; gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; gbc.insets = new Insets(4, 20, 4, 10); pnl.add(new JLabel(i18n.AUTO_CHECK_FREQUENCY, JLabel.LEFT), gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 1; gbc.insets = new Insets(4, 0, 4, 0); gbc.fill = GridBagConstraints.NONE; pnl.add(this._updateCheckFrequency, gbc); return pnl; }
From source file:davmail.ui.SettingsFrame.java
protected JPanel getNetworkSettingsPanel() { JPanel networkSettingsPanel = new JPanel(new GridLayout(4, 2)); networkSettingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_NETWORK"))); allowRemoteField = new JCheckBox(); allowRemoteField.setSelected(Settings.getBooleanProperty("davmail.allowRemote")); bindAddressField = new JTextField(Settings.getProperty("davmail.bindAddress"), 15); clientSoTimeoutField = new JTextField(Settings.getProperty("davmail.clientSoTimeout"), 15); certHashField = new JTextField(Settings.getProperty("davmail.server.certificate.hash"), 15); addSettingComponent(networkSettingsPanel, BundleMessage.format("UI_BIND_ADDRESS"), bindAddressField, BundleMessage.format("UI_BIND_ADDRESS_HELP")); addSettingComponent(networkSettingsPanel, BundleMessage.format("UI_CLIENT_SO_TIMEOUT"), clientSoTimeoutField, BundleMessage.format("UI_CLIENT_SO_TIMEOUT_HELP")); addSettingComponent(networkSettingsPanel, BundleMessage.format("UI_ALLOW_REMOTE_CONNECTION"), allowRemoteField, BundleMessage.format("UI_ALLOW_REMOTE_CONNECTION_HELP")); addSettingComponent(networkSettingsPanel, BundleMessage.format("UI_SERVER_CERTIFICATE_HASH"), certHashField, BundleMessage.format("UI_SERVER_CERTIFICATE_HASH_HELP")); updateMaximumSize(networkSettingsPanel); return networkSettingsPanel; }
From source file:Converter.java
ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) { if (MULTICOLORED) { setOpaque(true);/* w w w .j av a2s . co m*/ setBackground(new Color(0, 255, 255)); } setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Save arguments in instance variables. controller = myController; units = myUnits; title = myTitle; sliderModel = myModel; // Create the text field format, and then the text field. numberFormat = NumberFormat.getNumberInstance(); numberFormat.setMaximumFractionDigits(2); NumberFormatter formatter = new NumberFormatter(numberFormat); formatter.setAllowsInvalid(false); formatter.setCommitsOnValidEdit(true);// seems to be a no-op -- // aha -- it changes the value property but doesn't cause the result to // be parsed (that happens on focus loss/return, I think). // textField = new JFormattedTextField(formatter); textField.setColumns(10); textField.setValue(new Double(sliderModel.getDoubleValue())); textField.addPropertyChangeListener(this); // Add the combo box. unitChooser = new JComboBox(); for (int i = 0; i < units.length; i++) { // Populate it. unitChooser.addItem(units[i].description); } unitChooser.setSelectedIndex(0); sliderModel.setMultiplier(units[0].multiplier); unitChooser.addActionListener(this); // Add the slider. slider = new JSlider(sliderModel); sliderModel.addChangeListener(this); // Make the text field/slider group a fixed size // to make stacked ConversionPanels nicely aligned. JPanel unitGroup = new JPanel() { public Dimension getMinimumSize() { return getPreferredSize(); } public Dimension getPreferredSize() { return new Dimension(150, super.getPreferredSize().height); } public Dimension getMaximumSize() { return getPreferredSize(); } }; unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { unitGroup.setOpaque(true); unitGroup.setBackground(new Color(0, 0, 255)); } unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); unitGroup.add(textField); unitGroup.add(slider); // Create a subpanel so the combo box isn't too tall // and is sufficiently wide. JPanel chooserPanel = new JPanel(); chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { chooserPanel.setOpaque(true); chooserPanel.setBackground(new Color(255, 0, 255)); } chooserPanel.add(unitChooser); chooserPanel.add(Box.createHorizontalStrut(100)); // Put everything together. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(unitGroup); add(chooserPanel); unitGroup.setAlignmentY(TOP_ALIGNMENT); chooserPanel.setAlignmentY(TOP_ALIGNMENT); }