Java Code Examples for javax.swing.JTextArea#append()
The following examples show how to use
javax.swing.JTextArea#append() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * GUI������������ */ private void initGUI() { setLayout(new BorderLayout()); // ���b�Z�[�W����\���G���A dialogueArea = new JTextArea(); dialogueArea.setEditable(false); dialogueArea.setLineWrap(true); dialogueArea.append("�l�H���]�v���g�^�C�v\n\n"); // ���b�Z�[�W���̓t�B�[���h inputField = new JTextField("���b�Z�[�W����͂��Ă�������"); inputField.selectAll(); // �p�l���ɒlj� JScrollPane scrollPane = new JScrollPane(dialogueArea); scrollPane.setAutoscrolls(true); add(scrollPane, BorderLayout.CENTER); add(inputField, BorderLayout.SOUTH); inputField.addActionListener(this); }
Example 2
Source File: ClientGui.java From logging-log4j2 with Apache License 2.0 | 6 votes |
private void addWidgetForLoggerContext(final LoggerContextAdminMBean ctx) throws MalformedObjectNameException, IOException, InstanceNotFoundException { final JTabbedPane contextTabs = new JTabbedPane(); contextObjNameToTabbedPaneMap.put(ctx.getObjectName(), contextTabs); tabbedPaneContexts.addTab("LoggerContext: " + ctx.getName(), contextTabs); final String contextName = ctx.getName(); final StatusLoggerAdminMBean status = client.getStatusLoggerAdmin(contextName); if (status != null) { final JTextArea text = createTextArea(); final String[] messages = status.getStatusDataHistory(); for (final String message : messages) { text.append(message + '\n'); } statusLogTextAreaMap.put(ctx.getObjectName(), text); registerListeners(status); final JScrollPane scroll = scroll(text); contextTabs.addTab("StatusLogger", scroll); } final ClientEditConfigPanel editor = new ClientEditConfigPanel(ctx); contextTabs.addTab("Configuration", editor); }
Example 3
Source File: ClientGui.java From logging-log4j2 with Apache License 2.0 | 6 votes |
private void handleNotificationInAwtEventThread(final Notification notif, final Object paramObject) { if (StatusLoggerAdminMBean.NOTIF_TYPE_MESSAGE.equals(notif.getType())) { if (!(paramObject instanceof ObjectName)) { handle("Invalid notification object type", new ClassCastException(paramObject.getClass().getName())); return; } final ObjectName param = (ObjectName) paramObject; final JTextArea text = statusLogTextAreaMap.get(param); if (text != null) { text.append(notif.getMessage() + '\n'); } return; } if (notif instanceof MBeanServerNotification) { final MBeanServerNotification mbsn = (MBeanServerNotification) notif; final ObjectName mbeanName = mbsn.getMBeanName(); if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notif.getType())) { onMBeanRegistered(mbeanName); } else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(notif.getType())) { onMBeanUnregistered(mbeanName); } } }
Example 4
Source File: PanelLogging.java From java-ocr-api with GNU Affero General Public License v3.0 | 6 votes |
private static void logAndScrollToBottom(final JTextArea textArea, final String mesg) { if(! SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { logAndScrollToBottom(textArea, mesg); } }); return; } textArea.append(textArea.getText().length() == 0 ? mesg : "\n" + mesg); String text = textArea.getText(); if(text.length() > 2) { int lastLinePos = text.lastIndexOf("\n", text.length() - 2); if(lastLinePos > 0) { textArea.setCaretPosition(lastLinePos + 1); } } }
Example 5
Source File: ShareAlbumToolPanel.java From java-photoslibrary with Apache License 2.0 | 6 votes |
private JTextArea getMetadataTextArea(Album album) { JTextArea metadataTextArea = new JTextArea(); metadataTextArea.setBorder(METADATA_BORDER); metadataTextArea.setLayout( new GridLayout(2 /* rows */, 1 /* cols */, 0 /* unset hgap */, 10 /* vgap */)); metadataTextArea.setEditable(false); metadataTextArea.setLineWrap(true); metadataTextArea.append(String.format("URL: %s", album.getProductUrl())); if (album.hasShareInfo()) { metadataTextArea.append( String.format("\nShare URL: %s", album.getShareInfo().getShareableUrl())); metadataTextArea.append( String.format("\nShare Token: %s", album.getShareInfo().getShareToken())); } return metadataTextArea; }
Example 6
Source File: TipsDialog.java From sc2gears with Apache License 2.0 | 6 votes |
/** * Creates a new TipsDialog. */ public TipsDialog() { super( "tips.title", Icons.LIGHT_BULB ); final JTextArea tipsTextArea = new JTextArea( 25, 65 ); tipsTextArea.setEditable( false ); tipsTextArea.setLineWrap( true ); tipsTextArea.setWrapStyleWord( true ); // Set tips as text for ( int i = 1; i <= StartPage.TIPS_COUNT; i++ ) tipsTextArea.append( "\n" + i + ". " + Language.getText( "module.startPage.tip." + i ) + "\n" ); tipsTextArea.setCaretPosition( 0 ); final JScrollPane scrollPane = new JScrollPane( tipsTextArea ); scrollPane.setBorder( BorderFactory.createEmptyBorder( 15, 15, 15, 15 ) ); getContentPane().add( scrollPane, BorderLayout.CENTER ); final JPanel buttonsPanel = new JPanel(); buttonsPanel.setBorder( BorderFactory.createEmptyBorder( 0, 15, 10, 15 ) ); final JButton closeButton = createCloseButton( "button.close" ); buttonsPanel.add( closeButton ); getContentPane().add( buttonsPanel, BorderLayout.SOUTH ); packAndShow( closeButton, false ); }
Example 7
Source File: LicenseDialog.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor */ public LicenseDialog(final Window parent) { super(parent, Resources.getLabel("license.button"), ModalityType.APPLICATION_MODAL); getContentPane().add(createHeaderPanel(false, null), BorderLayout.NORTH); final JTextArea license = new JTextArea(30, 50); license.setEditable(false); // read the license file and add its content to the JTextArea for (final String line : Util.readUTF8File(Resources.class.getResourceAsStream("/" + Resources.RESOURCE_PATH + "/License.txt"))) { license.append(" " + line + "\n"); } // scroll to the top of the JTextArea license.setCaretPosition(0); // the all thing in a ScrollPane final JScrollPane scroll = new JScrollPane(license); getContentPane().add(scroll, BorderLayout.CENTER); final JPanel donatePanel = new JPanel(new BorderLayout(5, 10)); final JLabel donate = new JLabel(Resources.getLabel("donate")); donatePanel.add(donate, BorderLayout.NORTH); final JPanel center = new JPanel(); center.setLayout(new FlowLayout()); center.add(new JLabel(Resources.getImageIcon("donate.png"))); center.add(new HyperlinkLabel(Resources.getLabel("donate.label"), Env.INSTANCE.getDonateUrl())); donatePanel.add(center, BorderLayout.CENTER); final JButton close = new JButton(Resources.getLabel("close.button")); close.addActionListener(e -> LicenseDialog.this.dispose()); donatePanel.add(close, BorderLayout.SOUTH); getContentPane().add(donatePanel, BorderLayout.SOUTH); SwingUtilities4.setUp(this); getRootPane().registerKeyboardAction(e -> dispose(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); }
Example 8
Source File: JScrollPane457.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { test = new JScrollPane457(); test.setBorder(new TitledBorder(new EtchedBorder(), "Text Area")); textArea = new JTextArea(25, 80); textArea.setEditable(false); for (int i = 0; i < NUMBER_OF_LINES; i++) { textArea.append("line " + i + " 1234567890qwertyuiopasdfghjklzxcvbnm 1234567890qwertyuiopasdfghjklzxcvbnm\n"); } JScrollPane scroll = new JScrollPane(textArea); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); test.add(scroll); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); frame = new JFrame("OGLTR_DisableGlyphModeState test"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(1000, 1000); frame.add(test); frame.pack(); frame.setVisible(true); }
Example 9
Source File: LearnView.java From iBioSim with Apache License 2.0 | 5 votes |
public void viewLog() { try { if (new File(directory + File.separator + "run.log").exists()) { File log = new File(directory + File.separator + "run.log"); FileInputStream input = new FileInputStream(log); JTextArea messageArea = new JTextArea(); int read = -1; while ((read = input.read()) != -1) { messageArea.append("" + (char) read); } input.close(); messageArea.setEditable(false); JScrollPane scrolls = new JScrollPane(); scrolls.setMinimumSize(new Dimension(500, 500)); scrolls.setPreferredSize(new Dimension(500, 500)); scrolls.setViewportView(messageArea); JOptionPane.showMessageDialog(Gui.frame, scrolls, "Run Log", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(Gui.frame, "No run log exists.", "Error", JOptionPane.ERROR_MESSAGE); } } catch (Exception e1) { JOptionPane.showMessageDialog(Gui.frame, "Unable to view run log.", "Error", JOptionPane.ERROR_MESSAGE); } }
Example 10
Source File: SimpleApp.java From jmkvpropedit with BSD 2-Clause "Simplified" License | 5 votes |
private final void initializeTextArea(String[] args) { JTextArea textArea = new JTextArea(); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); getContentPane().add(scrollPane); textArea.setText(getMainProperties(args)); textArea.append(getAllProperties()); textArea.append(getEnvironmentVariables()); }
Example 11
Source File: VerificationView.java From iBioSim with Apache License 2.0 | 5 votes |
public void viewLog() { try { if (new File(directory + File.separator + "run.log").exists()) { File log = new File(directory + File.separator + "run.log"); BufferedReader input = new BufferedReader(new FileReader(log)); String line = null; JTextArea messageArea = new JTextArea(); while ((line = input.readLine()) != null) { messageArea.append(line); messageArea.append(System.getProperty("line.separator")); } input.close(); messageArea.setLineWrap(true); messageArea.setWrapStyleWord(true); messageArea.setEditable(false); JScrollPane scrolls = new JScrollPane(); scrolls.setMinimumSize(new Dimension(500, 500)); scrolls.setPreferredSize(new Dimension(500, 500)); scrolls.setViewportView(messageArea); JOptionPane.showMessageDialog(Gui.frame, scrolls, "Run Log", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(Gui.frame, "No run log exists.", "Error", JOptionPane.ERROR_MESSAGE); } } catch (Exception e1) { JOptionPane.showMessageDialog(Gui.frame, "Unable to view run log.", "Error", JOptionPane.ERROR_MESSAGE); } }
Example 12
Source File: ReplAgGUI.java From jason with GNU Lesser General Public License v3.0 | 4 votes |
void initGui() { Font font = new Font("Courier", Font.PLAIN, 14); command = new JTextField(40); command.setFont(font); command.setToolTipText("Type a Jason operation here."); command.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { execCmd(command.getText().trim()); } }); //mindPanel = new JTextPane(); //mindPanel.setEditable(false); //mindPanel.setContentType("text/html"); output = new JTextArea(5,50); output.setFont(font); output.setEditable(false); output.setText("Example of operations you can type:\n +bel; !goal; .add_plan({+!goal <- .print(ok) }); !!goal; \n .send(bob,tell,hello);\n"); output.append(" ?bel(A); .findall(X,bel(X),L); \n"); output.append(" .mi // to open mind inspector\n"); output.append(" .verbose(2) // to show debug messages\n"); output.append(" .clear // clean console\n"); output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console."); output.append("\n"); frame = new JFrame(".:: REPL Interface for "+getTS().getAgArch().getAgName()+" ::."); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(BorderLayout.NORTH,command); //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel)); frame.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output)); frame.pack(); int h = 200; int w = (int)(h*2*1.618); frame.setBounds((int)(h*0.618), 20, w, h); frame.setLocation(lastPos, 200+lastPos); lastPos += 50; frame.setVisible(true); }
Example 13
Source File: Benchmark.java From marvinproject with GNU Lesser General Public License v3.0 | 4 votes |
public void process(MarvinImage image){ JFrame result = new JFrame("BenchMark"); JTextArea text = new JTextArea(); result.add(text); MarvinImagePlugin tempPlugin; MarvinImage imageOut; long time, totalTime; text.append(""+new Date(System.currentTimeMillis()).toString()); text.append("\nimage width:"+image.getWidth()); text.append("\nimage height:"+image.getHeight()); text.append("\nNUM_EXECUTIONS:"+NUM_EXECUTIONS); text.append("\n\n"); long timeByPlugin[][] = new long[plugins.size()][]; for(int i=0; i<plugins.size(); i++){ timeByPlugin[i] = new long[NUM_EXECUTIONS]; } totalTime = System.currentTimeMillis(); for(int i=0; i<plugins.size(); i++){ for(int e=0; e<NUM_EXECUTIONS; e++){ tempPlugin = (MarvinImagePlugin)plugins.get(i); tempPlugin.load(); imageOut = new MarvinImage(image.getWidth(), image.getHeight()); time = System.currentTimeMillis(); tempPlugin.process(image, imageOut, null, MarvinImageMask.NULL_MASK, false); timeByPlugin[i][e] = (System.currentTimeMillis()-time); System.out.print("."); } } System.out.println("FINISHED"); long avgTime; for(int i=0; i<plugins.size(); i++){ avgTime=0; for(int e=0; e<NUM_EXECUTIONS; e++){ avgTime += timeByPlugin[i][e]; } avgTime /= NUM_EXECUTIONS; text.append("\nPlugin:"+plugins.get(i).getClass().getSimpleName()+" - Avarage time:"+avgTime); } text.append("\n\n total time:"+(System.currentTimeMillis()-totalTime)); result.setSize(600,500); result.setVisible(true); }
Example 14
Source File: ReplayRenameDialog.java From sc2gears with Apache License 2.0 | 4 votes |
/** * Creates a new ReplayRenameDialog. * @param replayOpCallback optional callback that has to be called upon file changes * @param files files to operate on */ public ReplayRenameDialog( final ReplayOpCallback replayOpCallback, final File[] files ) { super( "replayops.renameDialog.title", Icons.DOCUMENT_RENAME ); final JPanel editorPanel = new JPanel( new BorderLayout() ); editorPanel.setBorder( BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) ); final JComboBox< String > nameTemplateComboBox = GuiUtils.createPredefinedListComboBox( PredefinedList.REP_RENAME_TEMPLATE ); nameTemplateComboBox.setSelectedItem( Settings.getString( Settings.KEY_REP_SEARCH_RESULTS_RENAME_TEMPLATE ) ); editorPanel.add( GuiUtils.createNameTemplateEditor( nameTemplateComboBox, Symbol.REPLAY_COUNTER ), BorderLayout.CENTER ); final JPanel buttonsPanel = new JPanel(); final JButton previewButton = new JButton(); GuiUtils.updateButtonText( previewButton, "replayops.renameDialog.previewButton" ); buttonsPanel.add( previewButton ); final JButton renameButton = new JButton(); GuiUtils.updateButtonText( renameButton, "replayops.renameDialog.renameButton" ); buttonsPanel.add( renameButton ); final JButton cancelButton = createCloseButton( "button.cancel" ); buttonsPanel.add( cancelButton ); editorPanel.add( buttonsPanel, BorderLayout.SOUTH ); getContentPane().add( editorPanel, BorderLayout.NORTH ); final JTextArea previewTextArea = new JTextArea( 10, 50 ); previewTextArea.setEditable( false ); getContentPane().add( new JScrollPane( previewTextArea ), BorderLayout.CENTER ); final ActionListener renameActionListener = new ActionListener() { @Override public void actionPerformed( final ActionEvent event ) { final boolean preview = event.getSource() == previewButton; if ( preview ) previewTextArea.setText( "" ); int errorCounter = 0; try { final TemplateEngine templatEngine = new TemplateEngine( nameTemplateComboBox.getSelectedItem().toString() ); for ( int fileIndex = 0; fileIndex < files.length; fileIndex++ ) { final File file = files[ fileIndex ]; final String newName = templatEngine.applyToReplay( file, file.getParentFile() ); if ( newName == null ) { errorCounter++; continue; } if ( preview ) previewTextArea.append( newName + "\n" ); else { if ( newName.equals( file.getName() ) ) continue; // Same name, no need to rename (and if we would proceed, we would wrongly append something like " (2)" at the end of it... final File destinationFile = GeneralUtils.generateUniqueName( new File( file.getParent(), newName ) ); // Create potential sub-folders specified by the name template final File parentOfDestinationFile = destinationFile.getParentFile(); boolean failedToCreateSubfolders = false; if ( !parentOfDestinationFile.exists() ) failedToCreateSubfolders = !parentOfDestinationFile.mkdirs(); if ( file.renameTo( destinationFile ) ) { if ( replayOpCallback != null ) replayOpCallback.replayRenamed( file, destinationFile, fileIndex ); } else { System.out.println( "Failed to rename replay file" + ( destinationFile.exists() ? " (target file already exists)" : failedToCreateSubfolders ? " (failed to create sub-folders)" : "" ) + "!" ); errorCounter++; } } } } catch ( final Exception e ) { e.printStackTrace(); GuiUtils.showErrorDialog( Language.getText( "replayops.renameDialog.invalidTemplate", e.getMessage() ) ); return; } finally { nameTemplateComboBox.requestFocusInWindow(); } if ( preview ) previewTextArea.setCaretPosition( 0 ); else { if ( replayOpCallback != null ) replayOpCallback.moveRenameDeleteEnded(); // Template is valid here, so we can store it Settings.set( Settings.KEY_REP_SEARCH_RESULTS_RENAME_TEMPLATE, nameTemplateComboBox.getSelectedItem().toString() ); if ( errorCounter == 0 ) GuiUtils.showInfoDialog( Language.getText( "replayops.renameDialog.successfullyRenamed", files.length ) ); else GuiUtils.showErrorDialog( new Object[] { Language.getText( "replayops.renameDialog.successfullyRenamed", files.length - errorCounter ), Language.getText( "replayops.renameDialog.failedToRename", errorCounter ) } ); dispose(); } } }; previewButton.addActionListener( renameActionListener ); renameButton .addActionListener( renameActionListener ); previewButton.doClick(); packAndShow( nameTemplateComboBox, false ); }
Example 15
Source File: GuiUtils.java From sc2gears with Apache License 2.0 | 4 votes |
/** * Appends a line and a new line to a text area. * @param textArea text area to append to * @param line line to be appended */ public static void appendNewLine( final JTextArea textArea, final String line ) { textArea.append( line ); textArea.append( "\n" ); textArea.setCaretPosition( textArea.getDocument().getLength() ); }
Example 16
Source File: GuiUtils.java From sc2gears with Apache License 2.0 | 4 votes |
/** * Appends a timestamp, a line and a new line to a text area. * @param textArea text area to append to * @param line line to be appended */ public static void appendNewLineWithTimestamp( final JTextArea textArea, final String line ) { textArea.append( Language.formatDateTime( new Date() ) ); textArea.append( " - " ); appendNewLine( textArea, line ); }
Example 17
Source File: ExceptionDialog.java From dualsub with GNU General Public License v3.0 | 4 votes |
private void initComponents() { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(I18N.getText("Window.name.text")); // Features this.setResizable(false); getContentPane().setLayout(null); this.getContentPane().setBackground(parent.getBackground()); JLabel lblTitle = new JLabel(I18N.getText("ExceptionDialog.text.01")); lblTitle.setFont(new Font("Lucida", Font.BOLD, 20)); lblTitle.setBounds(29, 21, 435, 25); getContentPane().add(lblTitle); JLabel lblContent01 = new JLabel( I18N.getHtmlText("ExceptionDialog.text.02")); lblContent01.setBounds(29, 69, 435, 50); getContentPane().add(lblContent01); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(28, 130, 435, 150); getContentPane().add(scrollPane); JTextArea textArea = new JTextArea(); scrollPane.setViewportView(textArea); textArea.append(exception.getClass() + ":" + exception.getMessage() + "\n"); StackTraceElement[] stack = exception.getStackTrace(); for (StackTraceElement s : stack) { textArea.append(" " + s.toString() + "\n"); } JLabel lblContent02 = new JLabel( I18N.getHtmlText("ExceptionDialog.text.03")); lblContent02.setBounds(29, 290, 435, 90); getContentPane().add(lblContent02); // Borders (for debug purposes) if (log.isTraceEnabled()) { Border border = BorderFactory.createLineBorder(Color.black); lblTitle.setBorder(border); lblContent01.setBorder(border); lblContent02.setBorder(border); } }
Example 18
Source File: UnitInfoPanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void init(String unitName, String unitType, String unitDescription) { setOpaque(false); setLayout(new BorderLayout(10, 20)); // this.setSize(350, 400); // undecorated 301, 348 ; decorated : 303, 373 JPanel mainPanel = new JPanel(new FlowLayout());// new BorderLayout()); mainPanel.setOpaque(false); mainPanel.setBackground(new Color(0, 0, 0, 128)); // setMinimumSize() this.add(mainPanel, BorderLayout.NORTH); JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout()); westPanel.setOpaque(false); westPanel.setBackground(new Color(0, 0, 0, 128)); // setMinimumSize() this.add(westPanel, BorderLayout.WEST); JPanel eastPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout()); eastPanel.setOpaque(false); eastPanel.setBackground(new Color(0, 0, 0, 128)); // setMinimumSize() this.add(eastPanel, BorderLayout.EAST); // Creating the text Input JTextField tf1 = new JTextField("", 15); tf1.setHorizontalAlignment(JTextField.CENTER); tf1.setOpaque(false); tf1.setFocusable(false); tf1.setBackground(new Color(92, 83, 55, 128)); tf1.setColumns(20); Border border = BorderFactory.createLineBorder(Color.gray, 2); tf1.setBorder(border); tf1.setText(unitName); tf1.setForeground(Color.BLACK); tf1.setFont(new Font("Arial", Font.BOLD, 14)); mainPanel.add(tf1); JTextArea ta = new JTextArea(); String type = "TYPE: "; String description = "DESCRIPTION: "; ta.setLineWrap(true); ta.setFocusable(false); ta.setWrapStyleWord(true); ta.setText(type + "\n"); ta.append(unitType + "\n\n"); ta.append(description + "\n"); ta.append(unitDescription); ta.setCaretPosition(0); ta.setEditable(false); ta.setForeground(Color.black); ta.setFont(new Font("Dialog", Font.PLAIN, 14)); ta.setOpaque(false); ta.setBackground(new Color(92, 83, 55, 128)); CustomScroll scr = new CustomScroll(ta); scr.setSize(PopUpUnitMenu.D_WIDTH - 50 , PopUpUnitMenu.D_HEIGHT); add(scr, BorderLayout.CENTER); JPanel southPanel = new JPanel(); add(southPanel, BorderLayout.SOUTH); southPanel.setOpaque(false); southPanel.setBackground(new Color(0, 0, 0, 128)); setVisible(true); }
Example 19
Source File: Main.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
public static void consolePrint(JTextArea console, String text) { console.append(text); console.setCaretPosition(console.getDocument().getLength()); console.requestFocus(); }
Example 20
Source File: PressureClientTool.java From game-server with MIT License | 4 votes |
public PressureClientTool(int clientNum, String userNamePrefix, String password, String clusterIp,JTextArea logTextArea) { this.clientNum = clientNum; this.clusterIp = clusterIp; this.userNamePrefix = userNamePrefix; initConfigPath(); ScriptManager.getInstance().init(null); //循环初始化客户端 try { for (int i = 0; i < clientNum; i++) { PressureClientHandler pressureClientHandler = new PressureClientHandler(); MinaClientConfig minaClientConfig = getMinaClientConfig(); String userName = userNamePrefix + userNameNo.incrementAndGet(); // TCP // 添加ssl Map<String, IoFilter> filters = new HashMap<>(); SslFilter sslFilter = new SslFilter(ClientSslContextFactory.getInstance(false)); sslFilter.setUseClientMode(true); // filters.put("ssl", sslFilter); SingleMinaTcpClientService service = new SingleMinaTcpClientService(minaClientConfig, new ClientProtocolCodecFactory(), pressureClientHandler, filters); pressureClientHandler.setService(service); new Thread(service).start(); // UDP MinaClientConfig minaClientConfig2 = new MinaClientConfig(); MinaClienConnToConfig connTo = new MinaClienConnToConfig(); connTo.setHost(minaClientConfig.getConnTo().getHost()); connTo.setPort(8004); minaClientConfig2.setConnTo(connTo); MinaUdpClient udpClient = new MinaUdpClient(minaClientConfig2, pressureClientHandler, new ClientProtocolCodecFactory()); new Thread(udpClient).start(); while (udpClient.getSession() == null) { Thread.sleep(MathUtil.random(500, 3000)); } Player player = new Player(); player.setUserName(userName); player.setPassword(password); player.setUdpSession(udpClient.getSession()); player.setTcpSession(service.getMostIdleIoSession()); player.setLogTextArea(logTextArea); if(player.getTcpSession()==null||player.getUdpSession()==null){ LOGGER.warn("用户{}连接服务器失败",userName); logTextArea.append(String.format("用户%s连接服务器失败\n",userName)); continue; } player.loginInit(); players.put(userName, player); new PressureServiceThread(player).start(); } } catch (Exception e) { LOGGER.error("PressureClientTool", e); } }