/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
public SpinnerModelEditorDemo() { // Group labels JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayout(4, 1)); panel1.add(new JLabel("Date")); panel1.add(new JLabel("Day")); panel1.add(new JLabel("Month")); panel1.add(new JLabel("Year")); // Group spinners JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayout(4, 1)); panel2.add(jspDate); panel2.add(jspDay); panel2.add(jspMonth); panel2.add(spinnerYear); // Add spinner and label to the UI add(panel1, BorderLayout.WEST); add(panel2, BorderLayout.CENTER); // Set editor for date JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(jspDate, "MMM dd, yyyy"); jspDate.setEditor(dateEditor); // Set editor for year JSpinner.NumberEditor yearEditor = new JSpinner.NumberEditor(spinnerYear, "####"); spinnerYear.setEditor(yearEditor); // Update date to synchronize with the day, month, and year updateDate(); // Register and create a listener for jspDay jspDay.addChangeListener( new ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { updateDate(); } }); // Register and create a listener for jspMonth jspMonth.addChangeListener( new ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { updateDate(); } }); // Register and create a listener for spinnerYear spinnerYear.addChangeListener( new ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { updateDate(); } }); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
public void buildPanel() { input.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (input.getText().isEmpty() == false) { outputLabel.setText(""); outputLabel.append(sumNumbers(input.getText())); outputLabel.setEditable(false); } } }); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); JLabel header = new JLabel("Sum of all digits"); JPanel headerFrame = new JPanel(); headerFrame.add(header); mainPanel.add(headerFrame, BorderLayout.NORTH); inputPanel.add(inputLabel); inputPanel.add(input); mainPanel.add(inputPanel, BorderLayout.CENTER); outputPanel.add(outputLabel); mainPanel.add(outputPanel, BorderLayout.SOUTH); topPanel.add(mainPanel); }
/** * Constructor for the RingFoilPosController object * * @param updatingController_in The Parameter */ public RingFoilPosController(UpdatingEventController updatingController_in) { updatingController = updatingController_in; ringFoilPosCorr = new RingFoilPosCorrector("HORIZONTAL Ring Beam Position at Foil"); ringFoilPosCorr.setMessageText(getMessageText()); ringFoilPosMainPanel.setLayout(new BorderLayout()); ringFoilPosMainPanel.add(ringFoilPosCorr.getPanel(), BorderLayout.CENTER); }
public GLDemo() { super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false); DisplayOptions.addChangeListener(this); contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); gradientPanel = createGradientPanel(); contentPane.add(gradientPanel, BorderLayout.CENTER); checkBox = new JCheckBox("Transparent", true); checkBox.setActionCommand("transparancy"); checkBox.addActionListener(this); optionsPan = new JPanel(); optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false)); optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); optionsPan.add(checkBox); runButton = new JToggleButton("Run"); runButton.setActionCommand("run"); runButton.setSelected(false); runButton.addActionListener(this); optionsPan.add(runButton); getContentPane().add(optionsPan, BorderLayout.SOUTH); setSize(300, 300); setLocation(300, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { stop(); } }) .start(); } }); setVisible(false); }
public static JPanel createGradientPanel() { JPanel gradientPanel = new JPanel() { Color c = Util.getBgColor(); public void paintComponent(Graphics g) { ((Graphics2D) g) .setPaint( new GradientPaint(0, 0, c.brighter(), getWidth(), getHeight(), c.darker())); g.fillRect(0, 0, getWidth(), getHeight()); } }; gradientPanel.setLayout(new BorderLayout()); return gradientPanel; }
/** Applet initialization */ public void init() { // Get the port to be used String port_str = getParameter("port"); if (port_str != null) { port = Integer.parseInt(port_str); } // Try to use the system look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } // Create main panel to hold notebook main_panel = new JPanel(); main_panel.setBackground(Color.white); main_panel.setLayout(new BorderLayout()); setContentPane(main_panel); // Create the notebook tabbed_pane = new JTabbedPane(JTabbedPane.TOP); main_panel.add(tabbed_pane, BorderLayout.CENTER); // Add notebook page for default host connection pages = new Vector(); addPage(new SOAPMonitorPage(getCodeBase().getHost())); }
public MonitorGUI(final PhoneCallMonitor pcm, String title) { this.pcm = pcm; text.setFont(new Font("Courier", Font.PLAIN, 12)); text.setText(title); JPanel buttons = new JPanel(); buttons.setLayout(new GridLayout(1, 0)); button = new JButton( new AbstractAction("Pick Up" /*,new JarImageIcon(getClass(),"32x32/play.png")*/) { public void actionPerformed(ActionEvent ev) { button.setEnabled(false); pcm.pickup(); } }); buttons.add(button); setLayout(new BorderLayout()); add(new JScrollPane(text), BorderLayout.CENTER); add(buttons, BorderLayout.SOUTH); }
public void init() { // 添加按钮 JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); mainPanel.setLayout(new GridLayout(0, 3)); mainWin.add(mainPanel, BorderLayout.CENTER); JFormattedTextField intField0 = new JFormattedTextField( new InternationalFormatter(NumberFormat.getIntegerInstance()) { protected DocumentFilter getDocumentFilter() { return new NumberFilter(); } }); intField0.setValue(100); addRow("只接受数字的文本框", intField0); JFormattedTextField intField1 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField1.setValue(new Integer(100)); // 添加输入校验器 intField1.setInputVerifier(new FormattedTextFieldVerifier()); addRow("带输入校验器的文本框", intField1); // 创建自定义格式器对象 IPAddressFormatter ipFormatter = new IPAddressFormatter(); ipFormatter.setOverwriteMode(false); // 以自定义格式器对象创建格式化文本框 JFormattedTextField ipField = new JFormattedTextField(ipFormatter); ipField.setValue(new byte[] {(byte) 192, (byte) 168, 4, 1}); addRow("IP地址格式", ipField); mainWin.add(buttonPanel, BorderLayout.SOUTH); mainWin.pack(); mainWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainWin.setVisible(true); }
/* public void addMiniChart(Plugin p){ components.add(p); rebuild(); } public void removeMiniChart(Plugin p){ components.remove(p); rebuild(); } */ public void rebuild() { // remove everything from main panel mainpanel.removeAll(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; int i = 0; // add chart gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // add all other plugins/components validate(); }
public MainCitiesCriteriaPanel() { super(new BorderLayout()); CountryController countryc = Application.getCountryController(); CitiesController citiesc = Application.getCitiesController(); countryName = Application.getCountryName(); label = new JLabel(); labelPanel = new JPanel(); labelPanel.add(label); label.setText("Criteria to select main cities for " + countryName.replaceAll("_", " ")); listModel = new DefaultListModel(); Iterator<HashMap<String, String>> iter = citiesc.getToponymTypesIterator(); while (iter.hasNext()) { String topTypeName = iter.next().get("code"); listModel.addElement(topTypeName); } list = new JList(listModel); list.addListSelectionListener(this); listPanel = new JScrollPane(list); NumberFormat nCitiesFormat = NumberFormat.getInstance(); nCitiesFormat.setMaximumFractionDigits(0); nCitiesFormat.setMaximumIntegerDigits(4); NumberFormat distFormat = NumberFormat.getInstance(); distFormat.setMaximumFractionDigits(0); distFormat.setMaximumIntegerDigits(3); nCitiesField = new JFormattedTextField(nCitiesFormat); distField = new JFormattedTextField(distFormat); nCitiesField.setMaximumSize(new Dimension(50, 1)); distField.setMaximumSize(new Dimension(50, 1)); rb1 = new JRadioButton("Filter by type", true); rb2 = new JRadioButton("Filter by number", false); rb3 = new JRadioButton("Filter by distance to the borders (km)", false); ButtonGroup bgroup = new ButtonGroup(); bgroup.add(rb1); bgroup.add(rb2); bgroup.add(rb3); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS)); radioPanel.add(rb1); radioPanel.add(listPanel); radioPanel.add(rb2); radioPanel.add(nCitiesField); radioPanel.add(rb3); radioPanel.add(distField); submit = new JButton(); back = new JButton(); submit.setText("OK"); back.setText("GO BACK"); submit.addActionListener(this); back.addActionListener(this); buttonPanel = new JPanel(); buttonPanel.add(back); buttonPanel.add(submit); add(labelPanel, BorderLayout.NORTH); add(radioPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
public LJ3MDApp() { tNum.setHorizontalAlignment(JTextField.CENTER); tTemp.setHorizontalAlignment(JTextField.CENTER); tRho.setHorizontalAlignment(JTextField.CENTER); tSpeed.setHorizontalAlignment(JTextField.CENTER); tAvK.setHorizontalAlignment(JTextField.RIGHT); tAvU.setHorizontalAlignment(JTextField.RIGHT); tAvp.setHorizontalAlignment(JTextField.RIGHT); float[] aveKing = new float[501]; float[] avePot = new float[501]; float[] aveEn = new float[501]; JFrame box = new JFrame(); box.setLayout(new BorderLayout()); box.setSize(1000, 1000); box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cpnl = new JPanel(); // create a panel for controls cpnl.setLayout(new GridLayout(18, 2)); box.add(cpnl, BorderLayout.EAST); // add controls cpnl.add(bStart); bStart.addActionListener(this); cpnl.add(bReset); bReset.addActionListener(this); cpnl.add(new JLabel(" N:")); tNum.addActionListener(this); cpnl.add(tNum); cpnl.add(new JLabel(" Density (\u03c1):")); tRho.addActionListener(this); cpnl.add(tRho); cpnl.add(new JLabel(" Steps/frame:")); tSpeed.addActionListener(this); cpnl.add(tSpeed); cpnl.add(bTstat); bTstat.addActionListener(this); cpnl.add(bPot); bPot.addActionListener(this); cpnl.add(new JLabel(" < K/N > :")); tAvK.setEditable(false); cpnl.add(tAvK); cpnl.add(new JLabel(" Temperature:")); tTemp.setEditable(false); cpnl.add(tTemp); cpnl.add(new JLabel(" < U/N > :")); tAvU.setEditable(false); cpnl.add(tAvU); cpnl.add(new JLabel(" < pressure > :")); tAvp.setEditable(false); cpnl.add(tAvp); cpnl.add(bRetime); bRetime.addActionListener(this); spnl = new JPanel(); // create a panel for status box.add(spnl, BorderLayout.SOUTH); lStatus.setFont(new Font("Courier", 0, 12)); spnl.add(lStatus); canvas = new XYZCanvas(); box.add(canvas, BorderLayout.CENTER); timer = new Timer(delay, this); timer.start(); // timer.stop(); box.setVisible(true); }
static void buildGUI() { // Need this size to balance axes. frame.setSize(520, 690); frame.setTitle("DrawTool"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container cPane = frame.getContentPane(); // Status label on top. Unused for now. statusLabel.setOpaque(true); statusLabel.setBackground(Color.white); cPane.add(statusLabel, BorderLayout.NORTH); // Build the input/output elements at the bottom. JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createLineBorder(Color.black)); panel.setBackground(inputPanelColor); panel.setLayout(new GridLayout(2, 1)); panel.add(outputLabel); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(inputPanelColor); bottomPanel.add(inputField); bottomPanel.add(new JLabel(" ")); JButton enterButton = new JButton("Enter"); enterButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent a) { hasEntered = true; } }); bottomPanel.add(enterButton); panel.add(bottomPanel); if (!sequencingOn) { cPane.add(panel, BorderLayout.SOUTH); } // Drawing in the center. drawArea = new DrawTool(); if (sequencingOn) { frame.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { handleKeyTyped(e); } }); } cPane.add(drawArea, BorderLayout.CENTER); drawArea.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { handleMouseClick(e); } public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); drawArea.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } }); }
public void buildPanel() { /*input.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if(input.getText().isEmpty()==false) { outputLabel.setText(""); outputLabel.append(getFileWords(input.getText())); outputLabel.setEditable(false); } } }); */ JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); JLabel header = new JLabel("File Name (*.dat)"); JPanel headerFrame = new JPanel(); headerFrame.add(header); mainPanel.add(headerFrame, BorderLayout.NORTH); JPanel wrapper = new JPanel(); wrapper.add(inputLabel); wrapper.add(input); inputPanel.add(wrapper); JButton create = new JButton("Write New File"); create.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { int[] numbers = new int[(int) (Math.random() * 10)]; for (int i = 0; i < numbers.length; i++) { numbers[i] = (int) (Math.random() * 100); } if (input.getText().isEmpty() == false) { FileArray.writeArray(input.getText(), numbers); } populateList(); } }); JButton read = new JButton("Read Existing File"); read.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (input.getText().isEmpty() == false) { outputLabel.setText(" "); ArrayList<String> strings = new ArrayList(); String temp = FileArray.readArray(input.getText()); String temp2 = ""; for (int i = 0; i < temp.length(); i++) { temp2 = temp2 + temp.charAt(i); if (i % 50 == 0) { temp2 = temp2 + "\n"; strings.add(temp2); temp2 = ""; } } strings.add(temp2); for (int i = 0; i < strings.size(); i++) { outputLabel.append(strings.get(i)); } } } }); wrapper = new JPanel(); wrapper.add(create); wrapper.add(read); inputPanel.add(wrapper); mainPanel.add(inputPanel, BorderLayout.CENTER); outputPanel.setLayout(new GridLayout(0, 2)); JPanel left = new JPanel(new BorderLayout()); JPanel right = new JPanel(new BorderLayout()); left.add(new JLabel("List of available files"), BorderLayout.NORTH); right.add(new JLabel("Contents"), BorderLayout.NORTH); JScrollPane scrollFileList = new JScrollPane(fileList); left.add(scrollFileList, BorderLayout.CENTER); JScrollPane scroll = new JScrollPane(outputLabel); right.add(scroll, BorderLayout.CENTER); outputPanel.add(left); outputPanel.add(right); mainPanel.add(outputPanel, BorderLayout.SOUTH); topPanel.add(mainPanel); populateList(); }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
public FormatTestFrame() { JPanel buttonPanel = new JPanel(); okButton = new JButton("Ok"); buttonPanel.add(okButton); add(buttonPanel, BorderLayout.SOUTH); mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(0, 3)); add(mainPanel, BorderLayout.CENTER); JFormattedTextField intField = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField.setValue(new Integer(100)); addRow("Number:", intField); JFormattedTextField intField2 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField2.setValue(new Integer(100)); intField2.setFocusLostBehavior(JFormattedTextField.COMMIT); addRow("Number (Commit behavior):", intField2); JFormattedTextField intField3 = new JFormattedTextField( new InternationalFormatter(NumberFormat.getIntegerInstance()) { protected DocumentFilter getDocumentFilter() { return filter; } }); intField3.setValue(new Integer(100)); addRow("Filtered Number", intField3); JFormattedTextField intField4 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField4.setValue(new Integer(100)); intField4.setInputVerifier( new InputVerifier() { public boolean verify(JComponent component) { JFormattedTextField field = (JFormattedTextField) component; return field.isEditValid(); } }); addRow("Verified Number:", intField4); JFormattedTextField currencyField = new JFormattedTextField(NumberFormat.getCurrencyInstance()); currencyField.setValue(new Double(10)); addRow("Currency:", currencyField); JFormattedTextField dateField = new JFormattedTextField(DateFormat.getDateInstance()); dateField.setValue(new Date()); addRow("Date (default):", dateField); DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT); format.setLenient(false); JFormattedTextField dateField2 = new JFormattedTextField(format); dateField2.setValue(new Date()); addRow("Date (short, not lenient):", dateField2); try { DefaultFormatter formatter = new DefaultFormatter(); formatter.setOverwriteMode(false); JFormattedTextField urlField = new JFormattedTextField(formatter); urlField.setValue(new URL("http://java.sun.com")); addRow("URL:", urlField); } catch (MalformedURLException ex) { ex.printStackTrace(); } try { MaskFormatter formatter = new MaskFormatter("###-##-####"); formatter.setPlaceholderCharacter('0'); JFormattedTextField ssnField = new JFormattedTextField(formatter); ssnField.setValue("078-05-1120"); addRow("SSN Mask:", ssnField); } catch (ParseException ex) { ex.printStackTrace(); } JFormattedTextField ipField = new JFormattedTextField(new IPAddressFormatter()); ipField.setValue(new byte[] {(byte) 130, 65, 86, 66}); addRow("IP Address:", ipField); pack(); }
public ChartWindow(String title) { this.symbol = title; thisp = this; // initialize the main layout setTitle(title); mainpanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); // build a toolbar // add a plain status bar this.statusLine = new JLabel("Done"); this.getContentPane().add(statusLine, BorderLayout.SOUTH); statusLine.setBackground(new Color(0, 0, 0)); statusLine.setForeground(new Color(255, 255, 255)); statusLine.setOpaque(true); // x1 = new TimeSeries("symbol", FixedMillisecond.class); dataset1.addSeries(x1); System.out.println("Populated."); // chart = createChart(dataset1); System.out.println("constr."); // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL); chart.setAntiAlias(false); chartPanel = new ChartPanel(chart); // int i = 0; gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // System.out.println("add"); setVisible(true); setSize(new Dimension(400, 300)); // chartPanel.setPopupMenu(buildPopupMenu()); chartPanel.setMouseZoomable(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalZoom(true); chartPanel.setOpaque(true); chartPanel.setBackground(new Color(0, 0, 0)); this.getContentPane().add(mainpanel, BorderLayout.CENTER); this.setSize(600, 400); this.toFront(); this.show(); }
ShutdownFrame(CryoBay cb) { super("CryoBay Monitor"); cryoB = cb; cmdClose = new JButton("Close") { public JToolTip createToolTip() { return new JToolTip(); } }; cmdClose.setToolTipText("Close program"); cmdClose.addActionListener(this); addWindowListener(this); GridBagConstraints gbc = new GridBagConstraints(); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); lblBStatus = new JLabel("Status: "); lblBHeater = new JLabel("Heater: "); lblBTemp = new JLabel(" Temp: "); lblBCli = new JLabel(" CLI: "); lblStatus = new JTextField(17); lblStatus.setEditable(false); lblStatus.setOpaque(true); lblStatus.setBorder(loweredbevel); lblHeater = new JTextField(17); lblHeater.setEditable(false); lblHeater.setOpaque(true); lblHeater.setBorder(loweredbevel); lblTemp = new JTextField(17); lblTemp.setEditable(false); lblTemp.setOpaque(true); lblTemp.setBorder(loweredbevel); lblCli = new JTextField(17); lblCli.setEditable(false); lblCli.setOpaque(true); lblCli.setBorder(loweredbevel); JPanel lblPanel = new JPanel(); lblPanel.setLayout(new GridBagLayout()); gbc.insets = new Insets(2, 5, 2, 5); setGbc(gbc, 0, 0, 1, 1); lblPanel.add(lblBStatus, gbc); setGbc(gbc, 0, 1, 1, 1); lblPanel.add(lblBHeater, gbc); setGbc(gbc, 0, 2, 1, 1); lblPanel.add(lblBTemp, gbc); setGbc(gbc, 0, 3, 1, 1); lblPanel.add(lblBCli, gbc); JPanel valPanel = new JPanel(); valPanel.setLayout(new GridBagLayout()); gbc.insets = new Insets(2, 5, 2, 5); setGbc(gbc, 0, 0, 1, 1); valPanel.add(lblStatus, gbc); setGbc(gbc, 0, 1, 1, 1); valPanel.add(lblHeater, gbc); setGbc(gbc, 0, 2, 1, 1); valPanel.add(lblTemp, gbc); setGbc(gbc, 0, 3, 1, 1); valPanel.add(lblCli, gbc); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); gbc.anchor = GridBagConstraints.CENTER; setGbc(gbc, 0, 5, 1, 1); buttonPanel.add(cmdClose, gbc); // finally, add the panels to the content pane getContentPane().setLayout(new GridBagLayout()); gbc.insets = new Insets(10, 10, 10, 10); gbc.anchor = GridBagConstraints.CENTER; setGbc(gbc, 0, 0, 1, 4); getContentPane().add(lblPanel, gbc); setGbc(gbc, 1, 0, 1, 4); getContentPane().add(valPanel, gbc); setGbc(gbc, 0, 5, 0, 0); getContentPane().add(buttonPanel, gbc); setSize(300, 220); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - 300, screenSize.height / 2 - 220); setResizable(true); }
/** * Creates a new <code>AddPersonDialog</code> with a given owner <code>JFrame</code> and <code> * FamilyTree</code>. */ public AddPersonDialog(JFrame owner, FamilyTree tree) { super(owner, "Add New Person", true /* modal */); Container pane = this.getContentPane(); pane.setLayout(new BorderLayout()); JPanel infoPanel = new JPanel(); infoPanel.setLayout(new GridLayout(0, 2)); Border infoBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5); infoPanel.setBorder(infoBorder); infoPanel.add(new JLabel("id:")); final JTextField idField = new JTextField(); infoPanel.add(idField); final ButtonGroup group = new ButtonGroup(); final JRadioButton male = new JRadioButton("male", true); group.add(male); infoPanel.add(male); final JRadioButton female = new JRadioButton("female"); group.add(female); infoPanel.add(female); infoPanel.add(new JLabel("First name:")); final JTextField firstNameField = new JTextField(); infoPanel.add(firstNameField); infoPanel.add(new JLabel("Middle name:")); final JTextField middleNameField = new JTextField(); infoPanel.add(middleNameField); infoPanel.add(new JLabel("Last name:")); final JTextField lastNameField = new JTextField(); infoPanel.add(lastNameField); infoPanel.add(new JLabel("Date of Birth:")); final JTextField dobField = new JTextField(); infoPanel.add(dobField); infoPanel.add(new JLabel("Date of Death:")); final JTextField dodField = new JTextField(); infoPanel.add(dodField); infoPanel.add(new JLabel("Father:")); JPanel fatherPanel = new JPanel(); fatherPanel.setLayout(new FlowLayout()); final JTextField fatherText = new JTextField("Click to choose"); fatherText.setEditable(false); fatherText.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { // Pop up a PersonChooseDialog, place name in TextField System.out.println("Clicked father"); } }); fatherPanel.add(fatherText); infoPanel.add(fatherPanel); infoPanel.add(new JLabel("Mother:")); JPanel motherPanel = new JPanel(); motherPanel.setLayout(new FlowLayout()); final JTextField motherText = new JTextField("Click to choose"); motherText.setEditable(false); motherText.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { // Pop up a PersonChooseDialog, place name in TextField System.out.println("Clicked mother"); } }); motherPanel.add(motherText); infoPanel.add(motherPanel); pane.add(infoPanel, BorderLayout.NORTH); // "Add" and "Cancel" buttons JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(Box.createHorizontalGlue()); JButton addButton = new JButton("Add"); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Create a new person based on the information entered in // this dialog int id = 0; try { id = Integer.parseInt(idField.getText()); } catch (NumberFormatException ex) { error("Invalid id: " + idField.getText()); return; } String text = null; text = dobField.getText(); Date dob = null; if (text != null && !text.equals("")) { dob = parseDate(dobField.getText()); if (dob == null) { // Parse error return; } } text = dodField.getText(); Date dod = null; if (text != null && !text.equals("")) { dod = parseDate(dodField.getText()); if (dod == null) { // Parse error return; } } Person.Gender gender; if (group.getSelection().equals(male)) { gender = Person.MALE; } else { gender = Person.FEMALE; } // Okay, everything parsed alright newPerson = new Person(id, gender); newPerson.setFirstName(firstNameField.getText()); newPerson.setMiddleName(middleNameField.getText()); newPerson.setLastName(lastNameField.getText()); newPerson.setDateOfBirth(dob); newPerson.setDateOfDeath(dod); if (mother != null) { newPerson.setMother(mother); } if (father != null) { newPerson.setFather(father); } // We're all happy AddPersonDialog.this.dispose(); } }); buttonPanel.add(addButton); buttonPanel.add(Box.createHorizontalGlue()); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Read my lips, no new Person! AddPersonDialog.this.newPerson = null; AddPersonDialog.this.dispose(); } }); buttonPanel.add(cancelButton); buttonPanel.add(Box.createHorizontalGlue()); pane.add(buttonPanel, BorderLayout.SOUTH); }
/////////////////////////////////// // member functions ////////////////////////////////// protected final void initForm() { thisPanel = new JPanel(); thisPanel.setName("Import Range Data"); thisPanel.setLayout(new java.awt.BorderLayout()); _thePanel.add(thisPanel); _theWarning = new JTextArea(); _theWarning.setEditable(false); String theMessage = "Warning, data imported through this panel has"; theMessage += " speed and course calculated as over the ground."; theMessage += System.getProperties().getProperty("line.separator"); theMessage += "Debrief recognises PC Argos (RAO) and PMRF (PRN) files."; theMessage += System.getProperties().getProperty("line.separator"); theMessage += "See Debrief Help File for file format and details."; _theWarning.setText(theMessage); _theWarning.setLineWrap(true); _theWarning.setBorder(BorderFactory.createLoweredBevelBorder()); _theWarning.setWrapStyleWord(true); thisPanel.add("North", _theWarning); //////////////////////////////////////////// // auto generated stuff //////////////////////////////////////////// ButtonPanel = new javax.swing.JPanel(); importBtn = new javax.swing.JButton(); closeBtn = new javax.swing.JButton(); PropertiesList = new javax.swing.JPanel(); FilenamePanel = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); FilenameLabel = new javax.swing.JLabel(); selectFileBtn = new javax.swing.JButton(); FrequencyPanel = new javax.swing.JPanel(); FrequencyLabel = new javax.swing.JLabel(); FrequencyCombo = new TimeFrequencyCombo(); OriginPanel = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); OriginLabel = new javax.swing.JLabel(); selectOriginBtn = new javax.swing.JButton(); DTGPanel = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); _theDate = new javax.swing.JTextField("2001/01/30"); ///////////////////////////////////////////////// // button panel first ////////////////////////////////////////////////// importBtn.setText("Import"); ButtonPanel.add(importBtn); closeBtn.setText("Close"); ButtonPanel.add(closeBtn); thisPanel.add(ButtonPanel, java.awt.BorderLayout.SOUTH); closeBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { doClose(); } }); importBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { doImport(); } }); /////////////////////////////////////////////////// // now the properties panel /////////////////////////////////////////////////// PropertiesList.setLayout(new java.awt.GridLayout(0, 1)); jLabel3.setText("Filename:"); FilenamePanel.add(jLabel3); FilenameLabel.setText(" blank "); FilenamePanel.add(FilenameLabel); selectFileBtn.setPreferredSize(new java.awt.Dimension(33, 27)); selectFileBtn.setToolTipText("Select file"); selectFileBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); selectFileBtn.setText("..."); selectFileBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { doEditFilename(); } }); FilenamePanel.add(selectFileBtn); PropertiesList.add(FilenamePanel); FrequencyLabel.setText("Frequency:"); FrequencyPanel.add(FrequencyLabel); FrequencyCombo.setPreferredSize(new java.awt.Dimension(100, 25)); FrequencyPanel.add(FrequencyCombo); PropertiesList.add(FrequencyPanel); jLabel7.setText("Origin:"); OriginPanel.add(jLabel7); OriginLabel.setText(" blank "); OriginPanel.add(OriginLabel); selectOriginBtn.setPreferredSize(new java.awt.Dimension(33, 27)); selectOriginBtn.setToolTipText("Select file"); selectOriginBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); selectOriginBtn.setText("..."); selectOriginBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { editOrigin(); } }); OriginPanel.add(selectOriginBtn); PropertiesList.add(OriginPanel); ////////////////////////////////////////////////////// // DTG ///////////////////////////////////////////////////// jLabel9.setText("DTG (yyyy/mm/dd):"); _theDate.setText("2001/01/30"); _theDate.addFocusListener( new FocusAdapter() { public void focusLost(final FocusEvent e) { checkDTG(); } }); DTGPanel.add(jLabel9); DTGPanel.add(_theDate); PropertiesList.add(DTGPanel); final JPanel jp = new JPanel(); jp.setLayout(new FlowLayout()); jp.add(PropertiesList); thisPanel.add(jp, java.awt.BorderLayout.CENTER); }