List of usage examples for javax.swing JLabel setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanel.java
/** * Create the panel.//from w w w . j a va2 s .c o m */ public Hl7ConnectionPanel(Controller theController) { setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 150, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; setLayout(gridBagLayout); mySinglePortRadio = new JRadioButton("Single Port MLLP"); mySinglePortRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updatePortsModel(); updatePortsUi(); } }); myPortButtonGroup.add(mySinglePortRadio); GridBagConstraints gbc_SinglePortRadio = new GridBagConstraints(); gbc_SinglePortRadio.anchor = GridBagConstraints.WEST; gbc_SinglePortRadio.insets = new Insets(0, 0, 5, 5); gbc_SinglePortRadio.gridx = 0; gbc_SinglePortRadio.gridy = 0; add(mySinglePortRadio, gbc_SinglePortRadio); JPanel panel_4 = new JPanel(); panel_4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_4 = new GridBagConstraints(); gbc_panel_4.fill = GridBagConstraints.BOTH; gbc_panel_4.insets = new Insets(0, 0, 5, 0); gbc_panel_4.gridx = 1; gbc_panel_4.gridy = 0; add(panel_4, gbc_panel_4); GridBagLayout gbl_panel_4 = new GridBagLayout(); gbl_panel_4.columnWidths = new int[] { 0, 0, 0 }; gbl_panel_4.rowHeights = new int[] { 0, 0 }; gbl_panel_4.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_panel_4.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel_4.setLayout(gbl_panel_4); mySinglePortTextBox = new JTextField(); mySinglePortTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = mySinglePortTextBox.getText(); text = text.replaceAll("[^0-9]+", ""); if (!StringUtils.equals(mySinglePortTextBox.getText(), text)) { final String newVal = text; SwingUtilities.invokeLater(new Runnable() { public void run() { mySinglePortTextBox.setText(newVal); } }); } if (mySinglePortRadio.isSelected()) { if (text.length() > 0) { myConnection.setIncomingOrSinglePort(Integer.parseInt(text)); } else { myConnection.setIncomingOrSinglePort(-1); } } } }); mylabel = new JLabel("Port"); mylabel.setHorizontalAlignment(SwingConstants.CENTER); mylabel.setPreferredSize(new Dimension(60, 16)); mylabel.setMinimumSize(new Dimension(60, 16)); mylabel.setMaximumSize(new Dimension(60, 16)); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.anchor = GridBagConstraints.EAST; gbc_label.insets = new Insets(0, 0, 0, 5); gbc_label.gridx = 0; gbc_label.gridy = 0; panel_4.add(mylabel, gbc_label); GridBagConstraints gbc_SinglePortTextBox = new GridBagConstraints(); gbc_SinglePortTextBox.insets = new Insets(0, 5, 0, 0); gbc_SinglePortTextBox.anchor = GridBagConstraints.WEST; gbc_SinglePortTextBox.gridx = 1; gbc_SinglePortTextBox.gridy = 0; panel_4.add(mySinglePortTextBox, gbc_SinglePortTextBox); mySinglePortTextBox.setMinimumSize(new Dimension(100, 28)); mySinglePortTextBox.setMaximumSize(new Dimension(100, 2147483647)); mySinglePortTextBox.setColumns(10); myDualPortRadio = new JRadioButton("Dual Port MLLP"); myDualPortRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updatePortsModel(); updatePortsUi(); } }); myPortButtonGroup.add(myDualPortRadio); GridBagConstraints gbc_DualPortRadio = new GridBagConstraints(); gbc_DualPortRadio.anchor = GridBagConstraints.WEST; gbc_DualPortRadio.insets = new Insets(0, 0, 5, 5); gbc_DualPortRadio.gridx = 0; gbc_DualPortRadio.gridy = 1; add(myDualPortRadio, gbc_DualPortRadio); JPanel panel = new JPanel(); panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_BottomPanel = new GridBagConstraints(); gbc_BottomPanel.insets = new Insets(0, 0, 5, 0); gbc_BottomPanel.fill = GridBagConstraints.BOTH; gbc_BottomPanel.gridx = 1; gbc_BottomPanel.gridy = 1; add(panel, gbc_BottomPanel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); JLabel lblInbound = new JLabel("Inbound"); lblInbound.setHorizontalAlignment(SwingConstants.CENTER); lblInbound.setPreferredSize(new Dimension(60, 16)); lblInbound.setMinimumSize(new Dimension(60, 16)); lblInbound.setMaximumSize(new Dimension(60, 16)); GridBagConstraints gbc_lblInbound = new GridBagConstraints(); gbc_lblInbound.insets = new Insets(0, 5, 0, 5); gbc_lblInbound.anchor = GridBagConstraints.EAST; gbc_lblInbound.gridx = 0; gbc_lblInbound.gridy = 0; panel.add(lblInbound, gbc_lblInbound); myDualIncomingTextBox = new JTextField(); myDualIncomingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = myDualIncomingTextBox.getText(); text = text.replaceAll("[^0-9]+", ""); if (!StringUtils.equals(myDualIncomingTextBox.getText(), text)) { final String newVal = text; SwingUtilities.invokeLater(new Runnable() { public void run() { myDualIncomingTextBox.setText(newVal); } }); } if (myDualPortRadio.isSelected()) { if (text.length() > 0) { myConnection.setIncomingOrSinglePort(Integer.parseInt(text)); } else { myConnection.setIncomingOrSinglePort(-1); } } } }); myDualIncomingTextBox.setMaximumSize(new Dimension(100, 2147483647)); myDualIncomingTextBox.setMinimumSize(new Dimension(100, 28)); GridBagConstraints gbc_DualIncomingTextBox = new GridBagConstraints(); gbc_DualIncomingTextBox.anchor = GridBagConstraints.WEST; gbc_DualIncomingTextBox.insets = new Insets(0, 0, 0, 5); gbc_DualIncomingTextBox.gridx = 1; gbc_DualIncomingTextBox.gridy = 0; panel.add(myDualIncomingTextBox, gbc_DualIncomingTextBox); myDualIncomingTextBox.setColumns(10); JLabel lblOutbound = new JLabel("Outbound"); GridBagConstraints gbc_lblOutbound = new GridBagConstraints(); gbc_lblOutbound.anchor = GridBagConstraints.EAST; gbc_lblOutbound.insets = new Insets(0, 0, 0, 5); gbc_lblOutbound.gridx = 2; gbc_lblOutbound.gridy = 0; panel.add(lblOutbound, gbc_lblOutbound); myDualOutgoingTextBox = new JTextField(); myDualOutgoingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = myDualOutgoingTextBox.getText(); text = text.replaceAll("[^0-9]+", ""); if (!StringUtils.equals(myDualOutgoingTextBox.getText(), text)) { final String newVal = text; SwingUtilities.invokeLater(new Runnable() { public void run() { myDualOutgoingTextBox.setText(newVal); } }); } if (myDualPortRadio.isSelected()) { if (text.length() > 0) { myConnection.setOutgoingPort(Integer.parseInt(text)); } else { myConnection.setOutgoingPort(-1); } } } }); myDualOutgoingTextBox.setMinimumSize(new Dimension(100, 28)); myDualOutgoingTextBox.setMaximumSize(new Dimension(100, 2147483647)); GridBagConstraints gbc_DualOutgoingTextBox = new GridBagConstraints(); gbc_DualOutgoingTextBox.insets = new Insets(0, 0, 0, 5); gbc_DualOutgoingTextBox.anchor = GridBagConstraints.WEST; gbc_DualOutgoingTextBox.gridx = 3; gbc_DualOutgoingTextBox.gridy = 0; panel.add(myDualOutgoingTextBox, gbc_DualOutgoingTextBox); myDualOutgoingTextBox.setColumns(10); myHl7OverHttpRadioButton = new JRadioButton("HL7 over HTTP"); myHl7OverHttpRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updatePortsModel(); updatePortsUi(); } }); myPortButtonGroup.add(myHl7OverHttpRadioButton); GridBagConstraints gbc_Hl7OverHttpRadioButton = new GridBagConstraints(); gbc_Hl7OverHttpRadioButton.anchor = GridBagConstraints.WEST; gbc_Hl7OverHttpRadioButton.insets = new Insets(0, 0, 5, 5); gbc_Hl7OverHttpRadioButton.gridx = 0; gbc_Hl7OverHttpRadioButton.gridy = 2; add(myHl7OverHttpRadioButton, gbc_Hl7OverHttpRadioButton); mypanel = new JPanel(); mypanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.insets = new Insets(0, 0, 5, 0); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 1; gbc_panel.gridy = 2; add(mypanel, gbc_panel); GridBagLayout gbl_panel2 = new GridBagLayout(); gbl_panel2.columnWidths = new int[] { 0, 0 }; gbl_panel2.rowHeights = new int[] { 0, 0 }; gbl_panel2.columnWeights = new double[] { 0.0, 1.0 }; gbl_panel2.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; mypanel.setLayout(gbl_panel2); mylabel_1 = new JLabel("URL"); mylabel_1.setHorizontalAlignment(SwingConstants.CENTER); mylabel_1.setPreferredSize(new Dimension(60, 16)); mylabel_1.setMinimumSize(new Dimension(60, 16)); mylabel_1.setMaximumSize(new Dimension(60, 16)); GridBagConstraints gbc_label_1 = new GridBagConstraints(); gbc_label_1.anchor = GridBagConstraints.EAST; gbc_label_1.insets = new Insets(0, 0, 0, 5); gbc_label_1.gridx = 0; gbc_label_1.gridy = 0; mypanel.add(mylabel_1, gbc_label_1); myHoHUrlTextField = new JTextField(); myHoHUrlTextField.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { if (myHohUrlTextFieldUpdating) { return; } String value = myHoHUrlTextField.getText(); try { URL url = new URL(value); boolean tls; if (url.getProtocol().equals("http")) { tls = false; } else if (url.getProtocol().equals("https")) { tls = true; } else { ourLog.info("Unknown protocol: {}", url.getProtocol()); myHoHUrlTextField.setBackground(ERROR_BG); return; } myConnection.setTls(tls); myConnection.setHost(url.getHost()); myConnection .setIncomingOrSinglePort(url.getPort() != -1 ? url.getPort() : url.getDefaultPort()); myConnection.setHttpUriPath(url.getPath()); myHohUrlTextFieldUpdating = true; updatePortsUi(); myHohUrlTextFieldUpdating = false; myTlsCheckbox.setSelected(tls); myHohTlsCheckbox.setSelected(tls); myHoHUrlTextField.setBackground(Color.white); } catch (MalformedURLException e) { myHoHUrlTextField.setBackground(ERROR_BG); } } }); GridBagConstraints gbc_HohUsernameTextbox = new GridBagConstraints(); gbc_HohUsernameTextbox.fill = GridBagConstraints.HORIZONTAL; gbc_HohUsernameTextbox.gridx = 1; gbc_HohUsernameTextbox.gridy = 0; mypanel.add(myHoHUrlTextField, gbc_HohUsernameTextbox); myHoHUrlTextField.setColumns(10); JLabel lblEncoding = new JLabel("Encoding"); GridBagConstraints gbc_lblEncoding = new GridBagConstraints(); gbc_lblEncoding.insets = new Insets(0, 0, 5, 5); gbc_lblEncoding.gridx = 0; gbc_lblEncoding.gridy = 3; add(lblEncoding, gbc_lblEncoding); JPanel encodingPanel = new JPanel(); GridBagConstraints gbc_encodingPanel = new GridBagConstraints(); gbc_encodingPanel.fill = GridBagConstraints.HORIZONTAL; gbc_encodingPanel.insets = new Insets(0, 0, 5, 0); gbc_encodingPanel.gridx = 1; gbc_encodingPanel.gridy = 3; add(encodingPanel, gbc_encodingPanel); encodingPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gbl_encodingPanel = new GridBagLayout(); gbl_encodingPanel.columnWidths = new int[] { 144, 58, 0 }; gbl_encodingPanel.rowHeights = new int[] { 23, 0 }; gbl_encodingPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; gbl_encodingPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; encodingPanel.setLayout(gbl_encodingPanel); myXmlRadio = new JRadioButton("XML"); myXmlRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { updateEncodingModel(); } }); myEr7Radio = new JRadioButton("ER7 (Pipe and hat)"); myEr7Radio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateEncodingModel(); } }); encodingButtonGroup.add(myEr7Radio); GridBagConstraints gbc_Er7Radio = new GridBagConstraints(); gbc_Er7Radio.anchor = GridBagConstraints.NORTHWEST; gbc_Er7Radio.insets = new Insets(0, 0, 0, 5); gbc_Er7Radio.gridx = 0; gbc_Er7Radio.gridy = 0; encodingPanel.add(myEr7Radio, gbc_Er7Radio); encodingButtonGroup.add(myXmlRadio); GridBagConstraints gbc_XmlRadio = new GridBagConstraints(); gbc_XmlRadio.anchor = GridBagConstraints.NORTHWEST; gbc_XmlRadio.gridx = 1; gbc_XmlRadio.gridy = 0; encodingPanel.add(myXmlRadio, gbc_XmlRadio); JLabel lblCharset = new JLabel("Charset"); GridBagConstraints gbc_lblCharset = new GridBagConstraints(); gbc_lblCharset.insets = new Insets(0, 0, 5, 5); gbc_lblCharset.gridx = 0; gbc_lblCharset.gridy = 4; add(lblCharset, gbc_lblCharset); JPanel panel_2 = new JPanel(); GridBagConstraints gbc_panel_2 = new GridBagConstraints(); gbc_panel_2.fill = GridBagConstraints.HORIZONTAL; gbc_panel_2.insets = new Insets(0, 0, 5, 0); gbc_panel_2.gridx = 1; gbc_panel_2.gridy = 4; add(panel_2, gbc_panel_2); panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gbl_panel_2 = new GridBagLayout(); gbl_panel_2.columnWidths = new int[] { 28, 198, 0, 0 }; gbl_panel_2.rowHeights = new int[] { 27, 0 }; gbl_panel_2.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel_2.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel_2.setLayout(gbl_panel_2); myCharsetSelectRadio = new JRadioButton(""); myCharsetSelectRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCharsetModel(); } }); charsetButtonGroup.add(myCharsetSelectRadio); GridBagConstraints gbc_CharsetSelectRadio = new GridBagConstraints(); gbc_CharsetSelectRadio.anchor = GridBagConstraints.WEST; gbc_CharsetSelectRadio.insets = new Insets(0, 0, 0, 5); gbc_CharsetSelectRadio.gridx = 0; gbc_CharsetSelectRadio.gridy = 0; panel_2.add(myCharsetSelectRadio, gbc_CharsetSelectRadio); myCharsetCombo = new JComboBox(); myCharsetCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCharsetModel(); } }); GridBagConstraints gbc_CharsetCombo = new GridBagConstraints(); gbc_CharsetCombo.anchor = GridBagConstraints.NORTHWEST; gbc_CharsetCombo.insets = new Insets(0, 0, 0, 5); gbc_CharsetCombo.gridx = 1; gbc_CharsetCombo.gridy = 0; panel_2.add(myCharsetCombo, gbc_CharsetCombo); myCharsetDetectRadio = new JRadioButton("Detect in Message (MSH-18)"); myCharsetDetectRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateCharsetModel(); } }); charsetButtonGroup.add(myCharsetDetectRadio); GridBagConstraints gbc_CharsetDetectRadio = new GridBagConstraints(); gbc_CharsetDetectRadio.anchor = GridBagConstraints.NORTH; gbc_CharsetDetectRadio.gridwidth = 2; gbc_CharsetDetectRadio.gridx = 2; gbc_CharsetDetectRadio.gridy = 0; panel_2.add(myCharsetDetectRadio, gbc_CharsetDetectRadio); mylabel_5 = new JLabel("Debug"); GridBagConstraints gbc_label_5 = new GridBagConstraints(); gbc_label_5.insets = new Insets(0, 0, 5, 5); gbc_label_5.gridx = 0; gbc_label_5.gridy = 5; add(mylabel_5, gbc_label_5); mypanel_2 = new JPanel(); mypanel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_75 = new GridBagConstraints(); gbc_panel_75.insets = new Insets(0, 0, 5, 0); gbc_panel_75.fill = GridBagConstraints.BOTH; gbc_panel_75.gridx = 1; gbc_panel_75.gridy = 5; add(mypanel_2, gbc_panel_75); GridBagLayout gbl_panel_74 = new GridBagLayout(); gbl_panel_74.columnWidths = new int[] { 0, 0 }; gbl_panel_74.rowHeights = new int[] { 0, 0 }; gbl_panel_74.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_panel_74.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; mypanel_2.setLayout(gbl_panel_74); myCaptureByteStreamCheckbox = new JCheckBox("Capture Bytes"); GridBagConstraints gbc_CaptureByteStreamCheckbox = new GridBagConstraints(); gbc_CaptureByteStreamCheckbox.gridx = 0; gbc_CaptureByteStreamCheckbox.gridy = 0; mypanel_2.add(myCaptureByteStreamCheckbox, gbc_CaptureByteStreamCheckbox); myCaptureByteStreamCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.setCaptureBytes(myCaptureByteStreamCheckbox.isSelected()); } }); myCaptureByteStreamCheckbox.setToolTipText("Check this box to capture the transport level communication"); myInterfaceTypeCardPanel = new JPanel(); myInterfaceTypeCardPanel.setBorder(null); GridBagConstraints gbc_InterfaceTypeCardPanel = new GridBagConstraints(); gbc_InterfaceTypeCardPanel.gridwidth = 2; gbc_InterfaceTypeCardPanel.fill = GridBagConstraints.BOTH; gbc_InterfaceTypeCardPanel.gridx = 0; gbc_InterfaceTypeCardPanel.gridy = 6; add(myInterfaceTypeCardPanel, gbc_InterfaceTypeCardPanel); myInterfaceTypeCardPanel.setLayout(new CardLayout(0, 0)); myMllpCard = new JPanel(); myMllpCard.setBorder(null); myInterfaceTypeCardPanel.add(myMllpCard, IFACE_TYPE_CARD_MLLP); GridBagLayout gbl_MllpCard = new GridBagLayout(); gbl_MllpCard.columnWidths = new int[] { 150, 0, 0 }; gbl_MllpCard.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_MllpCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_MllpCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; myMllpCard.setLayout(gbl_MllpCard); JLabel lblHost = new JLabel("Host"); GridBagConstraints gbc_lblHost = new GridBagConstraints(); gbc_lblHost.insets = new Insets(0, 0, 5, 5); gbc_lblHost.gridx = 0; gbc_lblHost.gridy = 0; myMllpCard.add(lblHost, gbc_lblHost); mypanel_1 = new JPanel(); mypanel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.insets = new Insets(0, 0, 5, 0); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; myMllpCard.add(mypanel_1, gbc_panel_1); GridBagLayout gbl_panel_1 = new GridBagLayout(); gbl_panel_1.columnWidths = new int[] { 134, 0 }; gbl_panel_1.rowHeights = new int[] { 28, 0 }; gbl_panel_1.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_panel_1.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; mypanel_1.setLayout(gbl_panel_1); myHostBox = new JTextField(); GridBagConstraints gbc_HostBox = new GridBagConstraints(); gbc_HostBox.fill = GridBagConstraints.HORIZONTAL; gbc_HostBox.anchor = GridBagConstraints.NORTH; gbc_HostBox.gridx = 0; gbc_HostBox.gridy = 0; mypanel_1.add(myHostBox, gbc_HostBox); myHostBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHost(myHostBox.getText()); } }); myHostBox.setColumns(10); JLabel lblTransport = new JLabel("Transport"); GridBagConstraints gbc_lblTransport = new GridBagConstraints(); gbc_lblTransport.insets = new Insets(0, 0, 5, 5); gbc_lblTransport.gridx = 0; gbc_lblTransport.gridy = 1; myMllpCard.add(lblTransport, gbc_lblTransport); JPanel panel_3 = new JPanel(); GridBagConstraints gbc_hohAuthPanel = new GridBagConstraints(); gbc_hohAuthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_hohAuthPanel.insets = new Insets(0, 0, 5, 0); gbc_hohAuthPanel.gridx = 1; gbc_hohAuthPanel.gridy = 1; myMllpCard.add(panel_3, gbc_hohAuthPanel); panel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagLayout gbl_hohAuthPanel = new GridBagLayout(); gbl_hohAuthPanel.columnWidths = new int[] { 0, 0, 0 }; gbl_hohAuthPanel.rowHeights = new int[] { 0, 0 }; gbl_hohAuthPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; gbl_hohAuthPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel_3.setLayout(gbl_hohAuthPanel); myTlsCheckbox = new JCheckBox("Use TLS/SSL"); myTlsCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myHohTlsCheckbox.setSelected(myTlsCheckbox.isSelected()); myConnection.setTls(myTlsCheckbox.isSelected()); } }); GridBagConstraints gbc_TlsCheckbox = new GridBagConstraints(); gbc_TlsCheckbox.insets = new Insets(0, 0, 0, 5); gbc_TlsCheckbox.anchor = GridBagConstraints.WEST; gbc_TlsCheckbox.gridx = 0; gbc_TlsCheckbox.gridy = 0; panel_3.add(myTlsCheckbox, gbc_TlsCheckbox); myHoHCard = new JPanel(); myInterfaceTypeCardPanel.add(myHoHCard, IFACE_TYPE_CARD_HOH); GridBagLayout gbl_HoHCard = new GridBagLayout(); gbl_HoHCard.columnWidths = new int[] { 150, 0, 0 }; gbl_HoHCard.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_HoHCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_HoHCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; myHoHCard.setLayout(gbl_HoHCard); mylabel_6 = new JLabel("Authorization"); GridBagConstraints gbc_label_6 = new GridBagConstraints(); gbc_label_6.insets = new Insets(0, 0, 5, 5); gbc_label_6.gridx = 0; gbc_label_6.gridy = 0; myHoHCard.add(mylabel_6, gbc_label_6); hohAuthPanel = new JPanel(); hohAuthPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_hohAuthPanel2 = new GridBagConstraints(); gbc_hohAuthPanel2.insets = new Insets(0, 0, 5, 0); gbc_hohAuthPanel2.fill = GridBagConstraints.BOTH; gbc_hohAuthPanel2.gridx = 1; gbc_hohAuthPanel2.gridy = 0; myHoHCard.add(hohAuthPanel, gbc_hohAuthPanel2); GridBagLayout gbl_hohAuthPanel3 = new GridBagLayout(); gbl_hohAuthPanel3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0 }; gbl_hohAuthPanel3.rowHeights = new int[] { 0, 0 }; gbl_hohAuthPanel3.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; gbl_hohAuthPanel3.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; hohAuthPanel.setLayout(gbl_hohAuthPanel3); myHohAuthEnabledCheckbox = new JCheckBox("Enabled"); myHohAuthEnabledCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { myConnection.setHohAuthenticationEnabled(myHohAuthEnabledCheckbox.isSelected()); } }); GridBagConstraints gbc_HohAuthEnabledCheckbox = new GridBagConstraints(); gbc_HohAuthEnabledCheckbox.insets = new Insets(0, 0, 0, 5); gbc_HohAuthEnabledCheckbox.gridx = 0; gbc_HohAuthEnabledCheckbox.gridy = 0; hohAuthPanel.add(myHohAuthEnabledCheckbox, gbc_HohAuthEnabledCheckbox); mylabel_7 = new JLabel("Username:"); GridBagConstraints gbc_label_7 = new GridBagConstraints(); gbc_label_7.insets = new Insets(0, 0, 0, 5); gbc_label_7.anchor = GridBagConstraints.EAST; gbc_label_7.gridx = 1; gbc_label_7.gridy = 0; hohAuthPanel.add(mylabel_7, gbc_label_7); myHohAuthUsernameTextbox = new JTextField(); myHohAuthUsernameTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohAuthenticationUsername(myHohAuthUsernameTextbox.getText()); } }); myHohAuthUsernameTextbox.setMaximumSize(new Dimension(200, 2147483647)); myHohAuthUsernameTextbox.setMinimumSize(new Dimension(100, 28)); myHohAuthUsernameTextbox.setPreferredSize(new Dimension(100, 28)); GridBagConstraints gbc_HohUsernameTextbox2 = new GridBagConstraints(); gbc_HohUsernameTextbox2.insets = new Insets(0, 0, 0, 5); gbc_HohUsernameTextbox2.fill = GridBagConstraints.HORIZONTAL; gbc_HohUsernameTextbox2.gridx = 2; gbc_HohUsernameTextbox2.gridy = 0; hohAuthPanel.add(myHohAuthUsernameTextbox, gbc_HohUsernameTextbox2); myHohAuthUsernameTextbox.setColumns(10); mylabel_8 = new JLabel("Password:"); GridBagConstraints gbc_label_8 = new GridBagConstraints(); gbc_label_8.insets = new Insets(0, 0, 0, 5); gbc_label_8.anchor = GridBagConstraints.EAST; gbc_label_8.gridx = 3; gbc_label_8.gridy = 0; hohAuthPanel.add(mylabel_8, gbc_label_8); myHohAuthPasswordTextbox = new JTextField(); myHohAuthPasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohAuthenticationPassword(myHohAuthPasswordTextbox.getText()); } }); myHohAuthPasswordTextbox.setPreferredSize(new Dimension(100, 28)); myHohAuthPasswordTextbox.setMaximumSize(new Dimension(200, 2147483647)); myHohAuthPasswordTextbox.setMinimumSize(new Dimension(100, 28)); GridBagConstraints gbc_HohSignatureKeystoreTextbox = new GridBagConstraints(); gbc_HohSignatureKeystoreTextbox.insets = new Insets(0, 0, 0, 5); gbc_HohSignatureKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL; gbc_HohSignatureKeystoreTextbox.gridx = 4; gbc_HohSignatureKeystoreTextbox.gridy = 0; hohAuthPanel.add(myHohAuthPasswordTextbox, gbc_HohSignatureKeystoreTextbox); myHohAuthPasswordTextbox.setColumns(10); mylabel_2 = new JLabel("Security Profile"); mylabel_2.setVerticalTextPosition(SwingConstants.TOP); mylabel_2.setVerticalAlignment(SwingConstants.TOP); GridBagConstraints gbc_label_2 = new GridBagConstraints(); gbc_label_2.insets = new Insets(0, 0, 5, 5); gbc_label_2.gridx = 0; gbc_label_2.gridy = 1; myHoHCard.add(mylabel_2, gbc_label_2); // securityProfilePanel = new JPanel(); GridBagConstraints gbc_securityProfilePanel = new GridBagConstraints(); gbc_securityProfilePanel.insets = new Insets(0, 0, 5, 0); gbc_securityProfilePanel.fill = GridBagConstraints.BOTH; gbc_securityProfilePanel.gridx = 1; gbc_securityProfilePanel.gridy = 1; // myHoHCard.add(securityProfilePanel, gbc_securityProfilePanel); // securityProfilePanel.setLayout(new BorderLayout(0, 0)); tlsKeystorePanel = new JPanel(); tlsKeystorePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); // securityProfilePanel.add(tlsKeystorePanel, BorderLayout.CENTER); myHoHCard.add(tlsKeystorePanel, gbc_securityProfilePanel); GridBagLayout gbl_tlsKeystorePanel = new GridBagLayout(); gbl_tlsKeystorePanel.columnWidths = new int[] { 0, 58, 107, 77, 0, 0 }; gbl_tlsKeystorePanel.rowHeights = new int[] { 28, 16, 0, 0 }; gbl_tlsKeystorePanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE }; gbl_tlsKeystorePanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; tlsKeystorePanel.setLayout(gbl_tlsKeystorePanel); myHohTlsCheckbox = new JCheckBox("TLS Enabled"); GridBagConstraints gbc_HohTlsCheckbox = new GridBagConstraints(); gbc_HohTlsCheckbox.gridheight = 2; gbc_HohTlsCheckbox.insets = new Insets(0, 0, 5, 5); gbc_HohTlsCheckbox.gridx = 0; gbc_HohTlsCheckbox.gridy = 0; tlsKeystorePanel.add(myHohTlsCheckbox, gbc_HohTlsCheckbox); myHohTlsCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.setTls(myHohTlsCheckbox.isSelected()); myTlsCheckbox.setSelected(myHohTlsCheckbox.isSelected()); updatePortsUi(); } }); mylabel_3 = new JLabel("Keystore:"); GridBagConstraints gbc_label_3 = new GridBagConstraints(); gbc_label_3.anchor = GridBagConstraints.WEST; gbc_label_3.fill = GridBagConstraints.VERTICAL; gbc_label_3.insets = new Insets(0, 0, 5, 5); gbc_label_3.gridx = 1; gbc_label_3.gridy = 0; tlsKeystorePanel.add(mylabel_3, gbc_label_3); myHohSecurityKeystoreTextbox = new JTextField(); GridBagConstraints gbc_HohKeystoreTextbox = new GridBagConstraints(); gbc_HohKeystoreTextbox.gridwidth = 2; gbc_HohKeystoreTextbox.anchor = GridBagConstraints.NORTH; gbc_HohKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL; gbc_HohKeystoreTextbox.insets = new Insets(0, 0, 5, 5); gbc_HohKeystoreTextbox.gridx = 2; gbc_HohKeystoreTextbox.gridy = 0; tlsKeystorePanel.add(myHohSecurityKeystoreTextbox, gbc_HohKeystoreTextbox); myHohSecurityKeystoreTextbox.setColumns(10); myHohSecurityKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { String text = myHohSecurityKeystoreTextbox.getText(); myHohSecurityKeyPwTextBox.setEnabled(isNotBlank(text)); myConnection.setTlsKeystoreLocation(text); } }); myHohSecurityKeystoreChooseBtn = new JButton("Choose"); myHohSecurityKeystoreChooseBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Hl7ConnectionPanel.chooseKeystore(Hl7ConnectionPanel.this, myHohSecurityKeystoreTextbox); } }); myHohSecurityKeystoreChooseBtn.setIcon( new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); GridBagConstraints gbc_HohSignatureKeystoreChooseButton = new GridBagConstraints(); gbc_HohSignatureKeystoreChooseButton.insets = new Insets(0, 0, 5, 0); gbc_HohSignatureKeystoreChooseButton.gridx = 4; gbc_HohSignatureKeystoreChooseButton.gridy = 0; tlsKeystorePanel.add(myHohSecurityKeystoreChooseBtn, gbc_HohSignatureKeystoreChooseButton); mylabel_4 = new JLabel("Store Pass:"); GridBagConstraints gbc_label_4 = new GridBagConstraints(); gbc_label_4.insets = new Insets(0, 0, 0, 5); gbc_label_4.anchor = GridBagConstraints.EAST; gbc_label_4.gridx = 1; gbc_label_4.gridy = 1; tlsKeystorePanel.add(mylabel_4, gbc_label_4); myHohSecurityKeyPwTextBox = new JTextField(); myHohSecurityKeyPwTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setTlsKeystorePassword(myHohSecurityKeyPwTextBox.getText()); } }); GridBagConstraints gbc_HohSecurityKeyPwTextBox = new GridBagConstraints(); gbc_HohSecurityKeyPwTextBox.insets = new Insets(0, 0, 0, 5); gbc_HohSecurityKeyPwTextBox.fill = GridBagConstraints.HORIZONTAL; gbc_HohSecurityKeyPwTextBox.gridx = 2; gbc_HohSecurityKeyPwTextBox.gridy = 1; tlsKeystorePanel.add(myHohSecurityKeyPwTextBox, gbc_HohSecurityKeyPwTextBox); myHohSecurityKeyPwTextBox.setColumns(10); myHohSecurityProfileKeystoreStatus = new JLabel("Value goes here"); myHohSecurityProfileKeystoreStatus.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_HohSecurityProfileKeystoreStatus = new GridBagConstraints(); gbc_HohSecurityProfileKeystoreStatus.anchor = GridBagConstraints.NORTH; gbc_HohSecurityProfileKeystoreStatus.fill = GridBagConstraints.HORIZONTAL; gbc_HohSecurityProfileKeystoreStatus.gridwidth = 5; gbc_HohSecurityProfileKeystoreStatus.gridx = 0; gbc_HohSecurityProfileKeystoreStatus.gridy = 2; tlsKeystorePanel.add(myHohSecurityProfileKeystoreStatus, gbc_HohSecurityProfileKeystoreStatus); mylabel_9 = new JLabel("Signature Profile"); GridBagConstraints gbc_label_9 = new GridBagConstraints(); gbc_label_9.insets = new Insets(0, 0, 0, 5); gbc_label_9.gridx = 0; gbc_label_9.gridy = 2; myHoHCard.add(mylabel_9, gbc_label_9); mypanel_3 = new JPanel(); mypanel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_3 = new GridBagConstraints(); gbc_panel_3.fill = GridBagConstraints.BOTH; gbc_panel_3.gridx = 1; gbc_panel_3.gridy = 2; myHoHCard.add(mypanel_3, gbc_panel_3); GridBagLayout gbl_panel_3 = new GridBagLayout(); gbl_panel_3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 50, 0, 0 }; gbl_panel_3.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_panel_3.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; mypanel_3.setLayout(gbl_panel_3); myHohSignatureEnabled = new JCheckBox("Enabled"); myHohSignatureEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { myConnection.setHohSignatureEnabled(myHohSignatureEnabled.isSelected()); } }); GridBagConstraints gbc_HohSignatureEnabled = new GridBagConstraints(); gbc_HohSignatureEnabled.insets = new Insets(0, 0, 5, 5); gbc_HohSignatureEnabled.gridx = 0; gbc_HohSignatureEnabled.gridy = 0; mypanel_3.add(myHohSignatureEnabled, gbc_HohSignatureEnabled); mylabel_10 = new JLabel("Keystore:"); GridBagConstraints gbc_label_10 = new GridBagConstraints(); gbc_label_10.anchor = GridBagConstraints.EAST; gbc_label_10.insets = new Insets(0, 0, 5, 5); gbc_label_10.gridx = 1; gbc_label_10.gridy = 0; mypanel_3.add(mylabel_10, gbc_label_10); myHohSignatureKeystoreTextbox = new JTextField(); myHohSignatureKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohSignatureKeystore(myHohSignatureKeystoreTextbox.getText()); } }); GridBagConstraints gbc_HohSignatureKeystoreTextbox2 = new GridBagConstraints(); gbc_HohSignatureKeystoreTextbox2.gridwidth = 5; gbc_HohSignatureKeystoreTextbox2.insets = new Insets(0, 0, 5, 5); gbc_HohSignatureKeystoreTextbox2.fill = GridBagConstraints.HORIZONTAL; gbc_HohSignatureKeystoreTextbox2.gridx = 2; gbc_HohSignatureKeystoreTextbox2.gridy = 0; mypanel_3.add(myHohSignatureKeystoreTextbox, gbc_HohSignatureKeystoreTextbox2); myHohSignatureKeystoreTextbox.setColumns(10); myHohSignatureKeystoreChooseButton = new JButton("Choose"); myHohSignatureKeystoreChooseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Hl7ConnectionPanel.chooseKeystore(Hl7ConnectionPanel.this, myHohSignatureKeystoreTextbox); } }); myHohSignatureKeystoreChooseButton.setIcon( new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); GridBagConstraints gbc_HohSignatureKeystoreChooseButton2 = new GridBagConstraints(); gbc_HohSignatureKeystoreChooseButton2.insets = new Insets(0, 0, 5, 0); gbc_HohSignatureKeystoreChooseButton2.gridx = 7; gbc_HohSignatureKeystoreChooseButton2.gridy = 0; mypanel_3.add(myHohSignatureKeystoreChooseButton, gbc_HohSignatureKeystoreChooseButton2); mylabel_11 = new JLabel("Store Pass:"); GridBagConstraints gbc_label_11 = new GridBagConstraints(); gbc_label_11.anchor = GridBagConstraints.EAST; gbc_label_11.insets = new Insets(0, 0, 5, 5); gbc_label_11.gridx = 1; gbc_label_11.gridy = 1; mypanel_3.add(mylabel_11, gbc_label_11); myHohSignatureKeystorePasswordTextbox = new JTextField(); myHohSignatureKeystorePasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohSignatureKeystorePassword(myHohSignatureKeystorePasswordTextbox.getText()); } }); myHohSignatureKeystorePasswordTextbox.setPreferredSize(new Dimension(100, 28)); myHohSignatureKeystorePasswordTextbox.setMinimumSize(new Dimension(100, 28)); myHohSignatureKeystorePasswordTextbox.setMaximumSize(new Dimension(200, 2147483647)); GridBagConstraints gbc_HohSignatureKeystorePasswordTextbox = new GridBagConstraints(); gbc_HohSignatureKeystorePasswordTextbox.insets = new Insets(0, 0, 5, 5); gbc_HohSignatureKeystorePasswordTextbox.fill = GridBagConstraints.HORIZONTAL; gbc_HohSignatureKeystorePasswordTextbox.gridx = 2; gbc_HohSignatureKeystorePasswordTextbox.gridy = 1; mypanel_3.add(myHohSignatureKeystorePasswordTextbox, gbc_HohSignatureKeystorePasswordTextbox); myHohSignatureKeystorePasswordTextbox.setColumns(10); mylabel_12 = new JLabel("Key:"); GridBagConstraints gbc_label_12 = new GridBagConstraints(); gbc_label_12.anchor = GridBagConstraints.EAST; gbc_label_12.insets = new Insets(0, 0, 5, 5); gbc_label_12.gridx = 3; gbc_label_12.gridy = 1; mypanel_3.add(mylabel_12, gbc_label_12); myHohSignatureKeyAliasCombo = new JComboBox(); myHohSignatureKeyAliasCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { if (myUpdatingHohSignatureKeyAliasCombo) { return; } String selection = (String) myHohSignatureKeyAliasCombo.getSelectedItem(); if (selection == HOH_SIGNATURE_KEY_USE_ANY_AVAILABLE) { myConnection.setHohSignatureKey(null); } else { myConnection.setHohSignatureKey(selection.replaceAll(" .*", "")); } } }); GridBagConstraints gbc_HohSignatureKeyAliasCombo = new GridBagConstraints(); gbc_HohSignatureKeyAliasCombo.insets = new Insets(0, 0, 5, 5); gbc_HohSignatureKeyAliasCombo.fill = GridBagConstraints.HORIZONTAL; gbc_HohSignatureKeyAliasCombo.gridx = 4; gbc_HohSignatureKeyAliasCombo.gridy = 1; mypanel_3.add(myHohSignatureKeyAliasCombo, gbc_HohSignatureKeyAliasCombo); mylabel_13 = new JLabel("Key Pass:"); GridBagConstraints gbc_label_13 = new GridBagConstraints(); gbc_label_13.anchor = GridBagConstraints.EAST; gbc_label_13.insets = new Insets(0, 0, 5, 5); gbc_label_13.gridx = 5; gbc_label_13.gridy = 1; mypanel_3.add(mylabel_13, gbc_label_13); myHohSignatureKeyPass = new JTextField(); myHohSignatureKeyPass.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myConnection.setHohSignatureKeyPassword(myHohSignatureKeyPass.getText()); } }); myHohSignatureKeyPass.setMinimumSize(new Dimension(50, 28)); myHohSignatureKeyPass.setMaximumSize(new Dimension(50, 2147483647)); myHohSignatureKeyPass.setPreferredSize(new Dimension(50, 28)); GridBagConstraints gbc_HohSignatureKeyPass = new GridBagConstraints(); gbc_HohSignatureKeyPass.gridwidth = 2; gbc_HohSignatureKeyPass.insets = new Insets(0, 0, 5, 0); gbc_HohSignatureKeyPass.fill = GridBagConstraints.HORIZONTAL; gbc_HohSignatureKeyPass.gridx = 6; gbc_HohSignatureKeyPass.gridy = 1; mypanel_3.add(myHohSignatureKeyPass, gbc_HohSignatureKeyPass); myHohSignatureKeyPass.setColumns(10); myHohSignatureStatusLabel = new JLabel("New label"); myHohSignatureStatusLabel.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_HohSignatureStatusLabel = new GridBagConstraints(); gbc_HohSignatureStatusLabel.fill = GridBagConstraints.HORIZONTAL; gbc_HohSignatureStatusLabel.gridwidth = 8; gbc_HohSignatureStatusLabel.insets = new Insets(0, 0, 0, 5); gbc_HohSignatureStatusLabel.gridx = 0; gbc_HohSignatureStatusLabel.gridy = 2; mypanel_3.add(myHohSignatureStatusLabel, gbc_HohSignatureStatusLabel); init(); }
From source file:gui.GW2EventerGui.java
/** * Creates new form GW2EventerGui/*w w w . java2 s. c om*/ */ public GW2EventerGui() { this.guiIcon = new ImageIcon(ClassLoader.getSystemResource("media/icon.png")).getImage(); if (System.getProperty("os.name").startsWith("Windows")) { this.OS = "Windows"; this.isWindows = true; } else { this.OS = "Other"; this.isWindows = false; } if (this.isWindows == true) { this.checkIniDir(); } initComponents(); this.speakQueue = new LinkedList(); this.speakRunnable = new Runnable() { @Override public void run() { String path = System.getProperty("user.home") + "\\.gw2eventer"; File f; String sentence; while (!speakQueue.isEmpty()) { f = new File(path + "\\tts.vbs"); if (!f.exists() && !f.isDirectory()) { sentence = (String) speakQueue.poll(); try { Writer writer = new OutputStreamWriter( new FileOutputStream( System.getProperty("user.home") + "\\.gw2eventer\\tts.vbs"), "ISO-8859-15"); BufferedWriter fout = new BufferedWriter(writer); fout.write("Dim Speak"); fout.newLine(); fout.write("Set Speak=CreateObject(\"sapi.spvoice\")"); fout.newLine(); fout.write("Speak.Speak \"" + sentence + "\""); fout.close(); Runtime rt = Runtime.getRuntime(); try { if (sentence.length() > 0) { Process p = rt.exec(System.getProperty("user.home") + "\\.gw2eventer\\tts.bat"); } } catch (IOException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } try { Thread.sleep(3000); } catch (InterruptedException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } else { try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } } } }; this.matchIds = new HashMap(); this.matchId = "2-6"; this.matchIdColor = "green"; this.jLabelNewVersion.setVisible(false); this.updateInformed = false; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(screenSize.width / 2 - this.getSize().width / 2, (screenSize.height / 2 - this.getSize().height / 2) - 20); double width = screenSize.getWidth(); double height = screenSize.getHeight(); if ((width == 1280) && (height == 720 || height == 768 || height == 800)) { this.setExtendedState(this.MAXIMIZED_BOTH); //this.setLocation(0, 0); } JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) this.jSpinnerRefreshTime.getEditor(); DefaultFormatter formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); /* jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayX.getEditor(); formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayY.getEditor(); formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); */ this.workingButton = this.jButtonRefresh; this.refreshSelector = this.jCheckBoxAutoRefresh; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { apiManager.saveSettingstoFile(); System.exit(0); } }); this.pushGui = new PushGui(this, true, "", ""); this.pushGui.setIconImage(guiIcon); this.donateGui = new DonateGui(this, true); this.donateGui.setIconImage(guiIcon); this.infoGui = new InfoGui(this, true); this.infoGui.setIconImage(guiIcon); this.feedbackGui = new FeedbackGui(this, true); this.feedbackGui.setIconImage(guiIcon); this.overlayGui = new OverlayGui(this); this.initOverlayGui(); this.settingsOverlayGui = new SettingsOverlayGui(this); this.initSettingsOverlayGui(); this.wvwOverlayGui = new WvWOverlayGui(this); this.initWvwOverlayGui(); this.language = "en"; this.worldID = "2206"; //Millersund [DE] this.setTranslations(); this.eventLabels = new ArrayList(); this.eventLabelsTimer = new ArrayList(); this.homeWorlds = new HashMap(); this.preventSystemSleep = true; for (int i = 1; i <= EVENT_COUNT; i++) { try { Field f = getClass().getDeclaredField("labelEvent" + i); JLabel l = (JLabel) f.get(this); l.setPreferredSize(new Dimension(70, 28)); //l.setToolTipText(""); //int width2 = l.getX(); //int height2 = l.getY(); //System.out.println("$coords .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";"); this.eventLabels.add(l); final int ii = i; l.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mousePressed(java.awt.event.MouseEvent evt) { showSoundSelector(ii); } }); f = getClass().getDeclaredField("labelTimer" + i); l = (JLabel) f.get(this); l.setEnabled(true); l.setVisible(false); l.setForeground(Color.green); //int width2 = l.getX(); //int height2 = l.getY(); //System.out.println("$coords2 .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";"); this.eventLabelsTimer.add(l); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } int[] disabledEvents = { 6, 8, 11, 12, 17, 18, 19, 20, 21, 22 }; for (int i = 0; i < disabledEvents.length; i++) { Field f; JLabel l; try { f = getClass().getDeclaredField("labelEvent" + disabledEvents[i]); l = (JLabel) f.get(this); l.setEnabled(false); l.setVisible(false); f = getClass().getDeclaredField("labelTimer" + disabledEvents[i]); l = (JLabel) f.get(this); l.setEnabled(false); l.setVisible(false); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } this.lastPush = new Date(); if (this.apiManager == null) { this.apiManager = new ApiManager(this, this.jSpinnerRefreshTime, this.jCheckBoxAutoRefresh.isSelected(), this.eventLabels, this.language, this.worldID, this.homeWorlds, this.jComboBoxHomeWorld, this.jLabelServer, this.jLabelWorking, this.jCheckBoxPlaySounds.isSelected(), this.workingButton, this.refreshSelector, this.eventLabelsTimer, this.jComboBoxLanguage, this.overlayGui, this.jCheckBoxWvWOverlay); } //this.wvwMatchReader = new WvWMatchReader(this.matchIds, this.jCheckBoxWvW); //this.wvwMatchReader.start(); this.preventSleepMode(); this.runUpdateService(); this.runPushService(); this.runTips(); //this.runTest(); }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo adibito alla creazione dinamica ricorsiva dell'interfaccia dei * metadati/* w w w . ja va2 s.c o m*/ * * @param submetadatas Map contente i metadati e i sottolivelli di metadati * @param vocabularies Map contenente i dati contenuti nel file xml * vocabulary.xml * @param parent Jpanel nel quale devono venir inseriti i metadati * @param level Livello corrente */ public void create_metadata_view(Map<Object, Metadata> submetadatas, JPanel parent, int level, final String panelname) throws Exception { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); int lenght = submetadatas.size(); int labelwidth = 220; int i = 0; JButton addcontribute = null; for (Map.Entry<Object, Metadata> kv : submetadatas.entrySet()) { ArrayList<Component> tabobjects = new ArrayList<Component>(); if (kv.getValue().MID == 17 || kv.getValue().MID == 23 || kv.getValue().MID == 18 || kv.getValue().MID == 137) { continue; } //Crea un jpanel nuovo e fa appen su parent JPanel innerPanel = new JPanel(new MigLayout("fillx, insets 1 1 1 1")); innerPanel.setName("pannello" + level + i); i++; String datatype = kv.getValue().datatype.toString(); if (kv.getValue().MID == 45) { JPanel choice = new JPanel(new MigLayout()); JComboBox combo = addClassificationChoice(choice, kv.getValue().sequence, panelname); JLabel labelc = new JLabel(); labelc.setText(Utility.getBundleString("selectclassif", bundle)); labelc.setPreferredSize(new Dimension(100, 20)); choice.add(labelc); findLastClassification(panelname); if (last_classification != 0 && classificationRemoveButton == null) { logger.info("Removing last clasification"); classificationRemoveButton = new JButton("-"); classificationRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); removeClassificationToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); findLastClassification(panelname); //update last_classification BookImporter.getInstance().setCursor(null); } }); if (Integer.parseInt(kv.getValue().sequence) == last_classification) { choice.add(classificationRemoveButton, "wrap, width :50:"); } } if (classificationAddButton == null) { logger.info("Adding a new classification"); choice.add(combo, "width 100:600:600"); classificationAddButton = new JButton("+"); classificationAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addClassificationToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); choice.add(classificationAddButton, "width :50:"); } else { //choice.add(combo, "wrap,width 100:700:700"); choice.add(combo, "width 100:700:700"); if (Integer.parseInt(kv.getValue().sequence) == last_classification) { choice.add(classificationRemoveButton, "wrap, width :50"); } } parent.add(choice, "wrap,width 100:700:700"); classificationMID = kv.getValue().MID; innerPanel.setName(panelname + "---ImPannelloClassif---" + kv.getValue().sequence); try { addClassification(innerPanel, classificationMID, kv.getValue().sequence, panelname); } catch (Exception ex) { logger.error("Errore nell'aggiunta delle classificazioni"); } parent.add(innerPanel, "wrap, growx"); BookImporter.policy.addIndexedComponent(combo); continue; } if (datatype.equals("Node")) { JLabel label = new JLabel(); label.setText(kv.getValue().description); label.setPreferredSize(new Dimension(100, 20)); int size = 16 - (level * 2); Font myFont = new Font("MS Sans Serif", Font.PLAIN, size); label.setFont(myFont); if (Integer.toString(kv.getValue().MID).equals("11")) { JPanel temppanel = new JPanel(new MigLayout()); //update last_contribute findLastContribute(panelname); if (last_contribute != 0 && removeContribute == null) { logger.info("Removing last contribute"); removeContribute = new JButton("-"); removeContribute.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance() .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); removeContributorToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); if (!kv.getValue().sequence.equals("")) { if (Integer.parseInt(kv.getValue().sequence) == last_contribute) { innerPanel.add(removeContribute, "width :50:"); } } } if (addcontribute == null) { logger.info("Adding a new contribute"); addcontribute = new JButton("+"); addcontribute.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance() .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addContributorToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); temppanel.add(label, " width :200:"); temppanel.add(addcontribute, "width :50:"); innerPanel.add(temppanel, "wrap, growx"); } else { temppanel.add(label, " width :200:"); findLastContribute(panelname); if (!kv.getValue().sequence.equals("")) { if (Integer.parseInt(kv.getValue().sequence) == last_contribute) { temppanel.add(removeContribute, "width :50:"); } } innerPanel.add(temppanel, "wrap, growx"); } } else if (Integer.toString(kv.getValue().MID).equals("115")) { logger.info("Devo gestire una provenience!"); } } else { String title = ""; if (kv.getValue().mandatory.equals("Y") || kv.getValue().MID == 14 || kv.getValue().MID == 15) { title = kv.getValue().description + " *"; } else { title = kv.getValue().description; } innerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title, TitledBorder.LEFT, TitledBorder.TOP)); if (datatype.equals("Vocabulary")) { TreeMap<String, String> entryCombo = new TreeMap<String, String>(); int index = 0; String selected = null; if (!Integer.toString(kv.getValue().MID).equals("8")) entryCombo.put(Utility.getBundleString("comboselect", bundle), Utility.getBundleString("comboselect", bundle)); for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) { String tempmid = Integer.toString(kv.getValue().MID); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { String[] testmid = tempmid.split("---"); tempmid = testmid[0]; } if (vc.getKey().equals(tempmid)) { TreeMap<String, VocEntry> iEntry = vc.getValue(); for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) { entryCombo.put(ivc.getValue().description, ivc.getValue().ID); if (kv.getValue().value != null) { if (kv.getValue().value.equals(ivc.getValue().ID)) { selected = ivc.getValue().ID; } } index++; } } } final ComboMapImpl model = new ComboMapImpl(); model.setVocabularyCombo(true); model.putAll(entryCombo); final JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence); } else { voc.setName("MID_" + Integer.toString(kv.getValue().MID)); } if (Integer.toString(kv.getValue().MID).equals("8") && selected == null) selected = "44"; selected = (selected == null) ? Utility.getBundleString("comboselect", bundle) : selected; for (int k = 0; k < voc.getItemCount(); k++) { Map.Entry<String, String> el = (Map.Entry<String, String>) voc.getItemAt(k); if (el.getValue().equals(selected)) voc.setSelectedIndex(k); } voc.setPreferredSize(new Dimension(150, 30)); innerPanel.add(voc, "wrap, width :400:"); tabobjects.add(voc); } else if (datatype.equals("CharacterString") || datatype.equals("GPS")) { final JTextArea textField = new javax.swing.JTextArea(); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { textField.setName( "MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence); } else { textField.setName("MID_" + Integer.toString(kv.getValue().MID)); } textField.setPreferredSize(new Dimension(230, 0)); textField.setText(kv.getValue().value); textField.setLineWrap(true); textField.setWrapStyleWord(true); innerPanel.add(textField, "wrap, width :300:"); textField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (e.getModifiers() > 0) { textField.transferFocusBackward(); } else { textField.transferFocus(); } e.consume(); } } }); tabobjects.add(textField); } else if (datatype.equals("LangString")) { JScrollPane inner_scroll = new javax.swing.JScrollPane(); inner_scroll.setHorizontalScrollBarPolicy( javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); inner_scroll.setVerticalScrollBarPolicy( javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); inner_scroll.setPreferredSize(new Dimension(240, 80)); inner_scroll.setName("langStringScroll"); final JTextArea jTextArea1 = new javax.swing.JTextArea(); jTextArea1.setName("MID_" + Integer.toString(kv.getValue().MID)); jTextArea1.setText(kv.getValue().value); jTextArea1.setSize(new Dimension(350, 70)); jTextArea1.setLineWrap(true); jTextArea1.setWrapStyleWord(true); inner_scroll.setViewportView(jTextArea1); innerPanel.add(inner_scroll, "width :300:"); //Add combo language box JComboBox voc = getComboLangBox(kv.getValue().language); voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "_lang"); voc.setPreferredSize(new Dimension(200, 20)); innerPanel.add(voc, "wrap, width :300:"); jTextArea1.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (e.getModifiers() > 0) { jTextArea1.transferFocusBackward(); } else { jTextArea1.transferFocus(); } e.consume(); } } }); tabobjects.add(jTextArea1); tabobjects.add(voc); } else if (datatype.equals("Language")) { final JComboBox voc = getComboLangBox(kv.getValue().value); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :500:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("Boolean")) { int selected = 0; TreeMap bin = new TreeMap<String, String>(); bin.put("yes", Utility.getBundleString("voc1", bundle)); bin.put("no", Utility.getBundleString("voc2", bundle)); if (kv.getValue().value == null) { switch (kv.getValue().MID) { case 35: selected = 0; break; case 36: selected = 1; break; } } else if (kv.getValue().value.equals("yes")) { selected = 1; } else { selected = 0; } final ComboMapImpl model = new ComboMapImpl(); model.putAll(bin); final JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setSelectedIndex(selected); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :300:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("License")) { String selectedIndex = null; int vindex = 0; int defaultIndex = 0; TreeMap<String, String> entryCombo = new TreeMap<String, String>(); for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) { if (vc.getKey().equals(Integer.toString(kv.getValue().MID))) { TreeMap<String, VocEntry> iEntry = vc.getValue(); for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) { entryCombo.put(ivc.getValue().description, ivc.getValue().ID); if (ivc.getValue().ID.equals("1")) defaultIndex = vindex; if (kv.getValue().value != null) { if (ivc.getValue().ID.equals(kv.getValue().value)) { selectedIndex = Integer.toString(vindex); } } vindex++; } } } if (selectedIndex == null) selectedIndex = Integer.toString(defaultIndex); ComboMapImpl model = new ComboMapImpl(); model.putAll(entryCombo); model.setVocabularyCombo(true); JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setSelectedIndex(Integer.parseInt(selectedIndex)); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :500:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("DateTime")) { //final JXDatePicker datePicker = new JXDatePicker(); JDateChooser datePicker = new JDateChooser(); datePicker.setName("MID_" + Integer.toString(kv.getValue().MID)); JPanel test = new JPanel(new MigLayout()); JLabel lbefore = new JLabel(Utility.getBundleString("beforechristlabel", bundle)); JCheckBox beforechrist = new JCheckBox(); beforechrist.setName("MID_" + Integer.toString(kv.getValue().MID) + "_check"); if (kv.getValue().value != null) { try { if (kv.getValue().value.charAt(0) == '-') { beforechrist.setSelected(true); } Date date1 = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (kv.getValue().value.charAt(0) == '-') { date1 = sdf.parse(adjustDate(kv.getValue().value)); } else { date1 = sdf.parse(kv.getValue().value); } datePicker.setDate(date1); } catch (Exception e) { //Console.WriteLine("ERROR import date:" + ex.Message); } } test.add(datePicker, "width :200:"); test.add(lbefore, "gapleft 30"); test.add(beforechrist, "wrap"); innerPanel.add(test, "wrap"); } } //Recursive call create_metadata_view(kv.getValue().submetadatas, innerPanel, level + 1, panelname); if (kv.getValue().editable.equals("Y") || (datatype.equals("Node") && kv.getValue().hidden.equals("0"))) { parent.add(innerPanel, "wrap, growx"); for (Component tabobject : tabobjects) { BookImporter.policy.addIndexedComponent(tabobject); } } } }
From source file:fs.MainWindow.java
public void GenerateTable(Object[][] data, String title, String subtitle, final String[] titles) { JFrame window = new JFrame(title); window.setLayout(new java.awt.BorderLayout(5, 5)); JLabel label = new JLabel(subtitle); label.setFont(new java.awt.Font("Tahoma", 1, 12)); label.setForeground(new java.awt.Color(0, 0, 255)); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setOpaque(true);/*w w w . j av a2 s .c o m*/ label.setPreferredSize(new java.awt.Dimension(50, 30)); ListModel lm = new AbstractListModel() { String headers[] = titles; @Override public int getSize() { return headers.length; } @Override public Object getElementAt(int index) { return headers[index]; } }; // String[] titles = getClasses(); JList rowHeader = new JList(lm); rowHeader.setFixedCellWidth(50); JTable jTable = new JTable(data, titles); rowHeader.setFixedCellHeight(jTable.getRowHeight()); rowHeader.setCellRenderer(new RowHeaderRenderer(jTable)); JScrollPane scroll = new JScrollPane(jTable); scroll.setRowHeaderView(rowHeader); getContentPane().add(scroll, BorderLayout.CENTER); jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTable.setAlignmentX(JTable.CENTER_ALIGNMENT); window.add(label, java.awt.BorderLayout.NORTH); window.add(scroll, java.awt.BorderLayout.CENTER); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); window.setBounds((screenSize.width - 800) / 2, (screenSize.height - 270) / 2, 800, 270); window.setVisible(true); }
From source file:com.osparking.osparking.Settings_System.java
private void initComPortIDLabel(JLabel comPortIDLabel) { short labelWidth = 115; comPortIDLabel.setFont(new java.awt.Font(font_Type, font_Style, font_Size)); comPortIDLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); comPortIDLabel.setText(COM_PORT_ID_LABEL.getContent()); comPortIDLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); comPortIDLabel.setMaximumSize(new java.awt.Dimension(labelWidth, 25)); comPortIDLabel.setMinimumSize(new java.awt.Dimension(labelWidth, 25)); comPortIDLabel.setPreferredSize(new java.awt.Dimension(labelWidth, 25)); comPortIDLabel.setFont(new java.awt.Font(font_Type, font_Style, font_Size)); }
From source file:net.team2xh.crt.gui.util.GUIToolkit.java
/** * Displays a dialog with "OK" button./*from ww w . j a v a 2 s. co m*/ * * @param parent Parent window * @param message Message (can contain "\n" characters) * @param title Dialog title * @param type Icon type (use JOptionPane static values) */ public static void showOkDialog(java.awt.Window parent, String message, String title, int type) { SwingUtilities.invokeLater(() -> { Object[] options = { "OK" }; JLabel msg = new JLabel(convertToMultiline(message)); Dimension sz = msg.getPreferredSize(); msg.setPreferredSize(new Dimension(sz.width + 20, sz.height)); JOptionPane.showOptionDialog(parent, msg, title, JOptionPane.DEFAULT_OPTION, type, null, options, options[0]); }); }
From source file:nz.ac.waikato.cms.supernova.gui.Supernova.java
/** * Adjusts the collected labels./*from w w w .j av a2 s . c o m*/ */ protected void adjustLabels() { int max; max = 0; for (JLabel label : m_ParamLabels) max = (int) Math.max(label.getPreferredSize().getWidth(), max); for (JLabel label : m_ParamLabels) label.setPreferredSize(new Dimension(max, (int) label.getPreferredSize().getHeight())); }
From source file:org.dwfa.ace.classifier.CNFormsLabelPanel.java
private void setBorder(JLabel tLabel, Color deltaColor) { if (deltaColor == null) { deltaColor = Color.white; }/*from www .j a v a 2 s . c om*/ Dimension size = tLabel.getSize(); tLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 5, 1, 5, deltaColor), BorderFactory.createEmptyBorder(1, 3, 1, 3)))); size.width = size.width + 18; size.height = size.height + 6; tLabel.setSize(size); tLabel.setPreferredSize(size); tLabel.setMaximumSize(size); tLabel.setMinimumSize(size); }
From source file:org.ecoinformatics.seek.ecogrid.CheckBoxTableCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { jTable = table;//from w w w. jav a 2 s. c om JPanel cellPanel = new JPanel(); cellPanel.setBorder(new LineBorder(Color.lightGray, 1)); cellPanel.setBackground(Color.WHITE); cellPanel.setPreferredSize( new Dimension(ServicesDisplayPanel.CELLPREFERREDWIDTH, ServicesDisplayPanel.HEIGHT)); SelectableDocumentType selectedDocumentType = null; boolean isChecked = false; boolean isEnable = true; String text = null; if (value != null && value instanceof SelectableObjectInterface) { SelectableObjectInterface selectedObj = (SelectableObjectInterface) value; text = selectedObj.getSelectableObjectLabel(); isChecked = selectedObj.getIsSelected(); isEnable = selectedObj.getEnabled(); } /* * label = (JLabel)renderer.getTableCellRendererComponent(table, text, * isSelected, hasFocus, row, column); */ JLabel label = new JLabel(text); label.setFont(new Font(FONTNAME, Font.PLAIN, FONTSIZE)); label.setPreferredSize(new Dimension(ServicesDisplayPanel.LABELPREFERWIDTH, ServicesDisplayPanel.HEIGHT)); // set a check box name String checkBoxName = "" + topRowNum + SEPERATOR + row; JCheckBox checkBox = new JCheckBox(); checkBox.setName(checkBoxName); checkBox.setBackground(Color.WHITE); checkBox.setSelected(isChecked); CheckBoxListener listener = new CheckBoxListener(); checkBox.addItemListener(listener); // checkBox.setEnabled(false); /* * if (topRowNum != DEFAUTTOPROW ) { // for sub table we need to set up * check box enable status checkBox.setEnabled(isEnable); }//if */ // add the label and checkbox to jpanel which has a border layout // manager BorderLayout layoutManager = new BorderLayout(); cellPanel.setLayout(layoutManager); cellPanel.add(label, BorderLayout.CENTER); cellPanel.add(checkBox, BorderLayout.WEST); return cellPanel; }