private void pageChanged() { switch (currentPage) { case 0: caption.setText("Specify where " + appName + " is to be installed"); nextButton.setText("Next"); prevButton.setEnabled(true); break; case 1: caption.setText("Installing " + appName); nextButton.setText("Finish"); prevButton.setEnabled(false); nextButton.setEnabled(false); install(); break; case 2: caption.setText("Installation complete"); nextButton.setText("Finish"); prevButton.setEnabled(false); nextButton.setEnabled(true); cancelButton.setEnabled(false); break; } getRootPane().invalidate(); getRootPane().validate(); }
@NotNull @Override public Component getTreeCellRendererComponent( @NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (value instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) value; myLabel.setText(getRenamedTitle(node.getKey().field.getName(), node.getText())); myLabel.setFont( myLabel .getFont() .deriveFont(node.getKey().groupName == null ? Font.BOLD : Font.PLAIN)); myLabel.setEnabled(node.isEnabled()); } else { myLabel.setText(getRenamedTitle(value.toString(), value.toString())); myLabel.setFont(myLabel.getFont().deriveFont(Font.BOLD)); myLabel.setEnabled(true); } Color foreground = selected ? UIUtil.getTableSelectionForeground() : UIUtil.getTableForeground(); myLabel.setForeground(foreground); return myLabel; }
private void createHealthPanel() { remove(healthPanel); remove(statsPanel); lblPlayerHealth.setText( "<html><font color='green'>" + GamePanel.healthPlayer + "</font></html>"); lblMrSawyerHealth.setText( "<html><font color='green'>" + GamePanel.healthMrSawyer + "</font></html>"); lblVikrantHealth.setText( "<html><font color='green'>" + GamePanel.healthVikrant + "</font></html>"); lblVarunHealth.setText("<html><font color='green'>" + GamePanel.healthVarun + "</font></html>"); lblBrianHealth.setText("<html><font color='green'>" + GamePanel.healthBrian + "</font></html>"); healthPanel.setLayout(new GridLayout(5, 2)); healthPanel.setBackground(new Color(0xd2b48c)); healthPanel.add(lblPlayerName); healthPanel.add(lblPlayerHealth); healthPanel.add(lblMrSawyerName); healthPanel.add(lblMrSawyerHealth); healthPanel.add(lblVikrantName); healthPanel.add(lblVikrantHealth); healthPanel.add(lblVarunName); healthPanel.add(lblVarunHealth); healthPanel.add(lblBrianName); healthPanel.add(lblBrianHealth); add(healthPanel, BorderLayout.WEST); revalidate(); repaint(); }
private void sendRequest(BlockPdu pdu) { setButton.setEnabled(false); getButton.setEnabled(false); getNextButton.setEnabled(false); lmessage.setText("Sending request .."); lmessage.setBackground(Color.white); try { varbind var = pdu.getResponseVariableBinding(); AsnObjectId oid = var.getOid(); AsnObject res = var.getValue(); if (res != null) { toid.setText(oid.toString()); tvalue.setText(res.toString()); lmessage.setText("Received aswer "); lmessage.setBackground(Color.white); } else { lmessage.setText("Received no aswer "); lmessage.setBackground(Color.red); } } catch (PduException exc) { lmessage.setText("PduException: " + exc.getMessage()); lmessage.setBackground(Color.red); exc.printStackTrace(); } catch (java.io.IOException exc) { lmessage.setText("IOException: " + exc.getMessage()); lmessage.setBackground(Color.red); exc.printStackTrace(); } setButton.setEnabled(true); getButton.setEnabled(true); getNextButton.setEnabled(true); }
public IGEgui() { start = new JPanel(); randomizer = new JPanel(); randomButton = new JButton("Randomize"); locationButton = new JButton("Randomize"); locationField = new JTextField(10); welcomeL = new JLabel(); instructL = new JLabel(); restaurantL = new JLabel(); setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Random Restaurant Generator"); setSize(300, 150); locationButton.addActionListener(this); randomButton.addActionListener(this); welcomeL.setText("Welcome to the Random Restaurant Generator!"); instructL.setText("Please enter your location (Zip code/City, State)"); restaurantL.setText(""); start.add(welcomeL); start.add(instructL); start.add(locationField); start.add(locationButton); randomizer.add(restaurantL); randomizer.add(randomButton); setContentPane(start); }
public void updateHealth() { if (GamePanel.healthPlayer > 0) lblPlayerHealth.setText( "<html><font color='green'>" + GamePanel.healthPlayer + "</font></html>"); else lblPlayerHealth.setText( "<html><font color='red'>" + GamePanel.healthPlayer + "</font></html>"); if (GamePanel.healthMrSawyer > 0) lblMrSawyerHealth.setText( "<html><font color='green'>" + GamePanel.healthMrSawyer + "</font></html>"); else lblMrSawyerHealth.setText( "<html><font color='red'>" + GamePanel.healthMrSawyer + "</font></html>"); if (GamePanel.healthVikrant > 0) lblVikrantHealth.setText( "<html><font color='green'>" + GamePanel.healthVikrant + "</font></html>"); else lblVikrantHealth.setText( "<html><font color='red'>" + GamePanel.healthVikrant + "</font></html>"); if (GamePanel.healthVarun > 0) lblVarunHealth.setText( "<html><font color='green'>" + GamePanel.healthVarun + "</font></html>"); else lblVarunHealth.setText("<html><font color='red'>" + GamePanel.healthVarun + "</font></html>"); if (GamePanel.healthBrian > 0) lblBrianHealth.setText( "<html><font color='green'>" + GamePanel.healthBrian + "</font></html>"); else lblBrianHealth.setText("<html><font color='red'>" + GamePanel.healthBrian + "</font></html>"); }
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 void updateHelper() { if (model.GuessORHint == 0) { label1.setText("Entered:"); } if (model.GuessORHint == 1) { label1.setText("Hints:"); } DefaultListModel<String> listTemp = new DefaultListModel<String>(); if (model.GuessORHint == 0) { for (String str : model.haveEntered) { listTemp.addElement(str); } } else { if (model.hintWords != null) { for (String MM : model.hintWords) { if (MM == null) { listTemp.addElement("APPLE"); } else { listTemp.addElement(MM); } } } } list.setModel(listTemp); scroll.setViewportView(list); }
private void updateCountLabel() { int placesCount = 0; int enablePlacesCount = 0; final List<InjInfo> items = myInjectionsTable.getListTableModel().getItems(); if (!items.isEmpty()) { for (InjInfo injection : items) { for (InjectionPlace place : injection.injection.getInjectionPlaces()) { placesCount++; if (place.isEnabled()) enablePlacesCount++; } } myCountLabel.setText( items.size() + " injection" + (items.size() > 1 ? "s" : "") + " (" + enablePlacesCount + " of " + placesCount + " place" + (placesCount > 1 ? "s" : "") + " enabled) "); } else { myCountLabel.setText("no injections configured "); } }
public void ShowChessNumber() // 显示黑子白子数目 { white = 0; black = 0; Count(); blackNumberLabel.setText("黑子数:" + black + " "); whiteNumberLabel.setText("白子数:" + white + " "); }
/** 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!"); } }
public void setLabels() { int currentRoomID = model.getPlayer().getCurrentRoomID(); magic.setText(model.getRoom(currentRoomID).getMagicName()); health.setText("Health = " + model.getPlayer().getHealth()); magic.setVerticalTextPosition(JLabel.TOP); exp.setText("Experience = " + model.getPlayer().getExp()); currentRoom.setText("Current Room ID = " + model.getPlayer().getCurrentRoomID()); playerItemLabel.setText("Player's Items (Max " + model.getPlayer().getExp() + ")"); }
// Renders the selected image protected void updateLabel(String name) { ImageIcon icon = createImageIcon("images/" + name + ".gif"); picture.setIcon(icon); if (icon != null) { picture.setText(null); } else { picture.setText("Image not found"); } }
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); }
/** * 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(); }
@NotNull @Override public Component getTableCellRendererComponent( @NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { myTable = table; myRow = row; myColumn = column; boolean isEnabled = true; final DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((TreeTable) table).getTree().getPathForRow(row).getLastPathComponent(); Option key = null; if (node instanceof MyTreeNode) { isEnabled = ((MyTreeNode) node).isEnabled(); key = ((MyTreeNode) node).getKey(); } if (!table.isEnabled()) { isEnabled = false; } Color background = table.getBackground(); if (value instanceof Boolean) { myCheckBox.setSelected(((Boolean) value).booleanValue()); myCheckBox.setBackground(background); myCheckBox.setEnabled(isEnabled); return myCheckBox; } else if (value instanceof String) { /* myComboBox.removeAllItems(); myComboBox.addItem(value); */ myComboBox.setText((String) value); myComboBox.setBackground(background); myComboBox.setEnabled(isEnabled); return myComboBox; } else if (value instanceof Integer) { if (key instanceof IntOption && ((IntOption) key).isDefaultValue(value)) { myIntLabel.setText(((IntOption) key).getDefaultValueText()); } else { myIntLabel.setText(value.toString()); } return myIntLabel; } myCheckBox.putClientProperty("JComponent.sizeVariant", "small"); myComboBox.putClientProperty("JComponent.sizeVariant", "small"); myEmptyLabel.setBackground(background); return myEmptyLabel; }
/** Formats and displays today's date. */ public void reformat() { Date today = new Date(); SimpleDateFormat formatter = new SimpleDateFormat(currentPattern); try { String dateString = formatter.format(today); result.setForeground(Color.black); result.setText(dateString); } catch (IllegalArgumentException iae) { result.setForeground(Color.red); result.setText("Error: " + iae.getMessage()); } }
public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); if (b == locationButton) { yelpHelp.yelpRestaurants(locationField.getText()); remove(start); setContentPane(randomizer); restaurantL.setText(yelpHelp.randomPlace()); } else if (b == randomButton) { restaurantL.setText(yelpHelp.randomPlace()); } }
/** * Implementing the Observer interface. Receiving the response from the Pdu. * * @param obs the UpSincePdu variable * @param ov the date * @see uk.co.westhawk.snmp.pdu.UpSincePdu */ public void update(Observable obs, Object ov) { Pdu pdu = (Pdu) obs; if (pdu.getErrorStatus() == AsnObject.SNMP_ERR_NOERROR) { Date dres = (Date) ov; if (dres != null) { // TODO: invokeLater v.setText(dres.toString()); } } else { // TODO: invokeLater v.setText(pdu.getErrorStatusString()); } }
/** Create the frame */ public DateTimer() { super(); setTitle("v14 CountDown"); getContentPane().setLayout(null); setBounds(100, 100, 500, 375); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel finishtimeLabel = new JLabel(); finishtimeLabel.setText("CountDown Time"); finishtimeLabel.setBounds(10, 36, 119, 15); getContentPane().add(finishtimeLabel); finishtime = new JFormattedTextField( new DateFormatter(new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa", Locale.ENGLISH))); finishtime.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) {} }); finishtime.setValue(new Date()); finishtime.setBounds(135, 34, 187, 19); getContentPane().add(finishtime); final JButton startButton = new JButton(); startButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { startCount(); } }); startButton.setText("Start!!!"); startButton.setBounds(334, 31, 111, 25); getContentPane().add(startButton); countLabel = new JLabel(); countLabel.setHorizontalAlignment(SwingConstants.CENTER); countLabel.setHorizontalTextPosition(SwingConstants.CENTER); countLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 14)); countLabel.setBorder(new LineBorder(Color.black, 1, false)); countLabel.setText("Countdown not Started"); countLabel.setBounds(10, 162, 435, 47); getContentPane().add(countLabel); final JLabel credits = new JLabel(); credits.setHorizontalAlignment(SwingConstants.RIGHT); credits.setText(""); credits.setBounds(253, 328, 237, 15); getContentPane().add(credits); }
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); }
public void tampilan_GUI() { this.getContentPane().setBackground(Color.yellow); this.getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Dialog", 1, 16)); jLabel1.setText("Please Waiting..."); jLabel1.setBounds(new Rectangle(14, 5, 187, 30)); prosesBar.setBounds(new Rectangle(14, 40, 311, 16)); prosesBar.setStringPainted(true); statusProses.setText(""); statusProses.setBounds(new Rectangle(14, 60, 311, 16)); this.getContentPane().add(jLabel1); this.getContentPane().add(prosesBar); this.getContentPane().add(statusProses); }
private void updateMemDisplay() { if (product != null) { long storageMem = product.getRawStorageSize(productSubsetDef); double factor = 1.0 / (1024 * 1024); double megas = MathUtils.round(factor * storageMem, 10); if (megas > memWarnLimit) { memLabel.setForeground(MEM_LABEL_WARN_COLOR); } else { memLabel.setForeground(MEM_LABEL_NORM_COLOR); } memLabel.setText(MEM_LABEL_TEXT + megas + "M"); } else { memLabel.setText(" "); } }
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { renderer.setForeground(Color.BLACK); renderer.setText(value.toString()); if (sel) { renderer.setOpaque(true); } else { renderer.setOpaque(false); } if (leaf) { return (makeComponent((JIDStatus) value)); } if (value instanceof PrimaryJIDStatus) { PrimaryJIDStatus ps = (PrimaryJIDStatus) value; JIDStatus jidsStatus = ps.getJIDPrimaryStatus(); if (ps.hasMultiple()) { if (onlineTree) { if (ps.multipleJIDstatusOnline()) { renderer.setForeground(new Color(0, 0, 190)); } return makeComponent(jidsStatus); } if (ps.isAJIDstatusOffline()) { // if offline tree and a jidStatus in primary is offline // show renderer.setIcon(StatusIcons.getImageIcon("multiple")); } return renderer; } return makeComponent(jidsStatus); } else if (value instanceof JIDStatusGroup) { JIDStatusGroup group = (JIDStatusGroup) value; if (onlineTree) { renderer.setText(group.toString() + " (" + group.getOnlines() + ")"); } if (expanded) { renderer.setIcon(StatusIcons.getImageIcon("arrowDown")); } else { renderer.setIcon(StatusIcons.getImageIcon("arrowUp")); } } return renderer; }
@NotNull @Override public Component getTableCellRendererComponent( @NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final RegistryValue v = ((MyTableModel) table.getModel()).getRegistryValue(row); myLabel.setIcon(null); myLabel.setText(null); myLabel.setHorizontalAlignment(SwingConstants.LEFT); Color fg = isSelected ? table.getSelectionForeground() : table.getForeground(); Color bg = isSelected ? table.getSelectionBackground() : table.getBackground(); if (v != null) { switch (column) { case 0: myLabel.setIcon(v.isRestartRequired() ? RESTART_ICON : null); myLabel.setHorizontalAlignment(SwingConstants.CENTER); break; case 1: myLabel.setText(v.getKey()); break; case 2: if (v.asColor(null) != null) { myLabel.setIcon(createColoredIcon(v.asColor(null))); } else if (v.isBoolean()) { final JCheckBox box = new JCheckBox(); box.setSelected(v.asBoolean()); box.setBackground(bg); return box; } else { myLabel.setText(v.asString()); } } myLabel.setOpaque(true); myLabel.setFont( myLabel.getFont().deriveFont(v.isChangedFromDefault() ? Font.BOLD : Font.PLAIN)); myLabel.setForeground(fg); myLabel.setBackground(bg); } return myLabel; }
public void prettyPrint() { try { // clear old problem messages problemsView.setText(""); // update status view statusView.setText(" Parsing ..."); LispExpr root = Parser.parse(textView.getText()); statusView.setText(" Pretty Printing ..."); String newText = PrettyPrinter.prettyPrint(root); textView.setText(newText); statusView.setText(" Done."); } catch (Error e) { System.err.println(e.getMessage()); statusView.setText(" Errors."); } }
public static void writeTopString(String s) { if (s == null) { return; } statusLabel.setForeground(Color.black); statusLabel.setText(" " + s); }
/** * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as * <tt>CallPeer</tt> display name, call duration, security status. * * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information * such as <tt>CallPeer</tt> display name, call duration, security status */ private Component createStatusBar() { // stateLabel callStatusLabel.setForeground(Color.WHITE); dtmfLabel.setForeground(Color.WHITE); callStatusLabel.setText(callPeer.getState().getLocalizedStateString()); PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; statusPanel.add(securityStatusLabel, constraints); initSecurityStatusLabel(); constraints.gridx++; statusPanel.add(holdStatusLabel, constraints); constraints.gridx++; statusPanel.add(muteStatusLabel, constraints); constraints.gridx++; callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12)); statusPanel.add(callStatusLabel, constraints); constraints.gridx++; constraints.weightx = 1f; statusPanel.add(dtmfLabel, constraints); return statusPanel; }
@Override public Component getListCellRendererComponent( JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) { label.setText(Objects.toString(value, "")); this.list = list; this.index = index; if (isSelected) { setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); } else { setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground()); label.setForeground(list.getForeground()); } MutableComboBoxModel m = (MutableComboBoxModel) list.getModel(); if (index < 0 || m.getSize() - 1 <= 0) { setOpaque(false); deleteButton.setVisible(false); label.setForeground(list.getForeground()); } else { boolean f = index == rolloverIndex; setOpaque(true); deleteButton.setVisible(true); deleteButton.getModel().setRollover(f); deleteButton.setForeground(f ? Color.WHITE : list.getForeground()); } return this; }
public void setTimeMessage(String message) { // <<TODO:IMPROVE>> Treat null messages like "" [Jon Aquino] timeLabel.setText((message == "") ? " " : message); // Make message at least a space so that status bar won't collapse [Jon // Aquino] }