private void updateDisplay() { // first, set block colours textView.setBackground(getColour(backgroundColour("text-background-colour"))); textView.setForeground(getColour(foregroundColour("text-foreground-colour"))); textView.setCaretColor(getColour(foregroundColour("text-caret-colour"))); problemsView.setBackground(getColour(backgroundColour("problems-background-colour"))); problemsView.setForeground(getColour(foregroundColour("problems-foreground-colour"))); consoleView.setBackground(getColour(backgroundColour("console-background-colour"))); consoleView.setForeground(getColour(foregroundColour("console-foreground-colour"))); // second, set colours on the code! java.util.List<Lexer.Token> tokens = Lexer.tokenise(textView.getText(), true); int pos = 0; for (Lexer.Token t : tokens) { int len = t.toString().length(); if (t instanceof Lexer.RightBrace || t instanceof Lexer.LeftBrace) { highlightArea(pos, len, foregroundColour("text-brace-colour")); } else if (t instanceof Lexer.Strung) { highlightArea(pos, len, foregroundColour("text-string-colour")); } else if (t instanceof Lexer.Comment) { highlightArea(pos, len, foregroundColour("text-comment-colour")); } else if (t instanceof Lexer.Quote) { highlightArea(pos, len, foregroundColour("text-quote-colour")); } else if (t instanceof Lexer.Comma) { highlightArea(pos, len, foregroundColour("text-comma-colour")); } else if (t instanceof Lexer.Identifier) { highlightArea(pos, len, foregroundColour("text-identifier-colour")); } else if (t instanceof Lexer.Integer) { highlightArea(pos, len, foregroundColour("text-integer-colour")); } pos += len; } }
private JPanel createCentrePanel(YDataStateException exception) { JPanel centrePanel = new JPanel(new GridLayout(1, 2)); JPanel msgPanel = new JPanel(new BorderLayout()); msgPanel.setBackground(YAdminGUI._apiColour); msgPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Schema for completing task"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane msgTextPane = new JTextPane(); msgTextPane.setContentType("text/plain"); msgTextPane.setFont(new Font("courier", Font.PLAIN, 12)); msgTextPane.setForeground(Color.RED); msgTextPane.setText(exception.getMessage()); msgTextPane.setEditable(false); msgTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel = new JPanel(); noWrapPanel.setLayout(new BorderLayout()); noWrapPanel.add(msgTextPane); msgPanel.add(new JScrollPane(noWrapPanel)); centrePanel.add(msgPanel, BorderLayout.NORTH); return centrePanel; }
private void initDebugTextPane() { HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); HTMLDocument htmlDocument = new HTMLDocument(); debugTextPane.setEditable(false); debugTextPane.setBackground(Color.WHITE); debugTextPane.setEditorKit(htmlEditorKit); htmlEditorKit.install(debugTextPane); debugTextPane.setDocument(htmlDocument); }
public Container CreateContentPane() { // Create the content-pane-to-be. JPanel contentPane = new JPanel(new BorderLayout()); contentPane.setOpaque(true); // the log panel log = new JTextPane(); log.setEditable(false); log.setBackground(Color.BLACK); logPane = new JScrollPane(log); kit = new HTMLEditorKit(); doc = new HTMLDocument(); log.setEditorKit(kit); log.setDocument(doc); DefaultCaret c = (DefaultCaret) log.getCaret(); c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ClearLog(); // the preview panel previewPane = new DrawPanel(); previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right); // status bar statusBar = new StatusBar(); Font f = statusBar.getFont(); statusBar.setFont(f.deriveFont(Font.BOLD, 15)); Dimension d = statusBar.getMinimumSize(); d.setSize(d.getWidth(), d.getHeight() + 30); statusBar.setMinimumSize(d); // layout Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT); split.add(previewPane); split.add(logPane); split.setDividerSize(8); contentPane.add(statusBar, BorderLayout.SOUTH); contentPane.add(split, BorderLayout.CENTER); // open the file if (recentFiles[0].length() > 0) { OpenFileOnDemand(recentFiles[0]); } // connect to the last port ListSerialPorts(); if (Arrays.asList(portsDetected).contains(recentPort)) { OpenPort(recentPort); } return contentPane; }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Windows Form * Designer. Otherwise, retrieving design might not work properly. Tip: If you must revise this * method, please backup this GUI file for JFrameBuilder to retrieve your design properly in * future, before revising this method. */ private void initializeComponent() { jTextPane1 = new JTextPane(); jButton1 = new JButton(); jButton2 = new JButton(); contentPane = (JPanel) this.getContentPane(); // // jTextPane1 // jTextPane1.setBackground(new Color(140, 152, 236)); jTextPane1.setForeground(new Color(255, 0, 0)); jTextPane1.setText( " \n NO DONUT FOR YOU\n SORRY FOR INCONVINIENCE FACED BY YOU\n SEVER IS DOWN FOR A TIME BEING\n PLEASE TRY AGAIN LATER"); jTextPane1.setEditable(false); // // jButton1 // jButton1.setText("Home"); jButton1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); // // jButton2 // jButton2.setText("Friends"); jButton2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); // // contentPane // contentPane.setLayout(null); contentPane.setBackground(new Color(140, 152, 236)); addComponent(contentPane, jTextPane1, 76, 165, 451, 150); addComponent(contentPane, jButton1, 94, 36, 83, 39); addComponent(contentPane, jButton2, 184, 36, 83, 39); // // serverdown // this.setTitle("serverdown - extends JFrame"); this.setLocation(new Point(0, 0)); this.setSize(new Dimension(1024, 768)); }
private void updateFontColor() { Font mainFont = DrJava.getConfig().getSetting(OptionConstants.FONT_MAIN); Color backColor = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_BACKGROUND_COLOR); Color fontColor = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_NORMAL_COLOR); /* make it bigger */ Font titleFont = mainFont.deriveFont((float) (mainFont.getSize() + 3)); _antiAliasText = DrJava.getConfig().getSetting(OptionConstants.TEXT_ANTIALIAS).booleanValue(); _label.setForeground(fontColor); _panel.setBackground(backColor); _label.setFont(titleFont); _textpane.setForeground(fontColor); _textpane.setFont(mainFont); ; _textpane.setBackground(backColor); _scroller.setBackground(backColor); _scroller.setBorder(new EmptyBorder(0, 0, 0, 0)); _panel.setBorder(new LineBorder(fontColor, 1)); }
private void decompile(Map params) { try { ClazzSourceView csv = ClazzSourceViewFactory.getClazzSourceView(clazz); csv.setDecompileParameters(params); source = csv.getSource(); String sourceText = source; sourceText = sourceText.replaceAll(" ", " "); sourceText = sourceText.replaceAll("<", "<"); sourceText = sourceText.replaceAll(">", ">"); sourceText = sourceText.replaceAll("\n", "<BR>"); sourcePane.setText(sourceText); sourcePane.setCaretPosition(0); } catch (Throwable ex) { if (Utils.hasDebug()) { ex.printStackTrace(); } sourcePane.setText("Exception occured while decompiling"); String link = "http://sourceforge.net/tracker/?group_id=226227&atid=1066690"; String exception = unpackException(ex); JTextPane text = new JTextPane(); text.setContentType("text/html"); text.setText( "<html>Error occured while decompiling!<BR>Please submit bug at <b>" + link + "</b><BR>" + exception + "</html>"); text.setEditable(false); text.setBackground(this.getBackground()); JOptionPane.showMessageDialog(this, text, "Error", JOptionPane.ERROR_MESSAGE); throw new IllegalArgumentException("Error decompiling"); } }
public MyDialog() { super(); // "\u041e\u0448\u0438\u0431\u043a\u0430\u002e", true); setSize(200, 100); setLocation(350, 260); setBackground(new Color(0.77254903f, 0.015686275f, 0.12941177f, 1f)); setVisible(false); // <html><body text="red"><h3><i> </i></h3></body> label = new JTextPane(); label.setSize(196, 70); label.setLocation(2, 2); label.setBackground(new Color(0.77254903f, 0.015686275f, 0.12941177f, 1f)); label.setFont(new Font("Serif", Font.PLAIN, 16)); text = new String(""); MenuButton continuer = new MenuButton( "\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c", 2, 75, 96, 20, 7f); continuer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { setVisible(false); } }); MenuButton more = new MenuButton( "\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435", 102, 75, 96, 20, 7f); more.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { label.setText(text); } }); setLayout(null); add(label); add(continuer); add(more); }
public GithubLoginPanel(final GithubLoginDialog dialog) { DocumentListener listener = new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { dialog.clearErrors(); } }; myLoginTextField.getDocument().addDocumentListener(listener); myPasswordField.getDocument().addDocumentListener(listener); mySignupTextField.setText( "<html>Do not have an account at github.com? <a href=\"https://github.com\">Sign up</a>.</html>"); mySignupTextField.setMargin(new Insets(5, 0, 0, 0)); mySignupTextField.addHyperlinkListener( new HyperlinkAdapter() { @Override protected void hyperlinkActivated(final HyperlinkEvent e) { BrowserUtil.browse(e.getURL()); } }); mySignupTextField.setBackground(UIUtil.TRANSPARENT_COLOR); mySignupTextField.setCursor(new Cursor(Cursor.HAND_CURSOR)); }
/** * Returns a JPanel that represents the mancala board using strategy pattern to insert style. * * @param strat concrete strategy * @return JPanel containing both users' pits as controllers */ public JPanel boardContextDoWork(Strategy strat) { this.s = strat; Color boardColor = s.getBoardColor(); Color fontColor = s.getFontColor(); Font font = s.getFont(); JPanel panCenter = new JPanel(); JPanel panLeft = new JPanel(); JPanel panRight = new JPanel(); panCenter.setLayout(new GridLayout(2, 6, 10, 10)); // B6 to B1 Controllers for (int i = 12; i > 6; i--) { final Pits temp = new Pits(i); final int pit = i; final JLabel tempLabel = new JLabel(temp); tempLabel.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { if (Model.player == 1) { JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, "Player A's turn!"); } else if (model.data[pit] == 0) { JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, "Pit is Empty try another one."); } else { if (temp.pitShape.contains(e.getPoint())) { model.move(pit); // mutator undoBtn.setText("Undo : " + model.getUndoCounter()); model.display(); } } } }); JPanel tempPanel = new JPanel(new BorderLayout()); JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setBackground(boardColor); textPane.setForeground(fontColor); textPane.setFont(font); textPane.setText("B" + (i - 6)); StyledDocument doc = textPane.getStyledDocument(); SimpleAttributeSet center = new SimpleAttributeSet(); StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); doc.setParagraphAttributes(0, doc.getLength(), center, false); tempPanel.add(textPane, BorderLayout.NORTH); tempPanel.add(tempLabel, BorderLayout.SOUTH); panCenter.add(tempPanel, BorderLayout.SOUTH); tempPanel.setBackground(boardColor); } // A1 to A6 Controllers for (int i = 0; i < 6; i++) { final Pits newPits = new Pits(i); JLabel label = new JLabel(newPits); final int pit = i; label.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { if (Model.player == 2) { JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, "Player B's turn!"); } else if (model.data[pit] == 0) { JFrame frame = new JFrame(); JOptionPane.showMessageDialog(frame, "Pit is Empty try another one."); } else { if (newPits.pitShape.contains(e.getPoint())) { model.move(pit); // mutator undoBtn.setText("Undo : " + model.getUndoCounter()); model.display(); } } } }); JPanel tempPanel = new JPanel(new BorderLayout()); tempPanel.add(label, BorderLayout.NORTH); JTextPane textPane = new JTextPane(); textPane.setBackground(boardColor); textPane.setForeground(fontColor); textPane.setFont(font); textPane.setEditable(false); textPane.setText("A" + (i + 1)); StyledDocument doc = textPane.getStyledDocument(); SimpleAttributeSet center = new SimpleAttributeSet(); StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); doc.setParagraphAttributes(0, doc.getLength(), center, false); tempPanel.add(textPane, BorderLayout.SOUTH); tempPanel.setBackground(boardColor); panCenter.add(tempPanel, BorderLayout.SOUTH); } // left text pane JTextPane paneLeft = new JTextPane(); paneLeft.setBackground(boardColor); paneLeft.setForeground(fontColor); paneLeft.setFont(font); paneLeft.setEditable(false); paneLeft.setText("M\nA\nN\nC\nA\nL\nA\n \nB"); // right text pane JTextPane paneRight = new JTextPane(); paneRight.setBackground(boardColor); paneRight.setForeground(fontColor); paneRight.setFont(font); paneRight.setEditable(false); paneRight.setText("M\nA\nN\nC\nA\nL\nA\n \nA"); // Add text panes to left and right panels panLeft.setLayout(new BorderLayout()); panRight.setLayout(new BorderLayout()); panLeft.add(paneLeft, BorderLayout.WEST); panRight.add(paneRight, BorderLayout.EAST); panLeft.add(new JLabel(new Pits(13)), BorderLayout.EAST); panRight.add(new JLabel(new Pits(6)), BorderLayout.WEST); // add the 2 mancala panels and pit panel to larger displayPanel JPanel displayPanel = new JPanel(); displayPanel.add(panLeft, BorderLayout.WEST); displayPanel.add(panCenter, BorderLayout.CENTER); displayPanel.add(panRight, BorderLayout.EAST); // set color panCenter.setBackground(boardColor); panLeft.setBackground(boardColor); panRight.setBackground(boardColor); displayPanel.setBackground(boardColor); // return display panel which contains the containers and elements created return displayPanel; }
public static void ConfigureMainWindow() { userNameLabel.setFont(new Font("Lucida Console", 0, 14)); userNameLabel.setForeground(new Color(255, 255, 255)); mainWindow.getContentPane().setBackground(new Color(4, 3, 10)); mainWindow.setSize(800, 600); mainWindow.getContentPane().setLayout(null); connectButton.setBackground(new Color(255, 255, 255)); connectButton.setForeground(new Color(4, 3, 10)); connectButton.setFont(new Font("Lucida Console", 0, 14)); connectButton.setText("Anslut"); connectButton.setToolTipText(""); mainWindow.getContentPane().add(connectButton); connectButton.setBounds(455, 10, 100, 25); conversation.setColumns(20); conversation.setFont(new Font("Lucida Console", 0, 14)); conversation.setForeground(new Color(4, 3, 10)); conversation.setLineWrap(true); conversation.setRows(5); // conversation.setEditable(false); tpConversation.setForeground(new Color(255, 255, 255)); tpConversation.setBounds(10, 10, 600, 500); tpConversation.setBackground(new Color(4, 3, 10)); tpConversation.setFont(new Font("Lucida Console", 0, 14)); spConversation.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); spConversation.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); spConversation.setViewportView(tpConversation); mainWindow.getContentPane().add(spConversation); spConversation.setBounds(10, 10, 600, 500); userNameBox.setBounds(120, 10, 325, 25); userNameLabel.setBounds(10, 10, 130, 25); mainWindow.getContentPane().add(userNameBox); mainWindow.getContentPane().add(userNameLabel); usersOnline.setForeground(new Color(0, 180, 255)); usersOnline.setBackground(new Color(4, 3, 10)); usersOnline.setFont(new Font("Lucida Console", 0, 14)); spUsersOnline.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); spUsersOnline.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); spUsersOnline.setViewportView(usersOnline); mainWindow.getContentPane().add(spUsersOnline); spUsersOnline.setBounds(620, 10, 165, 300); messageField.setForeground(new Color(255, 255, 255)); messageField.setBackground(new Color(4, 3, 10)); messageField.requestFocus(); messageField.addActionListener(action); mainWindow.getContentPane().add(messageField); messageField.setBounds(10, 520, 600, 30); send.setBackground(new Color(255, 255, 255)); send.setForeground(new Color(4, 3, 10)); send.setText("Skicka"); send.setFont(new Font("Lucida Console", 0, 14)); mainWindow.getContentPane().add(send); send.setBounds(620, 520, 165, 30); disconnect.setBackground(new Color(255, 255, 255)); disconnect.setForeground(new Color(4, 3, 10)); disconnect.setText("Avsluta chatten"); disconnect.setFont(new Font("Lucida Console", 0, 14)); mainWindow.getContentPane().add(disconnect); disconnect.setBounds(620, 320, 165, 30); error.setFont(new Font("Lucida Console", 0, 14)); error.setForeground(new Color(255, 0, 23)); error.setBounds(120, 40, 525, 25); mainWindow.getContentPane().add(error); }
private JPanel createCentrePanel(YDataStateException exception) { XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); JPanel centrePanel = new JPanel(new GridLayout(1, 2)); JPanel schemaPanel = new JPanel(new BorderLayout()); schemaPanel.setBackground(YAdminGUI._apiColour); schemaPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Schema for completing task"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane schemaTextPane = new JTextPane(); schemaTextPane.setContentType("text/xml"); schemaTextPane.setFont(new Font("courier", Font.PLAIN, 12)); String schemaXML = xmlOut.outputString(exception.getSchema()); /** AJH: Trap various XML format errors gracefully. */ try { String xml = schemaXML.substring(schemaXML.indexOf('<'), schemaXML.lastIndexOf("</xsd:schema>") + 13); schemaTextPane.setText(xml); } catch (Exception e) { schemaTextPane.setText(schemaXML); } schemaTextPane.setEditable(false); schemaTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel = new JPanel(); noWrapPanel.setLayout(new BorderLayout()); noWrapPanel.add(schemaTextPane); schemaPanel.add(new JScrollPane(noWrapPanel)); JPanel rightPanel = new JPanel(new GridLayout(2, 1)); JPanel dataPanel = new JPanel(new BorderLayout()); dataPanel.setBackground(YAdminGUI._apiColour); dataPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "The data that failed to validate"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane dataTextPane = new JTextPane(); dataTextPane.setContentType("text/xml"); dataTextPane.setFont(new Font("courier", Font.PLAIN, 12)); String data = xmlOut.outputString(exception.get_dataInput()); /** AJH: Trap various XML format errors gracefully. */ try { String temp = data.substring(data.lastIndexOf("<?xml"), data.lastIndexOf('>')); dataTextPane.setText(temp); } catch (Exception e) { dataTextPane.setText(data); } dataTextPane.setEditable(false); dataTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel2 = new JPanel(); noWrapPanel2.setLayout(new BorderLayout()); noWrapPanel2.add(dataTextPane); dataPanel.add(new JScrollPane(noWrapPanel2)); JPanel errorPanel = new JPanel(new BorderLayout()); errorPanel.setBackground(YAdminGUI._apiColour); errorPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "The error message from validation engine"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane errorTextPane = new JTextPane(); errorTextPane.setContentType("text/plain"); errorTextPane.setFont(new Font("courier", Font.PLAIN, 12)); /** AJH: Trap various XML format errors gracefully. */ try { String error = schemaXML.substring(schemaXML.lastIndexOf("ERRORS ="), schemaXML.length()); errorTextPane.setText(error); } catch (Exception e) { // null action ! } errorTextPane.setText(exception.getErrors()); errorTextPane.setEditable(false); errorTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel3 = new JPanel(); noWrapPanel3.setLayout(new BorderLayout()); noWrapPanel3.add(errorTextPane); errorPanel.add(new JScrollPane(noWrapPanel3)); rightPanel.add(dataPanel); rightPanel.add(errorPanel); centrePanel.add(schemaPanel, BorderLayout.NORTH); centrePanel.add(rightPanel, BorderLayout.CENTER); return centrePanel; }