AdminMain() { l = new JLabel(); l.setBounds(10, 20, 1340, 1000); l.setBackground(Color.black); Font ft = new Font("Arial", Font.BOLD, 30); Font ft1 = new Font("Arial", Font.BOLD, 14); Font ft2 = new Font("Arial", Font.BOLD, 20); f1 = new Frame("Soft Test Management (Beta)"); f1.setLayout(null); l1 = new Label("Test Instructions", l1.CENTER); l1.setBounds(10, 20, 1300, 60); l1.setForeground(Color.blue); l1.setBackground(Color.white); l1.setFont(ft); l2 = new JLabel("Deletion of Faculty/Students"); l2.setBounds(20, 30, 1000, 500); l2.setBackground(Color.blue); l2.setFont(ft2); l3 = new JLabel("Test Pattern"); l3.setBounds(20, 90, 1300, 500); l3.setBackground(Color.green); l3.setFont(ft2); b1 = new JButton("Go !"); b1.setBounds(300, 220, 120, 30); b1.setBackground(Color.white); b1.setForeground(Color.blue); b1.setFont(ft2); b2 = new JButton("Go"); b2.setBounds(300, 240, 120, 30); b2.setBackground(Color.white); b2.setForeground(Color.blue); b2.setFont(ft2); f1.add(l); l.add(l1); l2.add(b1); l.add(l2); l3.add(b2); l.add(l3); b1.addActionListener(this); b2.addActionListener(this); f1.setVisible(true); f1.setSize(1800, 800); }
/** * Constructor that takes model as a parameter * * @param model */ public BoardFrame(Model model) { this.model = model; data = model.getData(); gameOver = false; initScreen(); setLayout(new BorderLayout()); setLocation(300, 200); // undoBtn is a controller that resets the turn and last state of board undoBtn = new JButton("Undo : " + this.model.getUndoCounter()); undoBtn.setPreferredSize(new Dimension(80, 50)); undoBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (BoardFrame.this.model.getUndoCounter() != 0) { BoardFrame.this.model.undo(); undoBtn.setText("Undo : " + BoardFrame.this.model.getUndoCounter()); } else ; } }); JPanel undoPanel = new JPanel(); undoPanel.add(undoBtn); // end of undoBtn code add(boardPanel, BorderLayout.CENTER); add(undoPanel, BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setResizable(false); setVisible(true); }
/** Initializes the call button. */ private void initCallButton() { List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders(); if (telephonyProviders != null && telephonyProviders.size() > 0) { if (callButton.getParent() != null) return; callButton.setAlignmentX(JButton.CENTER_ALIGNMENT); callButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT")); buttonPanel.add(callButton); callButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; CallManager.createCall(searchText, callButton); } }); } else { buttonPanel.remove(callButton); } }
public void evaluate() { try { // clear problems and console messages problemsView.setText(""); consoleView.setText(""); // update status view statusView.setText(" Parsing ..."); tabbedPane.setSelectedIndex(0); LispExpr root = Parser.parse(textView.getText()); statusView.setText(" Running ..."); tabbedPane.setSelectedIndex(1); // update run button runButton.setIcon(stopImage); runButton.setActionCommand("Stop"); // start run thread runThread = new RunThread(root); runThread.start(); } catch (SyntaxError e) { tabbedPane.setSelectedIndex(0); System.err.println( "Syntax Error at " + e.getLine() + ", " + e.getColumn() + " : " + e.getMessage()); } catch (Error e) { // parsing error System.err.println(e.getMessage()); statusView.setText(" Errors."); } }
/** * Creates the button panel with the query and reset buttons in a box layout. * * @return The constructed button panel. */ public JPanel createButtonPane() { // Set up the panel. buttonPane = new JPanel(); queryBtn = new JButton("Query"); // Create and add action listener to query and reset buttons. queryBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { parentCS.requestQuery(2, catCb1.getSelectedIndex(), catCb2.getSelectedIndex()); } }); resetBtn = new JButton("Reset"); resetBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { parentCS.switchContext(-1); } }); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); // Add buttons to panel. buttonPane.add(queryBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(resetBtn); return buttonPane; }
void setData(boolean equal, Trace newTrace, Trace oldTrace) { boolean equalComments = newTrace.getComment().equals(oldTrace.getComment()); if (equal) { if (equalComments) { messageLabel.setText("Passed"); saveButton.setEnabled(false); replaceButton.setEnabled(false); } else { messageLabel.setText("Passed, but comments differ"); } } else { messageLabel.setText("Discrepency found"); } if (equalComments) { addText(newTrace.getComment(), "regular", commentPane); } else { System.out.println("Old Comment: " + oldTrace.getComment()); System.out.println("New Comment: " + newTrace.getComment()); Object[] v = stringToArray(oldTrace.getComment()); Object[] h = stringToArray(newTrace.getComment()); displayDifferencesToPane(v, h, commentPane); } if (equal) { copyTraceToPane(newTrace); } else { Object[] v = traceToArray(oldTrace); Object[] h = traceToArray(newTrace); displayDifferencesToPane(v, h, jTextPane); } }
/** Returns the tool bar for the panel. */ protected JComponent getToolBar() { JToolBar tbarDir = new JToolBar(); JButton btnNew = new JButton(); // m_btnSave = new JButton("Save File"); // i118n // btnNew.setText("New Label"); btnNew.setText(Util.getAdmLabel("_adm_New_Label")); btnNew.setActionCommand("new"); // m_btnSave.setActionCommand("save"); ActionListener alTool = new ActionListener() { public void actionPerformed(ActionEvent e) { doAction(e); } }; btnNew.addActionListener(alTool); // m_btnSave.addActionListener(alTool); tbarDir.setFloatable(false); tbarDir.add(btnNew); /*tbarDir.add(new JLabel(" ")); tbarDir.add(m_btnSave);*/ return tbarDir; }
private void multiConnect() { if (jButtonMultiConnect.getText().equals("Multi-Connect")) { String res = JOptionPane.showInputDialog(this, "Enter number of connections", "Multi-Connect"); if (res != null) { jButtonMultiConnect.setText("Multi-Disconnect"); jMenuItemTestMulticonnect.setEnabled(false); jMenuItemTestMultidisconnect.setEnabled(true); int count = Integer.parseInt(res); MultiSessions = new Session[count]; for (int i = 0; i < count; i++) { MultiSessions[i] = new Session(); try { MultiSessions[i].connect( this.jTextFieldServer.getText(), this.jTextFieldUser.getText() + String.valueOf(i)); } catch (ConnectionException ex1) { } } } } else { for (int i = 0; i < MultiSessions.length; i++) { try { ((Session) MultiSessions[i]).disconnect(); } catch (Exception ex) { System.out.println("Error disconnectiong from session"); } } jButtonMultiConnect.setText("Multi-Connect"); jMenuItemTestMulticonnect.setEnabled(true); jMenuItemTestMultidisconnect.setEnabled(false); } }
private void initComponents() { // Message - JLabel lblMessage = new JLabel( String.format( "An unexpected error has occurred: %s", e == null ? "Unexpected exception" : e.getMessage())); lblMessage.setIcon(icon); lblMessage.setPreferredSize(new Dimension(360, 40)); lblMessage.setBorder(BorderFactory.createLineBorder(Color.red)); // txtTrace - ExceptionTracePane txtTrace = new ExceptionTracePane(); txtTrace.setBackground(new Color(92, 0, 0)); txtTrace.setException(e); // srlTrace - JScrollPane JPanel traceWrapper = new JPanel(new BorderLayout()); traceWrapper.add(txtTrace, BorderLayout.CENTER); srlTrace = new JScrollPane(traceWrapper); srlTrace.setPreferredSize(new Dimension(360, 200)); srlTrace.setVisible(false); // btnDetails - JButton btnDetails = new JButton(new DetailsButtonAction()); btnDetails.setPreferredSize(new Dimension(100, 40)); // btnClose - JButton btnClose = new JButton(new CloseButtonAction()); btnClose.setDefaultCapable(true); btnClose.setPreferredSize(new Dimension(100, 40)); }
/** Reloads button resources. */ public void loadSkin() { addButton.setIcon( GuiActivator.getResources().getImage("service.gui.icons.ADD_CONTACT_16x16_ICON")); callButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.CALL_16x16_ICON")); if (smsButton != null) smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); }
private void addButton(JPanel container, Action action, Hashtable actions, Icon icon) { String actionName = (String) action.getValue(Action.NAME); String actionCommand = (String) action.getValue(Action.ACTION_COMMAND_KEY); JButton button = new JButton(icon); button.setActionCommand(actionCommand); button.addActionListener(DeepaMehtaClientUtils.getActionByName(actionName, actions)); container.add(button); toolbarButtons[buttonIndex++] = button; }
private JButton makeToolbarButton(String name, String toolTipText, String action) { // Create and initialize the button. JButton button = new JButton(makeImageIcon(name)); button.setToolTipText(toolTipText); button.setActionCommand(action); button.addActionListener(this); return button; }
// GUI介面 public SystemEditReplace_Search() { jp.add(jl1); jp.add(tf1); jp.add(jl2); jp.add(tf2); jp.add(jb1); jb1.addActionListener(this); jp.add(jb2); jb2.addActionListener(this); }
void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f); buttonPanel.setBackground(bgColor); Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5); buttonPanel.setBorder(empty); textField = new JTextField(75); buttonPanel.add(textField); buttonPanel.add(Box.createHorizontalStrut(10)); searchPHI = new JButton("Search PHI"); searchPHI.addActionListener(this); buttonPanel.add(searchPHI); buttonPanel.add(Box.createHorizontalStrut(10)); searchTrial = new JButton("Search Trial IDs"); searchTrial.addActionListener(this); buttonPanel.add(searchTrial); buttonPanel.add(Box.createHorizontalStrut(20)); buttonPanel.add(Box.createHorizontalGlue()); saveAs = new JCheckBox("Save As..."); saveAs.setBackground(bgColor); buttonPanel.add(saveAs); mainPanel.add(buttonPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); textPane = new ColorPane(); // textPane.setEditable(false); scrollPane.setViewportView(textPane); mainPanel.add(scrollPane, BorderLayout.CENTER); JPanel footerPanel = new JPanel(); footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS)); footerPanel.setBackground(bgColor); message = new JLabel("Ready..."); footerPanel.add(message); mainPanel.add(footerPanel, BorderLayout.SOUTH); setTitle(windowTitle); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); getContentPane().add(mainPanel, BorderLayout.CENTER); pack(); centerFrame(); }
protected JButton createRunButton() { JButton run = new JButton("Run"); run.setEnabled(true); run.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { runSuite(); } }); return run; }
// Method to build the dialog box for help. private void buildDialogBox() { // Set the JDialog window properties. setTitle("Stack Trace Detail"); setResizable(false); setSize(dialogWidth, dialogHeight); // Append the stack trace output to the display area. displayArea.append(eStackTrace); // Create horizontal and vertical scrollbars for box. displayBox = Box.createHorizontalBox(); displayBox = Box.createVerticalBox(); // Add a JScrollPane to the Box. displayBox.add(new JScrollPane(displayArea)); // Define behaviors of container. c.setLayout(null); c.add(displayBox); c.add(okButton); // Set scroll pane bounds. displayBox.setBounds( (dialogWidth / 2) - ((displayAreaWidth / 2) + 2), (top + (offsetMargin / 2)), displayAreaWidth, displayAreaHeight); // Set the behaviors, bounds and action listener for the button. okButton.setBounds( (dialogWidth / 2) - (buttonWidth / 2), (displayAreaHeight + offsetMargin), buttonWidth, buttonHeight); // Set the font to the platform default Font for the object with the // properties of bold and font size of 11. okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11)); // The class implements the ActionListener interface and therefore // provides an implementation of the actionPerformed() method. When a // class implements ActionListener, the instance handler returns an // ActionListener. The ActionListener then performs actionPerformed() // method on an ActionEvent. okButton.addActionListener(this); // Set the screen and display dialog window in relation to screen size. setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2)); // Display JDialog. show(); } // End of buildDialogBox method.
public TextFields() { t1.setDocument(ucd); ucd.addDocumentListener(new T1()); b1.addActionListener(new B1()); b2.addActionListener(new B2()); t1.addActionListener(new T1A()); setLayout(new FlowLayout()); add(b1); add(b2); add(t1); add(t2); add(t3); }
public void runFinished() { // program execution finished so update // status and run button accordingly if (runThread == null) { // _runThread = null only if // execution stopped by user via // run button statusView.setText(" Stopped."); } else { statusView.setText(" Done."); } runButton.setActionCommand("Run"); runButton.setIcon(runImage); }
protected void showFooter() { footerPanel = new JPanel(); submitButton = new JButton("Abschicken"); submitButton.setMnemonic(KeyEvent.VK_A); submitButton.addActionListener(this); submitButton.setEnabled(checkIfFormIsComplete()); footerPanel.add(submitButton); closeButton = new JButton("Schließen"); closeButton.setMnemonic(KeyEvent.VK_S); closeButton.addActionListener(this); closeButton.setEnabled(true); footerPanel.add(closeButton); allPanel.add(footerPanel); }
public FindSynonymsActionHandler(String word, int position, Chapter c, AbstractEditorPanel p) { this.word = word; this.position = position; // this.chapter = c; this.editorPanel = p; this.projectViewer = this.editorPanel.getViewer(); final FindSynonymsActionHandler _this = this; // Show a panel of all the items. this.popup = new QPopup( "Synonyms for: " + word, Environment.getIcon(Constants.FIND_ICON_NAME, Constants.ICON_POPUP), null); JButton close = UIUtils.createButton( Constants.CLOSE_ICON_NAME, Constants.ICON_MENU, "Click to close", null); List<JButton> buts = new ArrayList(); buts.add(close); this.popup.getHeader().setControls(UIUtils.createButtonBar(buts)); close.addActionListener( new ActionAdapter() { public void actionPerformed(ActionEvent ev) { _this.popup.setVisible(false); _this.editorPanel.getEditor().removeHighlight(_this.highlight); } }); p.addPopup(this.popup, true, true); /* this.highlight = this.editorPanel.getEditor ().addHighlight (position, position + word.length (), null, true); */ this.popup.setOpaque(false); this.popup.setVisible(false); this.popup.setDraggable(this.editorPanel); }
/** sets this user to be an admin */ public void setAdmin() { admin = true; popup.add("kick user").addActionListener(myAction); if (chanAdmin) { butCreate.setEnabled(true); } }
private void init() { setSize(800, 600); cp = getContentPane(); cp.setLayout(null); btnResize.addActionListener(this); btnResize.setLocation(0, 0); btnResize.setSize(100, 30); sp.setLocation(0, 31); sp.setBorder(BorderFactory.createLineBorder(Color.blue, 2)); editorPane.setBorder(BorderFactory.createLineBorder(Color.red, 2)); step.setLocation(0, 31); step.setSize(100, 100); cp.add(step); // cp.add(sp); cp.add(btnResize); }
// 定义添加一行格式化文本框的方法 private void addRow(String labelText, final JFormattedTextField field) { mainPanel.add(new JLabel(labelText)); mainPanel.add(field); final JLabel valueLabel = new JLabel(); mainPanel.add(valueLabel); // 为"确定"按钮添加事件监听器 // 当用户单击“确定”按钮时,文本框后显示文本框内的值 okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Object value = field.getValue(); // 如果该值是数组,使用Arrays的toString方法输出数组 if (value.getClass().isArray()) { StringBuilder builder = new StringBuilder(); builder.append('{'); for (int i = 0; i < Array.getLength(value); i++) { if (i > 0) builder.append(','); builder.append(Array.get(value, i).toString()); } builder.append('}'); valueLabel.setText(builder.toString()); } else { // 输出格式化文本框的值 valueLabel.setText(value.toString()); } } }); }
public JButton createButton(Action a) { JButton b = new JButton() { public Dimension getMaximumSize() { int width = Short.MAX_VALUE; int height = super.getMaximumSize().height; return new Dimension(width, height); } }; // setting the following client property informs the button to show // the action text as it's name. The default is to not show the // action text. b.putClientProperty("displayActionText", Boolean.TRUE); b.setAction(a); // b.setAlignmentX(JButton.CENTER_ALIGNMENT); return b; }
private void initAddContactButton() { addButton.setAlignmentX(JButton.CENTER_ALIGNMENT); addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT")); buttonPanel.add(addButton); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { AddContactDialog dialog = new AddContactDialog(parentWindow); dialog.setContactAddress(parentWindow.getCurrentSearchText()); dialog.setVisible(true); } }); }
/** * used to manage the connection icons to signify connection and secure status * * @param b true if connected */ public void setConnected(boolean b) { if (b) { conIcon.setIcon(conYes); conIcon.setToolTipText("Connected"); secIcon.setIcon(secYes); secIcon.setToolTipText("Secure Connection"); butChannel.setEnabled(true); } else { conIcon.setIcon(conNo); conIcon.setToolTipText("Not Connected"); secIcon.setIcon(secNo); secIcon.setToolTipText("Connection not Secured"); butChannel.setEnabled(false); butCreate.setEnabled(false); butInvite.setEnabled(false); } }
/** * Create a button to go inside of the toolbar. By default this will load an image resource. The * image filename is relative to the classpath (including the '.' directory if its a part of the * classpath), and may either be in a JAR file or a separate file. * * @param key The key in the resource file to serve as the basis of lookups. */ protected JButton createToolbarButton(String key) { URL url = getResource(key + imageSuffix); JButton b = new JButton(new ImageIcon(url)) { @Override public float getAlignmentY() { return 0.5f; } }; b.setRequestFocusEnabled(false); b.setMargin(new Insets(1, 1, 1, 1)); String astr = getProperty(key + actionSuffix); if (astr == null) { astr = key; } Action a = getAction(astr); if (a != null) { b.setActionCommand(astr); b.addActionListener(a); } else { b.setEnabled(false); } String tip = getResourceString(key + tipSuffix); if (tip != null) { b.setToolTipText(tip); } return b; }
/** * Tests that the returned JButton of <code>createManualToolBarButton</code>: 1. Is disabled upon * return. 2. Inherits the tooltip of the Action parameter <code>a</code>. */ public void testCreateManualToolBarButton() { final Action a = new AbstractAction("Test Action") { public void actionPerformed(ActionEvent ae) {} }; a.putValue(Action.LONG_DESCRIPTION, "test tooltip"); Utilities.invokeAndWait( new Runnable() { public void run() { _but = _frame._createManualToolBarButton(a); } }); assertTrue("Returned JButton is enabled.", !_but.isEnabled()); assertEquals("Tooltip text not set.", "test tooltip", _but.getToolTipText()); _log.log("testCreateManualToobarButton completed"); }
/** * Updates the text area to take into account the new search text. * * @param searchText the search text to update */ private void updateTextArea(String searchText) { if (callButton.getParent() != null) { textArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'})); this.revalidate(); this.repaint(); } }
/** Initializes the call button. */ private void initSMSButton() { if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return; smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS")); smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); buttonPanel.add(smsButton); smsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; SMSManager.sendSMS(smsButton, searchText); } }); }