/** Constructs the <tt>AuthenticationWindow</tt>. */ private void init() { this.idValue = new JTextField( chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID()); this.infoTextArea.setOpaque(false); this.infoTextArea.setLineWrap(true); this.infoTextArea.setWrapStyleWord(true); this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD)); this.infoTextArea.setEditable(false); this.infoTextArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.CHAT_ROOM_REQUIRES_PASSWORD", new String[] {chatRoom.getChatRoomName()})); this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD)); this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD)); this.labelsPanel.add(idLabel); this.labelsPanel.add(passwdLabel); this.textFieldsPanel.add(idValue); this.textFieldsPanel.add(passwdField); this.buttonsPanel.add(loginButton); this.buttonsPanel.add(cancelButton); this.mainPanel.add(infoTextArea, BorderLayout.NORTH); this.mainPanel.add(labelsPanel, BorderLayout.WEST); this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER); this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH); this.backgroundPanel.add(mainPanel, BorderLayout.CENTER); this.loginButton.setName("ok"); this.cancelButton.setName("cancel"); this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK")); this.cancelButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); this.loginButton.addActionListener(this); this.cancelButton.addActionListener(this); this.getRootPane().setDefaultButton(loginButton); this.setTransparent(true); }
// counts lines public static int countLines(JTextArea textArea) { AttributedString text = new AttributedString(textArea.getText()); FontRenderContext frc = textArea.getFontMetrics(textArea.getFont()).getFontRenderContext(); int lines = 0; if (!textArea.getText().equals("")) { AttributedCharacterIterator charIt = text.getIterator(); LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(charIt, frc); float formatWidth = (float) textArea.getSize().width; lineMeasurer.setPosition(charIt.getBeginIndex()); while (lineMeasurer.getPosition() < charIt.getEndIndex()) { lineMeasurer.nextLayout(formatWidth); lines++; } for (int i = 0; i < textArea.getText().length(); i++) { if (textArea.getText().charAt(i) == '\r' || textArea.getText().charAt(i) == '\n') lines++; } } else { lines = 1; } return lines; }
/** * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR * call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { rootPanel = new JPanel(); rootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); final JToolBar toolBar1 = new JToolBar(); rootPanel.add( toolBar1, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 20), null, 0, false)); openSrcButton = new JButton(); openSrcButton.setText("Open Src"); openSrcButton.setToolTipText("Open source file"); toolBar1.add(openSrcButton); openBinButton = new JButton(); openBinButton.setEnabled(true); openBinButton.setText("Open Bin"); openBinButton.setToolTipText("Open and disassemble binaries"); toolBar1.add(openBinButton); saveSrcButton = new JButton(); saveSrcButton.setEnabled(true); saveSrcButton.setText("Save Src"); saveSrcButton.setToolTipText("Save sources"); toolBar1.add(saveSrcButton); saveBinButton = new JButton(); saveBinButton.setEnabled(true); saveBinButton.setText("Save Bin"); saveBinButton.setToolTipText("Save assembled binary"); toolBar1.add(saveBinButton); final JToolBar.Separator toolBar$Separator1 = new JToolBar.Separator(); toolBar1.add(toolBar$Separator1); asmButton = new JButton(); asmButton.setText("Asm"); asmButton.setToolTipText("Assemble sources"); toolBar1.add(asmButton); final JToolBar.Separator toolBar$Separator2 = new JToolBar.Separator(); toolBar1.add(toolBar$Separator2); hardResetButton = new JButton(); hardResetButton.setEnabled(true); hardResetButton.setText("Hard Reset"); hardResetButton.setToolTipText("Hard Reset - zeroize memory and reupload binary"); toolBar1.add(hardResetButton); resetButton = new JButton(); resetButton.setEnabled(true); resetButton.setText("Reset"); resetButton.setToolTipText("Reset CPU (registers to zero)"); toolBar1.add(resetButton); execButton = new JButton(); execButton.setEnabled(true); execButton.setText("Exec"); execButton.setToolTipText("Run forever"); toolBar1.add(execButton); pauseButton = new JButton(); pauseButton.setEnabled(false); pauseButton.setText("Pause"); pauseButton.setToolTipText("Pause execution"); toolBar1.add(pauseButton); runButton = new JButton(); runButton.setEnabled(true); runButton.setText("Run"); runButton.setToolTipText("Run until breakpoint/reserved"); toolBar1.add(runButton); stepButton = new JButton(); stepButton.setEnabled(true); stepButton.setText("Step"); stepButton.setToolTipText("Execute one instruction"); toolBar1.add(stepButton); final JToolBar.Separator toolBar$Separator3 = new JToolBar.Separator(); toolBar1.add(toolBar$Separator3); breakpointButton = new JButton(); breakpointButton.setEnabled(true); breakpointButton.setText("Breakpoint"); breakpointButton.setToolTipText("Toggle breakpoint on instruction address"); toolBar1.add(breakpointButton); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); rootPanel.add( panel1, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Source"); panel1.add( label1, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label2 = new JLabel(); label2.setText("Memory"); panel1.add( label2, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label3 = new JLabel(); label3.setText("Registers"); panel1.add( label3, new GridConstraints( 0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); memoryScrollPane = new JScrollPane(); panel1.add( memoryScrollPane, new GridConstraints( 1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(600, -1), null, 0, false)); memoryTable = new JTable(); memoryScrollPane.setViewportView(memoryTable); final JScrollPane scrollPane1 = new JScrollPane(); panel1.add( scrollPane1, new GridConstraints( 1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(100, -1), null, 0, false)); registersTable = new JTable(); scrollPane1.setViewportView(registersTable); sourceScrollPane = new JScrollPane(); panel1.add( sourceScrollPane, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(500, 400), null, 0, false)); sourceTextarea = new JTextArea(); sourceTextarea.setFont(new Font("Courier New", sourceTextarea.getFont().getStyle(), 12)); sourceTextarea.setText( "; Input your program here\n set a, 1\n add a, 1\n ife a, 2\n set a, 3\n:mainloop\n ife [message + I], 0\n set pc, end\n set a, [message + I]\n add a, 0xA100\n set [0x8000 + I], a\n add i, 1\n set pc, mainloop\n:message dat \"Hello, world!\", 0\n:end set pc, end"); sourceScrollPane.setViewportView(sourceTextarea); final JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); panel2.setVisible(false); rootPanel.add( panel2, new GridConstraints( 2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); consoleTextarea = new JTextArea(); consoleTextarea.setEditable(true); panel2.add( consoleTextarea, new GridConstraints( 1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 200), null, 0, false)); final JLabel label4 = new JLabel(); label4.setText("Console"); panel2.add( label4, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); clearButton = new JButton(); clearButton.setText("Clear"); panel2.add( clearButton, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel2.add( spacer1, new GridConstraints( 0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); }
/** Constructs the <tt>LoginWindow</tt>. */ private void init() { String title; if (windowTitle != null) title = windowTitle; else title = DesktopUtilActivator.getResources() .getI18NString("service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {server}); String text; if (windowText != null) text = windowText; else text = DesktopUtilActivator.getResources() .getI18NString("service.gui.AUTHENTICATION_REQUESTED_SERVER", new String[] {server}); String uinText; if (usernameLabelText != null) uinText = usernameLabelText; else uinText = DesktopUtilActivator.getResources().getI18NString("service.gui.IDENTIFIER"); String passText; if (passwordLabelText != null) passText = passwordLabelText; else passText = DesktopUtilActivator.getResources().getI18NString("service.gui.PASSWORD"); setTitle(title); infoTextArea.setEditable(false); infoTextArea.setOpaque(false); infoTextArea.setLineWrap(true); infoTextArea.setWrapStyleWord(true); infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD)); infoTextArea.setText(text); infoTextArea.setAlignmentX(0.5f); JLabel uinLabel = new JLabel(uinText); uinLabel.setFont(uinLabel.getFont().deriveFont(Font.BOLD)); JLabel passwdLabel = new JLabel(passText); passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD)); TransparentPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8)); labelsPanel.add(uinLabel); labelsPanel.add(passwdLabel); TransparentPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8)); textFieldsPanel.add(uinValue); textFieldsPanel.add(passwdField); JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2)); this.rememberPassCheckBox.setOpaque(false); this.rememberPassCheckBox.setBorder(null); southFieldsPanel.add(rememberPassCheckBox); if (signupLink != null && signupLink.length() > 0) southFieldsPanel.add( createWebSignupLabel( DesktopUtilActivator.getResources().getI18NString("plugin.simpleaccregwizz.SIGNUP"), signupLink)); else southFieldsPanel.add(new JLabel()); boolean allowRememberPassword = true; String allowRemPassStr = DesktopUtilActivator.getResources().getSettingsString(PNAME_ALLOW_SAVE_PASSWORD); if (allowRemPassStr != null) { allowRememberPassword = Boolean.parseBoolean(allowRemPassStr); } allowRememberPassword = DesktopUtilActivator.getConfigurationService() .getBoolean(PNAME_ALLOW_SAVE_PASSWORD, allowRememberPassword); setAllowSavePassword(allowRememberPassword); JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); buttonPanel.add(loginButton); buttonPanel.add(cancelButton); JPanel southEastPanel = new TransparentPanel(new BorderLayout()); southEastPanel.add(buttonPanel, BorderLayout.EAST); TransparentPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10)); mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20)); JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10)); mainFieldsPanel.add(labelsPanel, BorderLayout.WEST); mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER); mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH); mainPanel.add(infoTextArea, BorderLayout.NORTH); mainPanel.add(mainFieldsPanel, BorderLayout.CENTER); mainPanel.add(southEastPanel, BorderLayout.SOUTH); this.getContentPane().add(mainPanel, BorderLayout.EAST); this.loginButton.setName("ok"); this.cancelButton.setName("cancel"); if (loginButton.getPreferredSize().width > cancelButton.getPreferredSize().width) cancelButton.setPreferredSize(loginButton.getPreferredSize()); else loginButton.setPreferredSize(cancelButton.getPreferredSize()); this.loginButton.setMnemonic( DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.OK")); this.cancelButton.setMnemonic( DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); this.loginButton.addActionListener(this); this.cancelButton.addActionListener(this); this.getRootPane().setDefaultButton(loginButton); }
private static int getTextAreaBaseline(JTextArea text, int height) { Insets insets = text.getInsets(); FontMetrics fm = text.getFontMetrics(text.getFont()); return insets.top + fm.getAscent(); }