public JFrame buildFrame() { f = new JFrame("AMSA World"); f.setSize(800, 600); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new GridBagLayout()); textArea.setFocusable(false); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent evt) { checkInput(); } }; inputText.addActionListener(listener); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1.0; c.gridwidth = 3; c.weighty = 0.025; c.gridx = 0; c.gridy = 0; f.add(topPanel, c); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.gridwidth = 2; c.gridx = 0; c.gridy = 1; f.add(scrollPane, c); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.gridwidth = 1; c.gridx = 2; c.gridy = 1; f.add(sidePanel, c); sidePanel.setVisible(false); c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 0.025; c.gridwidth = 3; c.gridx = 0; c.gridy = 2; f.add(inputText, c); f.setVisible(true); return f; }
/** Créer les composants */ private void initComponents() { text = new JTextArea(); button_licence = new JButton(); button_close = new JButton(); logo = new LogoComponent(); // Ajout des actions listeners button_licence.addActionListener(new ButtonLicenceActionListener()); button_close.addActionListener(new ButtonCloseActionListener(this)); logo.setPreferredSize(new Dimension(128, 128)); text.setText( "Version : 1.0b \n" + "\n" + "Copyright © 2008-2012 Sipieter Clément \n" + "Copyright © 2011-2012 Sellem Lev-Arcady"); text.setBackground(this.getBackground()); button_licence.setText("Licence"); button_close.setText("Fermer"); this.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; this.add(logo, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.insets = new Insets(20, 20, 20, 20); this.add(text, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 1; gbc.insets = new Insets(5, 5, 20, 5); this.add(button_licence, gbc); gbc.gridx = 2; gbc.gridy = 2; this.add(button_close, gbc); this.pack(); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
/** * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as * <tt>CallPeer</tt> display name, call duration, security status. * * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information * such as <tt>CallPeer</tt> display name, call duration, security status */ private Component createStatusBar() { // stateLabel callStatusLabel.setForeground(Color.WHITE); dtmfLabel.setForeground(Color.WHITE); callStatusLabel.setText(callPeer.getState().getLocalizedStateString()); PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; statusPanel.add(securityStatusLabel, constraints); initSecurityStatusLabel(); constraints.gridx++; statusPanel.add(holdStatusLabel, constraints); constraints.gridx++; statusPanel.add(muteStatusLabel, constraints); constraints.gridx++; callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12)); statusPanel.add(callStatusLabel, constraints); constraints.gridx++; constraints.weightx = 1f; statusPanel.add(dtmfLabel, constraints); return statusPanel; }
private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) { JLabel spaces = new JLabel(" "); gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(spaces, gbc); m_pnlDisplay.add(spaces); }
public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) { GridBagLayout gridbag = (GridBagLayout) getLayout(); labelPair = lp; label = new JLabel(labelPair.getSingular(), JLabel.LEFT); pane.getDocument().addDocumentListener(this); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 20, 0, 00); gridbag.setConstraints(pane, c); add(pane); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 20); gridbag.setConstraints(label, c); add(label); JPanel filler = new JPanel(); filler.setBackground(white); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.8; c.weighty = 0.8; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; gridbag.setConstraints(filler, c); add(filler); filler = null; c = null; }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { // gbc.weightx = 0.5; showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1); showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2); showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3); /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 ); showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/ showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel("")); // i18n // label = new JLabel( "LABEL" ); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 5; // gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 5; m_gbc.ipadx = 0; m_gbc.gridwidth = 5; m_gbc.weightx = 0; m_gbl.setConstraints(label, m_gbc); // add( label ); // i18n // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" )); showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY"))); m_nRow = 5; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder( " Parent Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
private void showComp( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JComponent comp) { gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(comp, gbc); m_pnlDisplay.add(comp); }
protected GridBagConstraints createConstraints(int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = 2; c.gridheight = 1; c.ipadx = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; return c; }
private void addGrid( JPanel p, Component co, int x, int y, int w, int fill, double wx, int anchor) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = w; c.anchor = anchor; c.weightx = wx; c.fill = fill; if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty = 1.0; c.insets = new Insets(y == 0 ? 10 : 0, GAP, GAP, GAP); p.add(co, c); }
private void showInstruction( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JLabel instruction) { gbc.gridwidth = gridwidth; gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(instruction, gbc); instruction.setForeground(Color.black); m_pnlDisplay.add(instruction); }
/** * Sets the reason of a call failure if one occurs. The renderer should display this reason to the * user. * * @param reason the reason to display */ public void setErrorReason(final String reason) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { setErrorReason(reason); } }); return; } if (errorMessageComponent == null) { errorMessageComponent = new JTextPane(); JTextPane textPane = (JTextPane) errorMessageComponent; textPane.setEditable(false); textPane.setOpaque(false); StyledDocument doc = textPane.getStyledDocument(); MutableAttributeSet standard = new SimpleAttributeSet(); StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER); StyleConstants.setFontFamily(standard, textPane.getFont().getFamily()); StyleConstants.setFontSize(standard, 12); doc.setParagraphAttributes(0, 0, standard, true); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy = 4; constraints.weightx = 1; constraints.weighty = 0; constraints.insets = new Insets(5, 0, 0, 0); add(errorMessageComponent, constraints); this.revalidate(); } errorMessageComponent.setText(reason); if (isVisible()) errorMessageComponent.repaint(); }
private void drawComponents() { GridBagConstraints con = new GridBagConstraints(); con.gridx = 0; con.gridy = 0; con.gridwidth = 1; con.gridheight = 1; con.anchor = GridBagConstraints.NORTH; con.fill = GridBagConstraints.HORIZONTAL; con.insets = new Insets(5, 5, 5, 5); con.weightx = 0; con.weighty = 0; Box btns = Box.createHorizontalBox(); btns.add(btnDetails); btns.add(Box.createHorizontalGlue()); btns.add(btnClose); // Set up content Container content = getContentPane(); content.setLayout(new GridBagLayout()); // Add message label con.weightx = 1; con.weighty = 1; content.add(lblMessage, con); // Add button box con.gridy = 1; con.weighty = 0; content.add(btns, con); // Add trace pane con.gridy = 2; content.add(srlTrace, con); // Set default button getRootPane().setDefaultButton(btnClose); }
/** * The consturctor Constructor instantiates all the panels, convertible value instance, and the * frame. And adds the panels to the frame. And sets a proper size for the frame. */ public HappyHackingConverter() { CFrame frame = new CFrame(); frame.setBackground(white); ConvertibleValue temperatures = new ConvertibleValue(); ConvertibleValue distances = new ConvertibleValue(); ConvertibleValue weights = new ConvertibleValue(); GridBagLayout leftSideLayout = new GridBagLayout(); JPanel leftSide = new JPanel(leftSideLayout); leftSide.setBackground(white); GridBagLayout rightSideLayout = new GridBagLayout(); JPanel rightSide = new JPanel(rightSideLayout); rightSide.setBackground(white); GridBagConstraints metricTemperatureConstraints = new GridBagConstraints(); metricTemperatureConstraints.gridx = 0; metricTemperatureConstraints.gridy = 0; metricTemperatureConstraints.weighty = 0.1; metricTemperatureConstraints.weightx = 1; metricTemperatureConstraints.fill = GridBagConstraints.BOTH; metricTemperatureConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel metricTemperaturePanel = new TemperaturePanel(frame, temperatures, TemperatureScales.CENTIGRADE); leftSideLayout.setConstraints(metricTemperaturePanel, metricTemperatureConstraints); leftSide.add(metricTemperaturePanel); GridBagConstraints metricDistancesPanelConstraints = new GridBagConstraints(); metricDistancesPanelConstraints.gridx = 0; metricDistancesPanelConstraints.gridy = 1; metricDistancesPanelConstraints.weighty = 0.3; metricDistancesPanelConstraints.weightx = 1; metricDistancesPanelConstraints.fill = GridBagConstraints.BOTH; metricDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel metricDistancesPanel = new MetricDistancesPanel(frame, distances); leftSideLayout.setConstraints(metricDistancesPanel, metricDistancesPanelConstraints); leftSide.add(metricDistancesPanel); GridBagConstraints fahrenheitConstraints = new GridBagConstraints(); fahrenheitConstraints.gridx = 0; fahrenheitConstraints.gridy = 0; fahrenheitConstraints.weighty = 0.1; fahrenheitConstraints.weightx = 1; fahrenheitConstraints.fill = GridBagConstraints.BOTH; fahrenheitConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel fahrenheitTemperaturePanel = new TemperaturePanel(frame, temperatures, TemperatureScales.FAHRENHEIT); rightSideLayout.setConstraints(fahrenheitTemperaturePanel, fahrenheitConstraints); rightSide.add(fahrenheitTemperaturePanel); GridBagConstraints imperialDistancesPanelConstraints = new GridBagConstraints(); imperialDistancesPanelConstraints.gridx = 0; imperialDistancesPanelConstraints.gridy = 1; imperialDistancesPanelConstraints.weighty = 0.3; imperialDistancesPanelConstraints.weightx = 1; imperialDistancesPanelConstraints.fill = GridBagConstraints.BOTH; imperialDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel imperialDistancesPanel = new ImperialDistancesPanel(frame, distances); rightSideLayout.setConstraints(imperialDistancesPanel, imperialDistancesPanelConstraints); rightSide.add(imperialDistancesPanel); GridBagConstraints metricWeightsConstraints = new GridBagConstraints(); metricWeightsConstraints.gridx = 0; metricWeightsConstraints.gridy = 2; metricWeightsConstraints.weighty = 0.6; metricWeightsConstraints.weightx = 1; metricWeightsConstraints.fill = GridBagConstraints.BOTH; metricWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START; MetricWeightsPanel metricWeightsPanel = new MetricWeightsPanel(frame, weights); leftSideLayout.setConstraints(metricWeightsPanel, metricWeightsConstraints); leftSide.add(metricWeightsPanel); GridBagConstraints imperialWeightsConstraints = new GridBagConstraints(); imperialWeightsConstraints.gridx = 0; imperialWeightsConstraints.gridy = 2; imperialWeightsConstraints.weighty = 0.6; imperialWeightsConstraints.weightx = 1; imperialWeightsConstraints.fill = GridBagConstraints.BOTH; imperialWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START; ImperialWeightsPanel imperialWeightsPanel = new ImperialWeightsPanel(frame, weights); rightSideLayout.setConstraints(imperialWeightsPanel, imperialWeightsConstraints); rightSide.add(imperialWeightsPanel); CSplit split = new CSplit(JSplitPane.HORIZONTAL_SPLIT, true, leftSide, rightSide); Container contentPane = frame.getContentPane(); contentPane.add(split); frame.validate(); frame.pack(); frame.setSize(600, 997); split.setResizeWeight(0.5); split.setDividerLocation(0.5); } // end of HappyHackingConverter constructor
/** Creates sound level related components. */ private void createSoundLevelIndicators() { TransparentPanel localLevelPanel = new TransparentPanel(new BorderLayout(5, 0)); TransparentPanel remoteLevelPanel = new TransparentPanel(new BorderLayout(5, 0)); localLevel = new InputVolumeControlButton( call, ImageLoader.MICROPHONE, ImageLoader.MUTE_BUTTON, false, false); remoteLevel = new OutputVolumeControlButton(call.getConference(), ImageLoader.HEADPHONE, false, false) .getComponent(); final SoundLevelIndicator localLevelIndicator = new SoundLevelIndicator(SoundLevelChangeEvent.MIN_LEVEL, SoundLevelChangeEvent.MAX_LEVEL); final SoundLevelIndicator remoteLevelIndicator = new SoundLevelIndicator(SoundLevelChangeEvent.MIN_LEVEL, SoundLevelChangeEvent.MAX_LEVEL); localLevelPanel.add(localLevel, BorderLayout.WEST); localLevelPanel.add(localLevelIndicator, BorderLayout.CENTER); remoteLevelPanel.add(remoteLevel, BorderLayout.WEST); remoteLevelPanel.add(remoteLevelIndicator, BorderLayout.CENTER); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 5; constraints.weightx = 0; constraints.weighty = 0; constraints.insets = new Insets(10, 0, 0, 0); add(localLevelPanel, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 6; constraints.weightx = 0; constraints.weighty = 0; constraints.insets = new Insets(5, 0, 10, 0); add(remoteLevelPanel, constraints); if (!GuiActivator.getConfigurationService() .getBoolean( "net.java.sip.communicator.impl.gui.main.call." + "DISABLE_SOUND_LEVEL_INDICATORS", false)) { callPeer.addStreamSoundLevelListener( new SoundLevelListener() { public void soundLevelChanged(Object source, int level) { remoteLevelIndicator.updateSoundLevel(level); } }); /* * By the time the UI gets to be initialized, the callPeer may have * been removed from its Call. As far as the UI is concerned, the * callPeer will never have a Call again and there will be no audio * levels to display anyway so there is no point in throwing a * NullPointerException here. */ if (call != null) { call.addLocalUserSoundLevelListener( new SoundLevelListener() { public void soundLevelChanged(Object source, int level) { localLevelIndicator.updateSoundLevel(level); } }); } } }
/** * Creates a <tt>CallPeerPanel</tt> for the given call peer. * * @param callRenderer the renderer of the call * @param callPeer the <tt>CallPeer</tt> represented in this panel * @param uiVideoHandler the facility which is to aid the new instance in the dealing with the * video-related information */ public OneToOneCallPeerPanel( SwingCallRenderer callRenderer, CallPeer callPeer, UIVideoHandler2 uiVideoHandler) { this.callRenderer = callRenderer; this.callPeer = callPeer; // we need to obtain call as soon as possible // cause if it fails too quickly we may fail to show it this.call = callPeer.getCall(); this.uiVideoHandler = uiVideoHandler; peerName = CallManager.getPeerDisplayName(callPeer); securityPanel = SecurityPanel.create(this, callPeer, null); photoLabel = new JLabel(getPhotoLabelIcon()); center = createCenter(); statusBar = createStatusBar(); setPeerImage(CallManager.getPeerImage(callPeer)); /* Lay out the main Components of the UI. */ setLayout(new GridBagLayout()); GridBagConstraints cnstrnts = new GridBagConstraints(); if (center != null) { cnstrnts.fill = GridBagConstraints.BOTH; cnstrnts.gridx = 0; cnstrnts.gridy = 1; cnstrnts.weightx = 1; cnstrnts.weighty = 1; add(center, cnstrnts); } if (statusBar != null) { cnstrnts.fill = GridBagConstraints.NONE; cnstrnts.gridx = 0; cnstrnts.gridy = 3; cnstrnts.weightx = 0; cnstrnts.weighty = 0; cnstrnts.insets = new Insets(5, 0, 0, 0); add(statusBar, cnstrnts); } createSoundLevelIndicators(); initSecuritySettings(); /* * Add the listeners which will be notified about changes in the model * and which will update this view. */ callPeerAdapter = new CallPeerAdapter(callPeer, this); uiVideoHandler.addObserver(uiVideoHandlerObserver); /* * This view adapts to whether it is displayed in full-screen or * windowed mode. */ if (callRenderer instanceof Component) { ((Component) callRenderer).addPropertyChangeListener(CallContainer.PROP_FULL_SCREEN, this); } OperationSetDesktopSharingClient desktopSharingClient = callPeer.getProtocolProvider().getOperationSet(OperationSetDesktopSharingClient.class); if (desktopSharingClient != null) { desktopSharingMouseAndKeyboardListener = new DesktopSharingMouseAndKeyboardListener(callPeer, desktopSharingClient); } else desktopSharingMouseAndKeyboardListener = null; updateViewFromModel(); }