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); } }
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)); }
public Transferable createTransferable(JComponent comp) { // Clear image = null; Icon icon = null; if (comp instanceof JLabel) { JLabel label = (JLabel) comp; icon = label.getIcon(); } else if (comp instanceof AbstractButton) { AbstractButton button = (AbstractButton) comp; icon = button.getIcon(); } if (icon instanceof ImageIcon) { image = ((ImageIcon) icon).getImage(); return this; } return null; }
public static void writeTopString(String s) { if (s == null) { return; } statusLabel.setForeground(Color.black); statusLabel.setText(" " + s); }
public void testMnemonic() throws Exception { JPanel panel = (JPanel) getInstrumentedRootComponent("TestMnemonics.form", "BindingTest"); JLabel label = (JLabel) panel.getComponent(0); assertEquals("Mnemonic", label.getText()); assertEquals('M', label.getDisplayedMnemonic()); assertEquals(3, label.getDisplayedMnemonicIndex()); }
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."); } }
public static void main(String[] args) { final JPopupMenu menu = new JPopupMenu(); menu.setLayout(new GridLayout(0, 3, 5, 5)); final MenuedButton button = new MenuedButton("Icons", menu); for (int i = 0; i < 9; i++) { // replace "print.gif" with your own image final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") ); label.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { button.getMainButton().setIcon(label.getIcon()); menu.setVisible(false); } }); menu.add(label); } JFrame frame = new JFrame("Button Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH); frame.getContentPane().add(button, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public DisplayUserDirectory() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; hmlabel.setForeground(Color.black); add(hmlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(hmdir, gbc); add(Box.createVerticalStrut(15), gbc); gbc.gridwidth = 1; vjlabel.setForeground(Color.black); add(vjlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(vjdir, gbc); add(Box.createVerticalStrut(0), gbc); gbc.gridwidth = 1; vjlabel2.setForeground(Color.black); add(vjlabel2, gbc); setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder(" User_Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
public HeaderPanel(String heading) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(background); JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT); Font labelFont = new Font("Dialog", Font.BOLD, 18); panelLabel.setFont(labelFont); this.add(panelLabel); this.add(Box.createHorizontalGlue()); refresh = new JButton("Refresh"); refresh.addActionListener(this); this.add(refresh); this.add(Box.createHorizontalStrut(5)); root = new JComboBox(); Dimension d = root.getPreferredSize(); d.width = 90; root.setPreferredSize(d); root.setMaximumSize(d); File[] roots = directoryPane.getRoots(); for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath()); this.add(root); root.setSelectedIndex(directoryPane.getCurrentRootIndex()); root.addActionListener(this); this.add(Box.createHorizontalStrut(17)); }
BusinessPane() { setLayout(null); add(info_label); info_label.setBounds(10, 10, 300, 20); info_label.setFont(new Font("TimesRoman", Font.BOLD, 12)); add(info_scroll); info_scroll.setBounds(5, 35, 615, 400); info_name.add(columnName[0]); info_name.add(columnName[1]); info_name.add(columnName[2]); info_name.add(columnName[3]); DefaultTableModel info_model = new DefaultTableModel(info_data, info_name); info_table.setModel(info_model); info_table.getColumnModel().getColumn(0).setWidth(25); info_table.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 1) { // click to trigger the event // show_selected(); // System.out.print(table_selected(0)); } } }); add(B_refresh); B_refresh.setMargin(new java.awt.Insets(1, 1, 1, 1)); B_refresh.setBounds(530, 440, 90, 25); B_refresh.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { update_table(); } }); }
public static void writePrompt(String s) { if (s == null) { return; } outputLabel.setForeground(Color.black); outputLabel.setText(" " + s); hasEntered = false; }
public void showWord(String word, java.util.List<BoardCell> letterLocations, IPlayer player) { myWordList.add(word); scoreText.setText(player.getScore() + ""); scoreText.paintImmediately(scoreText.getVisibleRect()); myWordList.paintImmediately(myWordList.getVisibleRect()); // myBoardPanel.highlightDice(letterLocations); wordEntryField.clear(); // clear the wordEntryField text }
public void ShowChessNumber() // 显示黑子白子数目 { white = 0; black = 0; Count(); blackNumberLabel.setText("黑子数:" + black + " "); whiteNumberLabel.setText("白子数:" + white + " "); }
@Override public void paintComponent(Graphics g) { if (selected) { g.setColor(selColor); g.fillRoundRect(0, 0, getWidth(), getHeight(), getWidth() / 10, getHeight() / 10); label.setForeground(Color.YELLOW); } else label.setForeground(Color.WHITE); super.paintComponent(g); }
// Game Logic public void phase1() { System.out.println("Phase 1"); lblStatus1.setText("S+ Phase"); lblStatus2.setText("Advancing slow actions..."); lblStatus3.setText(""); ListIterator iList = listAT.listIterator(); while (iList.hasNext()) ((GameAction) iList.next()).tick(); phase2(); }
private void loadPreferences() { // grab the preferences so that they can be used to fill out the layout ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance(); // x resolution text box xres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME)); // y resolution text box yres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME)); // aspect ratio checkbox aspect.setSelected( myPreferences .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME) .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING)); // load the color values from the preferences int redValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME); int greenValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME); int blueValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME); // set the background color image colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber)); // red slider red.setValue(redValueNumber); redValue.setText("" + redValueNumber); // green slider green.setValue(greenValueNumber); greenValue.setText("" + greenValueNumber); // blue slider blue.setValue(blueValueNumber); blueValue.setText("" + blueValueNumber); // algorithm combo box algorithm.setSelectedIndex( myPreferences.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME)); // format combo box format.setSelectedIndex( myPreferences.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME)); // prepend field prepend.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME)); // append field append.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME)); // output folder field output.setText( (new File(myPreferences.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME))) .getAbsolutePath()); }
public void setVisible(boolean bShow, String title) { if (bShow) { String strDir = ""; String strFreq = ""; String strTraynum = ""; m_strHelpFile = getHelpFile(title); String strSampleName = getSampleName(title); String frameBounds = getFrameBounds(title); StringTokenizer tok = new QuotedStringTokenizer(title); if (tok.hasMoreTokens()) strDir = tok.nextToken(); if (tok.hasMoreTokens()) strFreq = tok.nextToken(); if (tok.hasMoreTokens()) strTraynum = tok.nextToken(); else { try { Integer.parseInt(strDir); // if strdir is number, then strdir is empty, and the // strfreq is the number strTraynum = strFreq; strFreq = strDir; strDir = ""; } catch (Exception e) { } } try { setTitle(gettitle(strFreq)); m_lblSampleName.setText("3"); boolean bVast = isVast(strTraynum); CardLayout layout = (CardLayout) m_pnlSampleName.getLayout(); if (!bVast) { if (strSampleName == null) { strSampleName = getSampleName(strDir, strTraynum); } m_lblSampleName.setText(strSampleName); layout.show(m_pnlSampleName, OTHER); } else { m_strDir = strDir; setTrays(); layout.show(m_pnlSampleName, VAST); m_trayTimer.start(); } boolean bSample = bVast || !strSampleName.trim().equals(""); m_pnlSampleName.setVisible(bSample); m_lblLogin.setForeground(getBackground()); m_lblLogin.setVisible(false); m_passwordField.setText(""); m_passwordField.setCaretPosition(0); } catch (Exception e) { Messages.writeStackTrace(e); } setBounds(frameBounds); ExpPanel exp = Util.getActiveView(); if (exp != null) exp.waitLogin(true); } writePersistence(); setVisible(bShow); }
void addTextField(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextField field = new JTextField(); field.setText(sketch.configFile.get(key)); field.setMaximumSize(new Dimension(Integer.MAX_VALUE, field.getPreferredSize().height)); fields.put(key, field); panel.add(field); }
/** Update button enable/disable state according enableCheckBox. */ private void updateButtonsState() { sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); fileCountField.setEnabled(enableCheckBox.isSelected()); fileSizeField.setEnabled(enableCheckBox.isSelected()); fileSizeLabel.setEnabled(enableCheckBox.isSelected()); fileCountLabel.setEnabled(enableCheckBox.isSelected()); }
public SidebarOption(String labelTxt, String rsc) { label = new JLabel(labelTxt); label.setForeground(Color.WHITE); label.setFont(font); add(label); setOpaque(false); setMaximumSize(new Dimension(1000, label.getPreferredSize().height + 5)); this.rsc = ClassLoader.getSystemClassLoader().getResource(rsc); }
/*Creates the South section of the mancala board. */ private JPanel southBoardPanel() { JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 300, 50)); p1Label = new JLabel("Player 1"); p1Label.setFont(new Font("Belta Regular", Font.BOLD, 50)); p1Label.setForeground(new Color(203, 159, 0)); southPanel.add(p1Label); southPanel.setOpaque(false); southPanel.setPreferredSize(new Dimension(600, 100)); return southPanel; }
public void phase3() { System.out.println("Phase 3"); lblStatus1.setText("C+ Phase"); lblStatus2.setText("Incrementing CT..."); lblStatus3.setText(""); for (int i = 0; i < listChar.length; i++) listChar[i].incrementCT(); iChar = 0; phase4(); }
/** * Update changing components. * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override public void paintComponent(Graphics g) { money.setText(String.valueOf(player.getMoney())); record.setText(String.valueOf(bestScore)); dealerPanel.removeAll(); playerPanel.removeAll(); for (Card dealerCard : dealer.getCards()) dealerPanel.add(dealerCard); for (Card playerCard : player.getCards()) playerPanel.add(playerCard); revalidate(); }
/** Called when color slider values change. */ public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); int val = slider.getValue(); String s = "" + val; if (val < 100) s = "0" + s; if (val < 10) s = "0" + s; if (slider == red) redValue.setText(s); else if (slider == green) greenValue.setText(s); else if (slider == blue) blueValue.setText(s); Color c = new Color(red.getValue(), green.getValue(), blue.getValue()); colorBox.setBackground(c); }
/** PaintComponent to draw everything. */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.WHITE); // If using images, use cool dragon background if (useImages) g.drawImage(background, 0, 0, 310, 300, null); // Use light gray to not overpower the background image g.setColor(Color.LIGHT_GRAY); for (int y = 1; y < ROWS; ++y) g.fillRoundRect(0, cellSize * y - 4, (cellSize * COLS) - 1, 8, 8, 8); for (int x = 1; x < COLS; ++x) g.fillRoundRect(cellSize * x - 4, 0, 8, (cellSize * ROWS) - 1, 8, 8); // Use graphics2d for when not using the images Graphics2D g2d = (Graphics2D) g; g2d.setStroke(new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); for (int y = 0; y < ROWS; ++y) { for (int x = 0; x < COLS; ++x) { int x1 = x * cellSize + 16; int y1 = y * cellSize + 16; if (board[y][x] == Symbol.X) { // use image if set to true, otherwise use g2d // for thicker, better looking X's and O's if (useImages) g.drawImage(imageX, x1, y1, 75, 75, null); else { g2d.setColor(PURPLE); int x2 = (x + 1) * cellSize - 16; int y2 = (y + 1) * cellSize - 16; g2d.drawLine(x1, y1, x2, y2); g2d.drawLine(x2, y1, x1, y2); } } else if (board[y][x] == Symbol.O) { if (useImages) g.drawImage(imageO, x1, y1, 75, 75, null); else { g2d.setColor(Color.BLUE); g2d.drawOval(x1, y1, 70, 70); } } } // end for } // Set status bar based on gamestate. If CONTINUE, show whose turn it is if (gameStatus == GameStatus.CONTINUE) { statusBar.setForeground(Color.BLACK); if (currentPlayer == Symbol.X) statusBar.setText("X's Turn"); else statusBar.setText("O's Turn"); } else if (gameStatus == GameStatus.DRAW) { statusBar.setForeground(Color.RED); statusBar.setText("Draw! Click to play again!"); } else if (gameStatus == GameStatus.X_WIN) { statusBar.setForeground(Color.RED); statusBar.setText("X has won! Click to play again!"); } else if (gameStatus == GameStatus.O_WIN) { statusBar.setForeground(Color.RED); statusBar.setText("O has won! Click to play again!"); } }
// Panel above board private JPanel northWindowPanel() { JPanel lab2Panel = new JPanel(); lab2Panel.setLayout(new BorderLayout()); lab2Panel.setPreferredSize(new Dimension(300, 150)); lab2Panel.setOpaque(false); statusLabel2 = new JLabel("", JLabel.CENTER); statusLabel2.setForeground(new Color(203, 159, 0)); statusLabel2.setFont(new Font("Belta Regular", Font.ITALIC, 45)); lab2Panel.add(statusLabel2, BorderLayout.CENTER); return lab2Panel; }
public void save() { boolean isNoticed = false; if (!notice.isVisible()) { isNoticed = true; notice.setVisible(true); notice.setText("Saving..."); } if (getOptions() != null) { DB database = null; try { database = factory.open(this.leveldbStore.getSelectedFile(), getOptions()); DBIterator iterator = database.iterator(); HashSet<byte[]> keys = new HashSet<>(); for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) { keys.add(iterator.peekNext().getKey()); } iterator.close(); for (byte[] key : keys) { database.delete(key); } for (int i = 0; i < dataList.getModel().getSize(); ++i) { DBItem item = dataList.getModel().getElementAt(i); database.put(item.key, item.value); } } catch (Exception e) { JOptionPane.showMessageDialog(pane, "Unable to open database:\n" + e); e.printStackTrace(); } finally { if (database != null) { try { database.close(); } catch (IOException e) { JOptionPane.showMessageDialog(pane, "Unable to close database:\n" + e); e.printStackTrace(); } } saveButton.setEnabled(false); } } if (isNoticed) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } notice.setVisible(false); notice.setText(""); } }
void addTextArea(JPanel panel, String key, String label) { JLabel lab = new JLabel(label); lab.setAlignmentX(LEFT_ALIGNMENT); panel.add(lab); JTextArea field = new JTextArea(); field.setText(sketch.configFile.get(key)); field.setLineWrap(true); field.setWrapStyleWord(true); fields.put(key, field); JScrollPane scroll = new JScrollPane(field); scroll.setAlignmentX(0.0f); panel.add(scroll); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
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); }