List of usage examples for javax.swing JLabel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:com.lottery.gui.MainLotteryForm.java
private void btnAddNumberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddNumberActionPerformed try {/*from w w w . jav a 2 s . co m*/ Integer number = Integer.parseInt(inputNumberTf.getText()); if (inputNumbers.contains(number)) { JOptionPane.showMessageDialog(this, "Number has already existed!"); return; } if (number > LotteryUtils.MAX_BALL_VALUE || number < LotteryUtils.MIN_BALL_VALUE) { JOptionPane.showMessageDialog(this, "Invalid range (" + LotteryUtils.MIN_BALL_VALUE + " - " + LotteryUtils.MAX_BALL_VALUE + ")!"); return; } JLabel numberLbl = new JLabel(number + ""); numberLbl.setOpaque(true); //numberLbl.setMinimumSize(new Dimension(100, 100)); // numberLbl.setPreferredSize(new Dimension(400, 100)); // numberLbl.setBackground(Color.white); numberLbl.setForeground(Color.red); setFont(numberLbl.getFont().deriveFont(150f)); numberLbl.setFont(new Font("Serif", Font.PLAIN, 30)); int numberOfInput = inputNumbers.size(); int row = numberOfInput / NO_NUMBER_PER_ROW; int col = numberOfInput % NO_NUMBER_PER_ROW; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = col; c.gridy = row; c.weightx = 0.5; ballNumbersPanel.add(numberLbl, c); lbNumbers.add(numberLbl); inputNumbers.add(number); ballNumbersPanel.revalidate(); ballNumbersPanel.repaint(); inputNumberTf.setText(""); inputNumberTf.requestFocusInWindow(); // // check if has winner // Date today = LotteryUtils.getNextDate(new Date()); // if (dbTicketTables.isEmpty()) { // dbTicketTables = ticketTableService.getByDate(today); // } totalDrawedNumbers++; checkCanAddNumber(); if (inputNumbers.size() < LotteryUtils.MAX_BALLS_PER_LINE) { return; } winTicketTables.addAll(LotteryUtils.getWinnerByLine(dbTicketTables, inputNumbers)); if (winTicketTables.size() > 0) { // update table list view refreshWinnerTable(); // JOptionPane.showMessageDialog(this, "Number of winner: " + winTicketTables.size()); } // check if has full table, then stop game if (totalDrawedNumbers >= (LotteryUtils.MAX_BALLS_PER_LINE * LotteryUtils.NO_LINES_PER_TABLE)) { Iterator<TicketTable> iter = winTicketTables.iterator(); while (iter.hasNext()) { TicketTable tmp = iter.next(); if (tmp.getWinType() == TicketTable.FULL_TABLE) { JOptionPane.showMessageDialog(this, "Got winner with full table!"); // save draw results, update ticket_table winner DrawResult drawResult = new DrawResult(); drawResult.setDrawDate(LotteryUtils.getDate(ftfDrawDate.getText().trim())); drawResult.setDrawBalls(StringUtils.join(inputNumbers, LotteryUtils.BALLS_SEPARATOR)); drawResult.setRound(Byte.parseByte((String) cbbRound.getSelectedItem())); drawResultService.updateWinner(drawResult, winTicketTables); restartGame(); return; } } } } catch (NumberFormatException ex) { LOGGER.error("Invalid number!: ", ex); JOptionPane.showMessageDialog(this, "Invalid number!"); } catch (ParseException ex) { LOGGER.error("Cant parse date", ex); JOptionPane.showMessageDialog(this, "Cant save result!"); } }
From source file:lcmc.gui.resources.EditableInfo.java
/** Returns a more panel with "more options are available" message. */ protected final JPanel getMoreOptionsPanel(final int width) { final JLabel l = new JLabel(Tools.getString("EditableInfo.MoreOptions")); final Font font = l.getFont(); final String name = font.getFontName(); final int style = Font.ITALIC; final int size = font.getSize(); l.setFont(new Font(name, style, size - 3)); moreOptionsPanel.setBackground(Browser.PANEL_BACKGROUND); moreOptionsPanel.add(l);//from w w w.j a va2 s .co m final Dimension d = moreOptionsPanel.getPreferredSize(); d.width = width; moreOptionsPanel.setMaximumSize(d); return moreOptionsPanel; }
From source file:com.juanhg.triangle.TriangleApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblO1 = new JLabel("Tensi\u00F3n:"); lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTValue = new JLabel(); lblTValue.setText("0"); lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblO2 = new JLabel("V:"); lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVValue = new JLabel(); lblVValue.setText("0"); lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO3 = new JLabel("tfinal:"); lblO3.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTfValue = new JLabel(); lblTfValue.setText("0"); lblTfValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblW = new JLabel("W:"); lblW.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblWValue = new JLabel(); lblWValue.setText("0"); lblWValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblO2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblO1, GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblVValue, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTValue, GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO3, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblTfValue, GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblWValue, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))) .addContainerGap())); gl_panelOutputs//from w w w . j a va2s. c o m .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup().addComponent(lblO1) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblTValue) .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent( lblTfValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs .createParallelGroup(Alignment.BASELINE) .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblWValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)))) .addGap(107))); panelOutputs.setLayout(gl_panelOutputs); JPanel panelLicense = new JPanel(); panelLicense.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control .createParallelGroup(Alignment.LEADING) .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE).addComponent( panelOutputs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE) .addGap(13) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(24))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6 .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(69, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); JLabel LabelI1 = new JLabel("Roz Est\u00E1tico"); LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI2 = new JLabel("Roz Din\u00E1mico"); labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI3 = new JLabel("Masa"); labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblMudValue = new JLabel("0.1"); lblMudValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMValue = new JLabel("10"); lblMValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMueValue = new JLabel("0.4"); lblMueValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderMue = new JSlider(); sliderMue.setMinimum(15); sliderMue.setMaximum(80); sliderMue.setMinorTickSpacing(1); sliderMue.setValue(40); sliderMue.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderMud = new JSlider(); sliderMud.setMinimum(5); sliderMud.setMaximum(15); sliderMud.setMinorTickSpacing(1); sliderMud.setValue(10); sliderMud.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); sliderIM = new JSlider(); sliderIM.setMinimum(1); sliderIM.setMaximum(20); sliderIM.setValue(10); sliderIM.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); JLabel lblI4 = new JLabel("\u00C1ngulo"); lblI4.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblZValue = new JLabel("45\u00BA"); lblZValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderZ = new JSlider(); sliderZ.setMinimum(20); sliderZ.setMaximum(60); sliderZ.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderZ.setValue(45); sliderZ.setMinorTickSpacing(1); btnCilindro = new JButton(new ImageIcon(loadImage(cilindro))); btnCilindro.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { type = CILINDRO; btnCilindro.setEnabled(false); btnEsfera.setEnabled(true); btnCubo.setEnabled(true); chartTriangle.deleteAnnotation(pulleyAnnotation); pulleyAnnotation = chartTriangle.setImageAtPoint(pulleyImage1, xPulley, yPulley); updatePanels(); repaint(); } }); btnEsfera = new JButton(new ImageIcon(loadImage(esfera))); btnEsfera.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { type = ESFERA; btnCilindro.setEnabled(true); btnEsfera.setEnabled(false); btnCubo.setEnabled(true); chartTriangle.deleteAnnotation(pulleyAnnotation); pulleyAnnotation = chartTriangle.setImageAtPoint(pulleyImage2, xPulley, yPulley); updatePanels(); repaint(); } }); btnCubo = new JButton(new ImageIcon(loadImage(cubo))); btnCubo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { type = CUBO; btnCilindro.setEnabled(true); btnEsfera.setEnabled(true); btnCubo.setEnabled(false); chartTriangle.deleteAnnotation(pulleyAnnotation); pulleyAnnotation = chartTriangle.setImageAtPoint(pulleyImage3, xPulley, yPulley); updatePanels(); repaint(); } }); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING).addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addComponent(labelI3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelI1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelI2, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblMueValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblMudValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addComponent(sliderMue, 0, 0, Short.MAX_VALUE) .addComponent(sliderMud, 0, 0, Short.MAX_VALUE).addComponent( sliderIM, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblZValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(sliderZ, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGap(19)) .addGroup(Alignment.LEADING, gl_panelInputs.createSequentialGroup().addGap(35) .addComponent(btnCilindro, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(btnEsfera, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(btnCubo, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE) .addContainerGap(42, Short.MAX_VALUE))); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelI1).addComponent(lblMueValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderMue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelI2).addComponent(lblMudValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderMud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3) .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderIM, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblZValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderZ, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(36) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(btnCubo, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE) .addComponent(btnEsfera, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE) .addComponent(btnCilindro, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(Color.WHITE); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 696, GroupLayout.PREFERRED_SIZE) .addContainerGap(149, Short.MAX_VALUE))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false) .addComponent(panel_visualizar, Alignment.TRAILING, 0, 0, Short.MAX_VALUE) .addComponent(panel_control, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 568, Short.MAX_VALUE)) .addContainerGap())); JPanel panel = new JPanel(); panelGrafica = new JPanelGrafica(); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelGrafica, GroupLayout.DEFAULT_SIZE, 686, Short.MAX_VALUE)); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelGrafica, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)); panel.setLayout(gl_panel); GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar); gl_panel_visualizar.setHorizontalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_visualizar.createSequentialGroup().addContainerGap() .addComponent(panel, GroupLayout.PREFERRED_SIZE, 414, GroupLayout.PREFERRED_SIZE) .addContainerGap(272, Short.MAX_VALUE))); gl_panel_visualizar.setVerticalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_visualizar.createSequentialGroup().addContainerGap() .addComponent(panel, GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE).addContainerGap())); panel_visualizar.setLayout(gl_panel_visualizar); getContentPane().setLayout(groupLayout); }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * Creates one panel for each kind of form that may be used and stores them for later *//* ww w . j av a2 s . c o m*/ private void createInitialInfoSubPanels() { //boolean editing = hasPermissionToModify; infoSubPanels = new Hashtable<String, AdminInfoSubPanelWrapper>(); JPanel blankPanel = new JPanel(); createBlankInfoSubPanel(Institution.class, blankPanel); createBlankInfoSubPanel(Discipline.class, blankPanel); createBlankInfoSubPanel(Collection.class, blankPanel); JPanel allPermissions = new JPanel(new BorderLayout()); JLabel lbl = UIHelper.createI18NLabel("SEC_ALL_PERMISSIONS", SwingConstants.CENTER); lbl.setFont(lbl.getFont().deriveFont(18.0f)); allPermissions.add(lbl, BorderLayout.CENTER); createBlankInfoSubPanel(AdminPrincipal.class, allPermissions); createUserPanel(); createGroupPanel(); }
From source file:com.polivoto.vistas.Charts.java
public void getHeader(JPanel header) { header.removeAll();/* ww w . jav a2 s . c o m*/ GridBagConstraints gridBagConstraints; header.setLayout(new GridBagLayout()); header.setBackground(Color.white); header.setPreferredSize(new Dimension(0, 100)); JLabel titulo = new JLabel("<html> <b>Votacin: </b>" + votacion.getTitulo() + "</html>"); JLabel lugar = new JLabel("<html> <b>Lugar: </b>" + votacion.getLugar() + "</html>"); SimpleDateFormat sdf = new SimpleDateFormat("EEEE d' de 'MMMM' del 'yyyy, hh:mm:ss"); JLabel fechaInicio = new JLabel( "<html><b>Fecha de inicio: </b>" + sdf.format(new Date(votacion.getFechaInicio())) + "</html>"); JLabel fechaFin = new JLabel( "<html><b>Fecha de fin: </b>" + sdf.format(new Date(votacion.getFechaFin())) + "</html>"); titulo.setFont(fuenteNormal); titulo.setVerticalAlignment(JLabel.CENTER); lugar.setFont(fuenteNormal); lugar.setVerticalAlignment(JLabel.CENTER); fechaFin.setFont(fuenteNormal); fechaFin.setVerticalAlignment(JLabel.CENTER); fechaInicio.setFont(fuenteNormal); fechaInicio.setVerticalAlignment(JLabel.CENTER); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5); header.add(titulo, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); header.add(fechaInicio, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5); header.add(lugar, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 3; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); header.add(fechaFin, gridBagConstraints); header.repaint(); header.revalidate(); }
From source file:es.emergya.ui.plugins.admin.aux1.RecursoDialog.java
public RecursoDialog(final Recurso rec, final AdminResources adminResources) { super();/*from ww w. j a va 2 s.c om*/ setAlwaysOnTop(true); setSize(600, 400); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); if (cambios) { int res = JOptionPane.showConfirmDialog(RecursoDialog.this, "Existen cambios sin guardar. Seguro que desea cerrar la ventana?", "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION); if (res != JOptionPane.CANCEL_OPTION) { e.getWindow().dispose(); } } else { e.getWindow().dispose(); } } }); final Recurso r = (rec == null) ? null : RecursoConsultas.get(rec.getId()); if (r != null) { setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador()); } else { setTitle(i18n.getString("Resources.summary.titleWindow.new")); } setIconImage(getBasicWindow().getFrame().getIconImage()); JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); title.setOpaque(false); JLabel labelTitulo = null; if (r != null) { labelTitulo = new JLabel(i18n.getString("Resources.summary"), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); } else { labelTitulo = new JLabel(i18n.getString("Resources.cabecera.nuevo"), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); } labelTitulo.setFont(LogicConstants.deriveBoldFont(12f)); title.add(labelTitulo); base.add(title); // Nombre JPanel mid = new JPanel(new SpringLayout()); mid.setOpaque(false); mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT)); final JTextField name = new JTextField(25); if (r != null) { name.setText(r.getNombre()); } name.getDocument().addDocumentListener(changeListener); name.setEditable(r == null); mid.add(name); // patrullas final JLabel labelSquads = new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT); mid.add(labelSquads); List<Patrulla> pl = PatrullaConsultas.getAll(); pl.add(0, null); final JComboBox squads = new JComboBox(pl.toArray()); squads.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXX"); squads.addActionListener(changeSelectionListener); squads.setOpaque(false); labelSquads.setLabelFor(squads); if (r != null) { squads.setSelectedItem(r.getPatrullas()); } else { squads.setSelectedItem(null); } squads.setEnabled((r != null && r.getHabilitado() != null) ? r.getHabilitado() : true); mid.add(squads); // // Identificador // mid.setOpaque(false); // mid.add(new JLabel(i18n.getString("Resources.identificador"), // JLabel.RIGHT)); // final JTextField identificador = new JTextField(""); // if (r != null) { // identificador.setText(r.getIdentificador()); // } // identificador.getDocument().addDocumentListener(changeListener); // identificador.setEditable(r == null); // mid.add(identificador); // Espacio en blanco // mid.add(Box.createHorizontalGlue()); // mid.add(Box.createHorizontalGlue()); // Tipo final JLabel labelTipoRecursos = new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT); mid.add(labelTipoRecursos); final JComboBox types = new JComboBox(RecursoConsultas.getTipos()); labelTipoRecursos.setLabelFor(types); types.addActionListener(changeSelectionListener); if (r != null) { types.setSelectedItem(r.getTipo()); } else { types.setSelectedItem(0); } // types.setEditable(true); types.setEnabled(true); mid.add(types); // Estado Eurocop mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT)); final JTextField status = new JTextField(); if (r != null && r.getEstadoEurocop() != null) { status.setText(r.getEstadoEurocop().getIdentificador()); } status.setEditable(false); mid.add(status); // Subflota y patrulla mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT)); final JComboBox subfleets = new JComboBox(FlotaConsultas.getAllHabilitadas()); subfleets.addActionListener(changeSelectionListener); if (r != null) { subfleets.setSelectedItem(r.getFlotas()); } else { subfleets.setSelectedIndex(0); } subfleets.setEnabled(true); subfleets.setOpaque(false); mid.add(subfleets); // Referencia humana mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT)); final JTextField rhumana = new JTextField(); // if (r != null && r.getIncidencias() != null) { // rhumana.setText(r.getIncidencias().getReferenciaHumana()); // } rhumana.setEditable(false); mid.add(rhumana); // dispositivo mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT)); final PlainDocument plainDocument = new PlainDocument() { private static final long serialVersionUID = 4929271093724956016L; @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (this.getLength() + str.length() <= LogicConstants.LONGITUD_ISSI) { super.insertString(offs, str, a); } } }; final JTextField issi = new JTextField(plainDocument, "", LogicConstants.LONGITUD_ISSI); plainDocument.addDocumentListener(changeListener); issi.setEditable(true); mid.add(issi); mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT)); final JCheckBox enabled = new JCheckBox("", true); enabled.addActionListener(changeSelectionListener); enabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (enabled.isSelected()) { squads.setSelectedIndex(0); } squads.setEnabled(enabled.isSelected()); } }); enabled.setEnabled(true); enabled.setOpaque(false); if (r != null) { enabled.setSelected(r.getHabilitado()); } else { enabled.setSelected(true); } if (r != null && r.getDispositivo() != null) { issi.setText( StringUtils.leftPad(String.valueOf(r.getDispositivo()), LogicConstants.LONGITUD_ISSI, '0')); } mid.add(enabled); // Fecha ultimo gps mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT)); JTextField lastGPS = new JTextField(); final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r); if (lastGPSDateForRecurso != null) { lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso)); } lastGPS.setEditable(false); mid.add(lastGPS); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); // informacion adicional JPanel infoPanel = new JPanel(new SpringLayout()); final JTextField info = new JTextField(25); info.getDocument().addDocumentListener(changeListener); infoPanel.add(new JLabel(i18n.getString("Resources.info"))); infoPanel.add(info); infoPanel.setOpaque(false); info.setOpaque(false); SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18); if (r != null) { info.setText(r.getInfoAdicional()); } else { info.setText(""); } info.setEditable(true); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18); base.add(mid); base.add(infoPanel); JPanel buttons = new JPanel(); buttons.setOpaque(false); JButton accept = null; if (r == null) { accept = new JButton("Crear", LogicConstants.getIcon("button_crear")); } else { accept = new JButton("Guardar", LogicConstants.getIcon("button_save")); } accept.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { if (cambios || r == null || r.getId() == null) { boolean shithappens = true; if ((r == null || r.getId() == null)) { // Estamos // creando // uno nuevo if (RecursoConsultas.alreadyExists(name.getText())) { shithappens = false; JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.nombreUnico")); } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT, "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI)); shithappens = false; } else if (issi.getText() != null && issi.getText().length() > 0 && LogicConstants.isNumeric(issi.getText()) && RecursoConsultas.alreadyExists(new Integer(issi.getText()))) { shithappens = false; JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.dispositivoUnico")); } } if (shithappens) { if (name.getText().isEmpty()) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.nombreNulo")); } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT, "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI)); } else if (issi.getText() != null && issi.getText().length() > 0 && LogicConstants.isNumeric(issi.getText()) && r != null && r.getId() != null && RecursoConsultas.alreadyExists(new Integer(issi.getText()), r.getId())) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.issiUnico")); } else if (issi.getText() != null && issi.getText().length() > 0 && !LogicConstants.isNumeric(issi.getText())) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.noNumerico")); // } else if (identificador.getText().isEmpty()) // { // JOptionPane // .showMessageDialog( // RecursoDialog.this, // i18n.getString("admin.recursos.popup.error.identificadorNulo")); } else if (subfleets.getSelectedIndex() == -1) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.noSubflota")); } else if (types.getSelectedItem() == null || types.getSelectedItem().toString().trim().isEmpty()) { JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.error.noTipo")); } else { int i = JOptionPane.showConfirmDialog(RecursoDialog.this, i18n.getString("admin.recursos.popup.dialogo.guardar.titulo"), i18n.getString("admin.recursos.popup.dialogo.guardar.guardar"), JOptionPane.YES_NO_CANCEL_OPTION); if (i == JOptionPane.YES_OPTION) { Recurso recurso = r; if (r == null) { recurso = new Recurso(); } recurso.setInfoAdicional(info.getText()); if (issi.getText() != null && issi.getText().length() > 0) { recurso.setDispositivo(new Integer(issi.getText())); } else { recurso.setDispositivo(null); } recurso.setFlotas(FlotaConsultas.find(subfleets.getSelectedItem().toString())); if (squads.getSelectedItem() != null && enabled.isSelected()) { recurso.setPatrullas( PatrullaConsultas.find(squads.getSelectedItem().toString())); } else { recurso.setPatrullas(null); } recurso.setNombre(name.getText()); recurso.setHabilitado(enabled.isSelected()); // recurso.setIdentificador(identificador // .getText()); recurso.setTipo(types.getSelectedItem().toString()); dispose(); RecursoAdmin.saveOrUpdate(recurso); adminResources.refresh(null); PluginEventHandler.fireChange(adminResources); } else if (i == JOptionPane.NO_OPTION) { dispose(); } } } } else { log.debug("No hay cambios"); dispose(); } } catch (Throwable t) { log.error("Error guardando un recurso", t); } } }); buttons.add(accept); JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel")); cancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (cambios) { if (JOptionPane.showConfirmDialog(RecursoDialog.this, "Existen cambios sin guardar. Seguro que desea cerrar la ventana?", "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION) { dispose(); } } else { dispose(); } } }); buttons.add(cancelar); base.add(buttons); getContentPane().add(base); setLocationRelativeTo(null); cambios = false; if (r == null) { cambios = true; } pack(); int x; int y; Container myParent = getBasicWindow().getPluginContainer().getDetachedTab(0); Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) { x = ((parentSize.width - mySize.width) / 2) + topLeft.x; } else { x = topLeft.x; } if (parentSize.height > mySize.height) { y = ((parentSize.height - mySize.height) / 2) + topLeft.y; } else { y = topLeft.y; } setLocation(x, y); cambios = false; }
From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java
/** * /*from w w w . ja v a 2s . c o m*/ */ protected void showForm() { if (selectedForm != null) { if (formFrame != null) { formFrame.setVisible(false); formFrame.dispose(); } formFrame = new JFrame(); FormPanelInfo formPanelInfo = createPanel(selectedForm); JPanel panel = formPanelInfo.getPanel(); JLabel label = new JLabel(formPanelInfo.getTitle(), SwingConstants.CENTER); Font font = label.getFont(); label.setFont(font.deriveFont(14.0f).deriveFont(Font.BOLD)); JPanel container = new JPanel(new BorderLayout()); container.add(panel, BorderLayout.CENTER); container.add(label, BorderLayout.SOUTH); formFrame.setContentPane(container); panel.addMouseMotionListener(new MouseAdapter() { @Override public void mouseMoved(MouseEvent e) { //System.out.println(e.getPoint()); } }); formFrame.setVisible(true); formFrame.setSize(new Dimension(formPanelInfo.getMaxWidth() + 10, formPanelInfo.getMaxHeight() + 25)); } }
From source file:com.juanhg.icewalker.IceWalkerApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTiempo = new JPanel(); panelTiempo.setToolTipText(""); panelTiempo.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblPhase = new JLabel("Velocidad:"); lblPhase.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVValue = new JLabel(); lblVValue.setText("0"); lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblPosicion = new JLabel("Posici\u00F3n:"); lblPosicion.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblPositionValue = new JLabel(); lblPositionValue.setText("0"); lblPositionValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs//from w w w . j a v a 2 s .c o m .setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addContainerGap() .addComponent(lblPhase, GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE).addGap(26) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE) .addContainerGap(130, Short.MAX_VALUE)) .addGroup(gl_panelOutputs.createSequentialGroup().addContainerGap() .addComponent(lblPosicion, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addGap(26).addComponent(lblPositionValue, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE) .addContainerGap(130, Short.MAX_VALUE))); gl_panelOutputs .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblPhase).addComponent(lblVValue)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblPosicion, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblPositionValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(63))); panelOutputs.setLayout(gl_panelOutputs); panel_1 = new JPanel(); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control .createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup() .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING, false) .addComponent(panelOutputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelInputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) .addGroup(Alignment.TRAILING, gl_panel_control.createSequentialGroup() .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addComponent(panel_1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addComponent(panelTiempo, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)) .addContainerGap())))); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 141, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelTiempo, GroupLayout.PREFERRED_SIZE, 271, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, 15, Short.MAX_VALUE).addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panel_1.add(lblNewLabel); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); panel = new JPanel(); panel.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); label = new JLabel("Datos de la Simulaci\u00F3n"); label.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(label); btnBanana = new JButton(""); btnBanana.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnBananaEvent(); } }); bananaImage = loadImage(banana); btnBanana.setIcon(new ImageIcon(bananaImage)); btnBurger = new JButton(""); btnBurger.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnBurgerEvent(); } }); burgerImage = loadImage(burger); btnBurger.setIcon(new ImageIcon(burgerImage)); btnCookie = new JButton(""); btnCookie.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnCookieEvent(); } }); cookieImage = loadImage(cookie); btnCookie.setIcon(new ImageIcon(cookieImage)); btnCarrot = new JButton(""); carrotImage = loadImage(carrot); btnCarrot.setIcon(new ImageIcon(carrotImage)); btnCarrot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnCarrotEvent(); } }); JLabel lblNewLabel_1 = new JLabel("30 cal/100g"); JLabel lblCalg_2 = new JLabel("734 cal/100g"); lblCalg = new JLabel("90 cal/100g"); lblCalg_1 = new JLabel("433 cal/100g"); GroupLayout gl_panelTiempo = new GroupLayout(panelTiempo); gl_panelTiempo.setHorizontalGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE) .addGroup(gl_panelTiempo.createSequentialGroup().addGap(17).addGroup(gl_panelTiempo .createParallelGroup(Alignment.LEADING, false) .addComponent(btnLaunchSimulation, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(gl_panelTiempo.createSequentialGroup() .addGroup(gl_panelTiempo.createParallelGroup(Alignment.TRAILING) .addComponent(btnCarrot, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addComponent(lblNewLabel_1, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.TRAILING) .addComponent(btnBanana).addComponent(lblCalg, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.TRAILING) .addComponent(btnCookie, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addComponent(lblCalg_1, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup().addGap(6).addComponent( btnBurger, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelTiempo.createSequentialGroup().addGap(18).addComponent( lblCalg_2, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE))))) .addContainerGap(24, Short.MAX_VALUE))); gl_panelTiempo.setVerticalGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup() .addComponent(panel, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING).addGroup(gl_panelTiempo .createSequentialGroup() .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addComponent(btnCarrot, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE) .addComponent(btnCookie, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE) .addComponent(btnBurger, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING, false) .addComponent(lblNewLabel_1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.BASELINE) .addComponent(lblCalg_2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCalg_1, GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)) .addComponent(lblCalg, GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE))) .addComponent(btnBanana, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)) .addGap(30).addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE) .addContainerGap(33, Short.MAX_VALUE))); panelTiempo.setLayout(gl_panelTiempo); JLabel LabelStrength = new JLabel("Fuerza"); LabelStrength.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelStaticFriction = new JLabel("Roz. Est\u00E1tico"); labelStaticFriction.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelDynamicFriction = new JLabel("Roz. Din\u00E1mico"); labelDynamicFriction.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblStaticFrictionValue = new JLabel("0.2"); lblStaticFrictionValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblDynamicFrictionValue = new JLabel("0.1"); lblDynamicFrictionValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblStregthValue = new JLabel("100"); lblStregthValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderStrength = new JSlider(); sliderStrength.setMinorTickSpacing(1); sliderStrength.setMinimum(1); sliderStrength.setMaximum(300); sliderStrength.setValue(100); sliderStrength.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderStrenghtEvent(); } }); sliderStaticFriction = new JSlider(); sliderStaticFriction.setMinimum(15); sliderStaticFriction.setMaximum(80); sliderStaticFriction.setMinorTickSpacing(1); sliderStaticFriction.setValue(20); sliderStaticFriction.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderStaticFrictionEvent(); } }); sliderDynamicFriction = new JSlider(); sliderDynamicFriction.setValue(10); sliderDynamicFriction.setMaximum(15); sliderDynamicFriction.setMinimum(5); sliderDynamicFriction.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderDynamicFrictionEvent(); } }); sliderDynamicFriction.setMinorTickSpacing(1); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelInputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addComponent(labelDynamicFriction, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelStrength, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelStaticFriction, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 120, Short.MAX_VALUE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblStregthValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblStaticFrictionValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblDynamicFrictionValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(sliderStaticFriction, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderStrength, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderDynamicFriction, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE)) .addGap(26)) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)); gl_panelInputs .setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(8) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelStrength).addComponent(lblStregthValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderStrength, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelStaticFriction) .addComponent(lblStaticFrictionValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderStaticFriction, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(labelDynamicFriction) .addComponent(lblDynamicFrictionValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderDynamicFriction, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(75))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 432, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE) .addContainerGap())); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addComponent(panel_visualizar, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE) .addComponent(panel_control, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 598, Short.MAX_VALUE)) .addContainerGap())); GridBagLayout gbl_panel_visualizar = new GridBagLayout(); gbl_panel_visualizar.columnWidths = new int[] { 0, 0 }; gbl_panel_visualizar.rowHeights = new int[] { 0, 0, 0 }; gbl_panel_visualizar.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_panel_visualizar.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; panel_visualizar.setLayout(gbl_panel_visualizar); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); gbc_tabbedPane.gridheight = 2; gbc_tabbedPane.fill = GridBagConstraints.BOTH; gbc_tabbedPane.gridx = 0; gbc_tabbedPane.gridy = 0; panel_visualizar.add(tabbedPane, gbc_tabbedPane); panelSimulation = new JPanelGrafica(); tabbedPane.addTab("Simulacin", null, panelSimulation, null); panelSimulation.setBackground(Color.WHITE); getContentPane().setLayout(groupLayout); }
From source file:com.juanhg.fridge.FridgeApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblO1 = new JLabel("Tiempo On:"); lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTValue = new JLabel(); lblTValue.setText("0"); lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblO2 = new JLabel("Eficiencia:"); lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblEValue = new JLabel(); lblEValue.setText("0"); lblEValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblTiempoOff = new JLabel("Tiempo Off:"); lblTiempoOff.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblOffValue = new JLabel(); lblOffValue.setText("0"); lblOffValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addComponent(lblO1, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblEValue, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE) .addGap(31) .addComponent(lblTiempoOff, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(lblOffValue, GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE))) .addContainerGap())); gl_panelOutputs//from w w w. ja v a2 s . co m .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblOffValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblTiempoOff, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO1).addComponent(lblTValue)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblEValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)))))); panelOutputs.setLayout(gl_panelOutputs); JPanel panelLicense = new JPanel(); panelLicense.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control .setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(Alignment.LEADING, gl_panel_control.createSequentialGroup().addContainerGap() .addGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addComponent(panelOutputs, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)) .addContainerGap())); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 305, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(24))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6 .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(69, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); JLabel LabelI1 = new JLabel("Potencia"); LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI2 = new JLabel("T1"); labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI3 = new JLabel("T2"); labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblT1Value = new JLabel("20"); lblT1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblT2Value = new JLabel("-15"); lblT2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblPValue = new JLabel("700"); lblPValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderP = new JSlider(); sliderP.setMinimum(500); sliderP.setMaximum(1000); sliderP.setMinorTickSpacing(50); sliderP.setValue(700); sliderP.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderT1 = new JSlider(); sliderT1.setMinimum(18); sliderT1.setMaximum(30); sliderT1.setMinorTickSpacing(1); sliderT1.setValue(20); sliderT1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); sliderT2 = new JSlider(); sliderT2.setMinimum(10); sliderT2.setMaximum(30); sliderT2.setValue(15); sliderT2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); JLabel lblQo = new JLabel("Qo"); lblQo.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblQcValue = new JLabel("25"); lblQcValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderQc = new JSlider(); sliderQc.setMinimum(10); sliderQc.setMaximum(50); sliderQc.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderQc.setValue(25); sliderQc.setMinorTickSpacing(1); btn1 = new JButton("1"); btn1.setFont(new Font("Tahoma", Font.PLAIN, 21)); btn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnMilk.setEnabled(false); btnFish.setEnabled(false); btnMetal.setEnabled(false); btn1.setEnabled(false); btn2.setEnabled(true); sliderQc.setEnabled(true); lblQcValue.setText("" + sliderQc.getValue()); } }); btn2 = new JButton("2"); btn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnMilk.setEnabled(true); btnFish.setEnabled(true); btnMetal.setEnabled(true); btn1.setEnabled(true); btn2.setEnabled(false); phase = 2; sliderQc.setEnabled(false); lblQcValue.setText("-"); } }); btn2.setFont(new Font("Tahoma", Font.PLAIN, 21)); fishImage = loadImage(fish); btnFish = new JButton(new ImageIcon(fishImage)); btnFish.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnFishFunction(); } }); milkImage = loadImage(milk); btnMilk = new JButton(new ImageIcon(milkImage)); btnMilk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnMilkFunction(); } }); metalImage = loadImage(metal); btnMetal = new JButton(new ImageIcon(metalImage)); btnMetal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnMetalFunction(); } }); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs .setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addGroup(gl_panelInputs.createSequentialGroup().addGap(38).addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING).addGroup( gl_panelInputs.createSequentialGroup().addGap(36) .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING, false) .addComponent(lblQo, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelI3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelI2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelI1, GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING) .addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING, false) .addComponent(sliderT1, 0, 0, Short.MAX_VALUE) .addComponent(sliderP, GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE) .addComponent(sliderT2, 0, 0, Short.MAX_VALUE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblQcValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(sliderQc, 0, 0, Short.MAX_VALUE))))) .addContainerGap(14, Short.MAX_VALUE)) .addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup() .addContainerGap(28, Short.MAX_VALUE) .addComponent(btnFish, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnMilk, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnMetal, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addGap(25))); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelI1).addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelI2).addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderT1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3) .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderT2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblQo, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblQcValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderQc, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE) .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(btnMetal, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE) .addComponent(btnMilk, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createSequentialGroup().addGap(1).addComponent(btnFish, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap(12, Short.MAX_VALUE))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(Color.WHITE); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 398, GroupLayout.PREFERRED_SIZE) .addGap(452))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout .createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addGap(12).addComponent(panel_visualizar, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)) .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE))) .addContainerGap())); JPanel panel = new JPanel(); panelGrafica = new JPanelGrafica(); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGap(0, 384, Short.MAX_VALUE) .addComponent(panelGrafica, GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE) .addComponent(panelGrafica, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)); panel.setLayout(gl_panel); GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar); gl_panel_visualizar.setHorizontalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)); gl_panel_visualizar.setVerticalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)); panel_visualizar.setLayout(gl_panel_visualizar); getContentPane().setLayout(groupLayout); }
From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java
private void initComponents() { JPanel mainPanel = new JPanel(new GridBagLayout()); // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Title panel JPanel titlePanel = new JPanel(new FlowLayout(LEFT)); titlePanel.setBackground(WHITE);/* ww w . j av a 2s .c o m*/ // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10)); JLabel titleLabel = new JLabel(WELCOME); titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f)); // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10)); JLabel titleIcon = new JLabel(tavernaCogs32x32Icon); // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10)); DialogTextArea titleMessage = new DialogTextArea(PLEASE_FILL_IN_THIS_REGISTRATION_FORM); titleMessage.setMargin(new Insets(0, 20, 0, 10)); titleMessage.setFont(baseFont); titleMessage.setEditable(false); titleMessage.setFocusable(false); // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10)); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(titleLabel, NORTH); messagePanel.add(titleMessage, CENTER); messagePanel.setBackground(WHITE); titlePanel.add(titleIcon); titlePanel.add(messagePanel); addDivider(titlePanel, BOTTOM, true); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 2; // gbc.insets = new Insets(5, 10, 0, 0); mainPanel.add(titlePanel, gbc); // Registration messages gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 1; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; // gbc.insets = new Insets(5, 0, 0, 10); DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER); registrationMessage1.setMargin(new Insets(0, 10, 0, 0)); registrationMessage1.setFont(baseFont); registrationMessage1.setEditable(false); registrationMessage1.setFocusable(false); registrationMessage1.setBackground(getBackground()); DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO); registrationMessage2.setMargin(new Insets(0, 10, 0, 10)); registrationMessage2.setFont(baseFont); registrationMessage2.setEditable(false); registrationMessage2.setFocusable(false); registrationMessage2.setBackground(getBackground()); JPanel registrationMessagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); registrationMessagePanel.add(registrationMessage1); registrationMessagePanel.add(registrationMessage2); addDivider(registrationMessagePanel, BOTTOM, true); mainPanel.add(registrationMessagePanel, gbc); // Mandatory label // JLabel mandatoryLabel = new JLabel("* Mandatory fields"); // mandatoryLabel.setFont(baseFont); // gbc.weightx = 0.0; // gbc.weighty = 0.0; // gbc.gridx = 0; // gbc.gridy = 3; // gbc.fill = NONE; // gbc.anchor = GridBagConstraints.EAST; // gbc.gridwidth = 2; // gbc.insets = new Insets(0, 10, 0, 20); // mainPanel.add(mandatoryLabel, gbc); // First name JLabel firstNameLabel = new JLabel(FIRST_NAME); firstNameLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 4; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(0, 10, 0, 10); mainPanel.add(firstNameLabel, gbc); firstNameTextField = new JTextField(); firstNameTextField.setFont(baseFont); if (previousRegistrationData != null) firstNameTextField.setText(previousRegistrationData.getFirstName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 4; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(firstNameTextField, gbc); // Last name JLabel lastNameLabel = new JLabel(LAST_NAME); lastNameLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 5; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(0, 10, 0, 10); mainPanel.add(lastNameLabel, gbc); lastNameTextField = new JTextField(); lastNameTextField.setFont(baseFont); if (previousRegistrationData != null) lastNameTextField.setText(previousRegistrationData.getLastName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 5; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(lastNameTextField, gbc); // Email address JLabel emailLabel = new JLabel(EMAIL_ADDRESS); emailLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 6; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(emailLabel, gbc); emailTextField = new JTextField(); emailTextField.setFont(baseFont); if (previousRegistrationData != null) emailTextField.setText(previousRegistrationData.getEmailAddress()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 6; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(emailTextField, gbc); // Keep me informed keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED); keepMeInformedCheckBox.setFont(baseFont); if (previousRegistrationData != null) keepMeInformedCheckBox.setSelected(previousRegistrationData.getKeepMeInformed()); keepMeInformedCheckBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox.isSelected()); } } }); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 7; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(keepMeInformedCheckBox, gbc); // Institution name JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME); institutionLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 8; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(institutionLabel, gbc); institutionOrCompanyTextField = new JTextField(); institutionOrCompanyTextField.setFont(baseFont); if (previousRegistrationData != null) institutionOrCompanyTextField.setText(previousRegistrationData.getInstitutionOrCompanyName()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 8; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(institutionOrCompanyTextField, gbc); // Industry type JLabel industryLabel = new JLabel(" Industry type:"); industryLabel.setFont(baseFont); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 9; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(industryLabel, gbc); industryTypeTextField = new JComboBox<>(industryTypes); industryTypeTextField.setFont(baseFont); if (previousRegistrationData != null) industryTypeTextField.setSelectedItem(previousRegistrationData.getIndustry()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 9; gbc.fill = HORIZONTAL; gbc.anchor = WEST; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(industryTypeTextField, gbc); // Field of investigation JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION); fieldLabel.setFont(baseFont); fieldLabel.setEditable(false); fieldLabel.setFocusable(false); fieldLabel.setBackground(getBackground()); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 10; gbc.fill = NONE; gbc.anchor = LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(fieldLabel, gbc); fieldTextField = new JTextField(); fieldTextField.setFont(baseFont); if (previousRegistrationData != null) fieldTextField.setText(previousRegistrationData.getField()); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 10; gbc.fill = HORIZONTAL; gbc.anchor = FIRST_LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(fieldTextField, gbc); // Purpose of using Taverna JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA); purposeLabel.setFont(baseFont); purposeLabel.setEditable(false); purposeLabel.setFocusable(false); purposeLabel.setBackground(getBackground()); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 11; gbc.fill = NONE; gbc.anchor = LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(purposeLabel, gbc); purposeTextArea = new JTextArea(4, 30); purposeTextArea.setFont(baseFont); purposeTextArea.setLineWrap(true); purposeTextArea.setAutoscrolls(true); if (previousRegistrationData != null) purposeTextArea.setText(previousRegistrationData.getPurposeOfUsingTaverna()); purposeTextArea.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_TAB) { if (evt.getModifiers() > 0) purposeTextArea.transferFocusBackward(); else purposeTextArea.transferFocus(); evt.consume(); } } }); JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea); gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 1; gbc.gridy = 11; gbc.fill = HORIZONTAL; gbc.anchor = FIRST_LINE_START; gbc.gridwidth = 1; gbc.insets = new Insets(5, 10, 0, 10); mainPanel.add(purposeScrollPane, gbc); // Terms and conditions termsAndConditionsCheckBox = new JCheckBox(I_AGREE_TO_THE_TERMS_AND_CONDITIONS); termsAndConditionsCheckBox.setFont(baseFont); termsAndConditionsCheckBox.setBorder(null); termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); termsAndConditionsCheckBox.setSelected(!termsAndConditionsCheckBox.isSelected()); } } }); // gbc.weightx = 0.0; // gbc.weighty = 0.0; // gbc.gridx = 0; // gbc.gridy = 12; // gbc.fill = NONE; // gbc.anchor = WEST; // gbc.gridwidth = 2; // gbc.insets = new Insets(10, 10, 0, 0); // mainPanel.add(termsAndConditionsCheckBox, gbc); // Terms and conditions link JEditorPane termsAndConditionsURL = new JEditorPane(); termsAndConditionsURL.setEditable(false); termsAndConditionsURL.setBackground(getBackground()); termsAndConditionsURL.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); termsAndConditionsURL.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:9px;}"); Document doc = kit.createDefaultDocument(); termsAndConditionsURL.setDocument(doc); termsAndConditionsURL.setText("<html><body><a href=\"" + TERMS_AND_CONDITIONS_URL + "\">" + TERMS_AND_CONDITIONS_URL + "</a></body></html>"); termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { if (he.getEventType() == ACTIVATED) followHyperlinkToTandCs(); } }); gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 13; gbc.fill = NONE; gbc.anchor = WEST; gbc.gridwidth = 2; gbc.insets = new Insets(5, 10, 0, 10); JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT)); termsAndConditionsPanel.add(termsAndConditionsCheckBox); termsAndConditionsPanel.add(termsAndConditionsURL); mainPanel.add(termsAndConditionsPanel, gbc); // Button panel JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton registerButton = new JButton("Register"); registerButton.setFont(baseFont); registerButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); register(); } } }); registerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { register(); } }); JButton doNotRegisterButton = new JButton("Do not ask me again"); doNotRegisterButton.setFont(baseFont); doNotRegisterButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); doNotRegister(); } } }); doNotRegisterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doNotRegister(); } }); JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks remindMeLaterButton.setFont(baseFont); remindMeLaterButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == VK_ENTER) { evt.consume(); remindMeLater(); } } }); remindMeLaterButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { remindMeLater(); } }); buttonPanel.add(registerButton); buttonPanel.add(remindMeLaterButton); buttonPanel.add(doNotRegisterButton); addDivider(buttonPanel, TOP, true); gbc.gridx = 0; gbc.gridy = 14; gbc.fill = HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(5, 10, 0, 10); gbc.gridwidth = 2; mainPanel.add(buttonPanel, gbc); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mainPanel, CENTER); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }