ThreadDetails(final Component focusGainer, KonThread thread) { mThread = thread; GroupPanel groupPanel = new GroupPanel(View.GAP_BIG, false); groupPanel.setMargin(View.MARGIN_BIG); groupPanel.add(new WebLabel(Tr.tr("Edit Chat")).setBoldFont()); groupPanel.add(new WebSeparator(true, true)); // editable fields groupPanel.add(new WebLabel(Tr.tr("Subject:"))); String subj = mThread.getSubject(); mSubjectField = new WebTextField(subj, 22); mSubjectField.setInputPrompt(subj); mSubjectField.setHideInputPromptOnFocus(false); groupPanel.add(mSubjectField); groupPanel.add(new WebSeparator(true, true)); final WebSlider colorSlider = new WebSlider(WebSlider.HORIZONTAL); groupPanel.add(new WebLabel(Tr.tr("Custom Background"))); mColorOpt = new WebRadioButton(Tr.tr("Color:") + " "); Optional<Color> optBGColor = mThread.getViewSettings().getBGColor(); mColorOpt.setSelected(optBGColor.isPresent()); mColorOpt.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { colorSlider.setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mColor = new WebButton(); mColor.setMinimumHeight(25); Color oldColor = optBGColor.orElse(DEFAULT_BG); mColor.setBottomBgColor(oldColor); groupPanel.add(new GroupPanel(GroupingType.fillLast, mColorOpt, mColor)); colorSlider.setMinimum(0); colorSlider.setMaximum(100); colorSlider.setPaintTicks(false); colorSlider.setPaintLabels(false); colorSlider.setEnabled(optBGColor.isPresent()); final GradientData gradientData = GradientData.getDefaultValue(); // TODO set location for color gradientData.getColor(0); colorSlider.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { float v = colorSlider.getValue() / (float) 100; Color c = gradientData.getColorForLocation(v); mColor.setBottomBgColor(c); mColor.repaint(); } }); groupPanel.add(colorSlider); mImgOpt = new WebRadioButton(Tr.tr("Image:") + " "); String imgPath = mThread.getViewSettings().getImagePath(); mImgOpt.setSelected(!imgPath.isEmpty()); mImgOpt.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { mImgChooser.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mImgChooser.getChooseButton().setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mImgChooser = Utils.createImageChooser(!imgPath.isEmpty(), imgPath); groupPanel.add(new GroupPanel(GroupingType.fillLast, mImgOpt, mImgChooser)); UnselectableButtonGroup.group(mColorOpt, mImgOpt); groupPanel.add(new WebSeparator()); // groupPanel.add(new WebLabel(Tr.tr("Participants:"))); // mParticipantsList = new WebCheckBoxList(); // mParticipantsList.setVisibleRowCount(10); // for (User oneUser : UserList.getInstance().getAll()) { // boolean selected = mThread.getUser().contains(oneUser); // mParticipantsList.getCheckBoxListModel().addCheckBoxElement( // new UserElement(oneUser), // selected); // } final WebButton saveButton = new WebButton(Tr.tr("Save")); // mParticipantsList.getModel().addListDataListener(new ListDataListener() { // @Override // public void intervalAdded(ListDataEvent e) { // } // @Override // public void intervalRemoved(ListDataEvent e) { // } // @Override // public void contentsChanged(ListDataEvent e) { // saveButton.setEnabled(!mParticipantsList.getCheckedValues().isEmpty()); // } // }); // // groupPanel.add(new WebScrollPane(mParticipantsList)); // groupPanel.add(new WebSeparator(true, true)); this.add(groupPanel, BorderLayout.CENTER); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // if (mParticipantsList.getCheckedValues().size() > 1) { // String infoText = Tr.t/r("More than one receiver not supported // (yet)."); // WebOptionPane.showMessageDialog(ThreadListView.this, // infoText, // Tr.t/r("Sorry"), // WebOptionPane.INFORMATION_MESSAGE); // return; // } ThreadDetails.this.save(); // close popup focusGainer.requestFocus(); } }); // this.getRootPane().setDefaultButton(saveButton); GroupPanel buttonPanel = new GroupPanel(2, saveButton); buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); this.add(buttonPanel, BorderLayout.SOUTH); }
public void install() { // Button that calls for popup WebButton showPopup = controller.getView().getBtnBuscarCliente(); // Popup itself popup = new WebButtonPopup(showPopup, PopupWay.downLeft); // Popup content WebLabel label = new WebLabel("Buscador de clientes", WebLabel.CENTER); field = new WebTextField("", 10); table = new WebTable(); tableModel = new ClienteTableModel(); table.setModel(tableModel); table.getColumnModel().getColumn(0).setMaxWidth(40); // Ancho del ID table.getColumnModel().getColumn(1).setMinWidth(280); // Ancho de la razón social table.getColumnModel().getColumn(2).setMinWidth(120); // Ancho del RFC table.getColumnModel().getColumn(3).setMinWidth(120); // Ancho de la calle table.getColumnModel().getColumn(4).setMinWidth(120); // Ancho del colonia table.getColumnModel().getColumn(5).setMinWidth(120); // Ancho del municipio field.setHorizontalAlignment(SwingConstants.CENTER); GroupPanel content = new GroupPanel(5, false, label, field, table); content.setMinimumWidth(800); content.setMargin(15); // Setup events table .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter"); table .getActionMap() .put( "Enter", new AbstractAction() { @Override public void actionPerformed(ActionEvent ae) { selectCliente(); } }); content .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Escape"); content .getActionMap() .put( "Escape", new AbstractAction() { @Override public void actionPerformed(ActionEvent ae) { popup.hidePopup(); } }); field.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) selectCliente(); else if (e.getKeyCode() == KeyEvent.VK_DOWN) { int sigFila = table.getSelectedRow() + 1; if (sigFila < table.getRowCount()) { table.setRowSelectionInterval(sigFila, sigFila); table.scrollRectToVisible(table.getCellRect(sigFila, 1, true)); } } else if (e.getKeyCode() == KeyEvent.VK_UP) { int antFila = table.getSelectedRow() - 1; if (antFila >= 0) { table.setRowSelectionInterval(antFila, antFila); table.scrollRectToVisible(table.getCellRect(antFila, 1, true)); } } else preBuscar(); } }); // Setup popup content popup.setContent(content); // Component focused by default popup.setDefaultFocusComponent(field); }
public void clearOnlineMsg() { localMsgPl.removeAll(); }
public void clearLocalMsg() { localMsgPl.removeAll(); }
AddUserDialog() { this.setTitle(Tr.tr("Add New Contact")); // this.setSize(400, 280); this.setResizable(false); this.setModal(true); GroupPanel groupPanel = new GroupPanel(10, false); groupPanel.setMargin(5); // editable fields WebPanel namePanel = new WebPanel(); namePanel.setLayout(new BorderLayout(10, 5)); namePanel.add(new WebLabel(Tr.tr("Display Name:")), BorderLayout.WEST); mNameField = new WebTextField(); namePanel.add(mNameField, BorderLayout.CENTER); groupPanel.add(namePanel); groupPanel.add(new WebSeparator(true, true)); mEncryptionBox = new WebCheckBox(Tr.tr("Encryption")); mEncryptionBox.setAnimated(false); mEncryptionBox.setSelected(true); groupPanel.add(mEncryptionBox); groupPanel.add(new WebSeparator(true, true)); groupPanel.add(new WebLabel("JID:")); mJIDField = new WebTextField(38); groupPanel.add(mJIDField); groupPanel.add(new WebSeparator(true, true)); this.add(groupPanel, BorderLayout.CENTER); // buttons WebButton cancelButton = new WebButton(Tr.tr("Cancel")); cancelButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AddUserDialog.this.dispose(); } }); final WebButton saveButton = new WebButton(Tr.tr("Save")); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AddUserDialog.this.saveUser(); AddUserDialog.this.dispose(); } }); GroupPanel buttonPanel = new GroupPanel(2, cancelButton, saveButton); buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); this.add(buttonPanel, BorderLayout.SOUTH); this.pack(); }
StatusDialog() { this.setTitle(Tr.tr("Status")); this.setResizable(false); this.setModal(true); GroupPanel groupPanel = new GroupPanel(10, false); groupPanel.setMargin(5); String[] strings = mConf.getStringArray(Config.NET_STATUS_LIST); List<String> stats = new ArrayList<>(Arrays.<String>asList(strings)); String currentStatus = ""; if (!stats.isEmpty()) currentStatus = stats.remove(0); stats.remove(""); groupPanel.add(new WebLabel(Tr.tr("Your current status:"))); mStatusField = new WebTextField(currentStatus, 30); groupPanel.add(mStatusField); groupPanel.add(new WebSeparator(true, true)); groupPanel.add(new WebLabel(Tr.tr("Previously used:"))); mStatusList = new WebList(stats); mStatusList.setMultiplySelectionAllowed(false); mStatusList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; mStatusField.setText(mStatusList.getSelectedValue().toString()); } }); WebScrollPane listScrollPane = new ScrollPane(mStatusList); groupPanel.add(listScrollPane); this.add(groupPanel, BorderLayout.CENTER); // buttons WebButton cancelButton = new WebButton(Tr.tr("Cancel")); cancelButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { StatusDialog.this.dispose(); } }); final WebButton saveButton = new WebButton(Tr.tr("Save")); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { StatusDialog.this.saveStatus(); StatusDialog.this.dispose(); } }); this.getRootPane().setDefaultButton(saveButton); GroupPanel buttonPanel = new GroupPanel(2, cancelButton, saveButton); buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); this.add(buttonPanel, BorderLayout.SOUTH); this.pack(); }
/** 初始化组件 */ private void initComponent() { WebLabel netSettingLbl = new WebLabel("Network Setting"); WebLabel typeLbl = new WebLabel("Type:"); WebLabel addressLbl = new WebLabel("Address:"); WebLabel portLbl = new WebLabel("Port:"); WebLabel usernameLbl = new WebLabel("Username:"******"Password:"******"Domain:"); typeCbx = new WebComboBox(); typeCbx.addItem("None"); typeCbx.addItem("Http"); typeCbx.addItem("Socks5"); typeCbx.addItem("Browser"); typeCbx.setDrawFocus(false); // field addressFld = new WebTextField(); portFld = new WebTextField(); usernameFld = new WebTextField(); passwordFld = new WebTextField(); domainFld = new WebTextField(); // label margin netSettingLbl.setMargin(15); Insets insets = new Insets(5, 5, 5, 5); typeLbl.setMargin(5, 37, 5, 5); addressLbl.setMargin(5, 14, 5, 5); portLbl.setMargin(5, 27, 5, 5); usernameLbl.setMargin(insets); passwordLbl.setMargin(insets); domainLbl.setMargin(insets); // size Dimension d1 = new Dimension(80, 30); Dimension d2 = new Dimension(100, 30); Dimension d3 = new Dimension(50, 30); // field properties typeCbx.setPreferredSize(d1); usernameFld.setPreferredSize(d1); addressFld.setPreferredSize(d2); passwordFld.setPreferredSize(d2); portFld.setPreferredSize(d3); domainFld.setPreferredSize(d3); // group panel GroupPanel g1 = new GroupPanel(true, typeLbl, typeCbx, addressLbl, addressFld, portLbl, portFld); GroupPanel g2 = new GroupPanel( true, usernameLbl, usernameFld, passwordLbl, passwordFld, domainLbl, domainFld); g1.setPreferredSize(new Dimension(this.getWidth(), 30)); // test button Dimension dBtn = new Dimension(80, 30); WebButton testBtn = new WebButton("Test"); WebButton okBtn = new WebButton("OK"); WebButton cancelBtn = new WebButton("Cancel"); // size testBtn.setPreferredSize(dBtn); okBtn.setPreferredSize(dBtn); cancelBtn.setPreferredSize(dBtn); // action testBtn.setAction(view.getActionService().getActionMap(this).get("processTestAction")); okBtn.setAction(view.getActionService().getActionMap(this).get("processOKAction")); cancelBtn.setAction(view.getActionService().getActionMap(this).get("processCancelAction")); // reset text testBtn.setText("Test"); okBtn.setText("OK"); cancelBtn.setText("Cancel"); // layout panel WebPanel testPl = new WebPanel(); testPl.add(testBtn, BorderLayout.LINE_END); testPl.setOpaque(false); testPl.setMargin(20, 0, 5, 30); WebPanel confimBtnPl = new WebPanel(); confimBtnPl.add(new GroupPanel(true, okBtn, cancelBtn), BorderLayout.LINE_END); confimBtnPl.setMargin(10, 0, 5, 30); confimBtnPl.setOpaque(false); // add to content add(new GroupPanel(false, netSettingLbl, g1, g2, testPl, confimBtnPl)); }