List of usage examples for javax.swing.border MatteBorder MatteBorder
public MatteBorder(int top, int left, int bottom, int right, Icon tileIcon)
From source file:ColorComboRenderer.java
public ColorComboRenderer() { super();//from w ww . j a va 2s . c o m setBorder(new CompoundBorder(new MatteBorder(2, 10, 2, 10, Color.white), new LineBorder(Color.black))); }
From source file:ColorMenu.java
public ColorMenu(String name) { super(name);/*from w ww. j a v a 2 s. c o m*/ _unselectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, getBackground()), new BevelBorder(BevelBorder.LOWERED, Color.WHITE, Color.GRAY)); _selectedBorder = new CompoundBorder(new MatteBorder(2, 2, 2, 2, Color.RED), new MatteBorder(1, 1, 1, 1, getBackground())); _activeBorder = new CompoundBorder(new MatteBorder(2, 2, 2, 2, Color.BLUE), new MatteBorder(1, 1, 1, 1, getBackground())); JPanel p = new JPanel(); p.setBorder(new EmptyBorder(5, 5, 5, 5)); p.setLayout(new GridLayout(8, 8)); _colorPanes = new HashMap(); int values[] = new int[] { 0, 128, 192, 255 }; for (int r = 0; r < values.length; r++) for (int g = 0; g < values.length; g++) for (int b = 0; b < values.length; b++) { Color color = new Color(values[r], values[g], values[b]); ColorPane colorPane = new ColorPane(color); p.add(colorPane); _colorPanes.put(color, colorPane); } add(p); }
From source file:UIUtilities.java
/** * Set up the user interface./* ww w . j a v a 2s. c om*/ */ public static void setupUI() { try { final String classname = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(classname); } catch (Exception e) { e.printStackTrace(); } final UIDefaults defaults = UIManager.getDefaults(); defaults.put("PopupMenu.border", new BorderUIResource.EtchedBorderUIResource(EtchedBorder.RAISED, defaults.getColor("controlShadow"), defaults.getColor("controlLtHighlight"))); final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black); final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control")); final BorderUIResource.CompoundBorderUIResource compBorder = new BorderUIResource.CompoundBorderUIResource( emptyborder, matteborder); final BorderUIResource.EmptyBorderUIResource emptyBorderUI = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0); defaults.put("SplitPane.border", emptyBorderUI); defaults.put("Table.scrollPaneBorder", emptyBorderUI); defaults.put("ComboBox.border", compBorder); defaults.put("TextField.border", compBorder); defaults.put("TextArea.border", compBorder); defaults.put("CheckBox.border", compBorder); defaults.put("ScrollPane.border", emptyBorderUI); }
From source file:ColorChooserMenu.java
public ColorMenu(String name) { super(name);/*from w w w. j a v a2 s .c o m*/ unselectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, getBackground()), new BevelBorder(BevelBorder.LOWERED, Color.white, Color.gray)); selectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, Color.red), new MatteBorder(1, 1, 1, 1, getBackground())); activeBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, Color.blue), new MatteBorder(1, 1, 1, 1, getBackground())); JPanel p = new JPanel(); p.setBorder(new EmptyBorder(5, 5, 5, 5)); p.setLayout(new GridLayout(8, 8)); paneTable = new Hashtable(); int[] values = new int[] { 0, 128, 192, 255 }; for (int r = 0; r < values.length; r++) { for (int g = 0; g < values.length; g++) { for (int b = 0; b < values.length; b++) { Color c = new Color(values[r], values[g], values[b]); ColorPane pn = new ColorPane(c); p.add(pn); paneTable.put(c, pn); } } } add(p); }
From source file:es.emergya.ui.base.Message.java
private void inicializar(final String texto) { log.trace("inicializar(" + texto + ")"); final Message message_ = this; SwingUtilities.invokeLater(new Runnable() { @Override//from w w w .j a v a 2 s. com public void run() { log.trace("Sacamos un nuevo mensaje: " + texto); JDialog frame = new JDialog(window.getFrame(), true); frame.setUndecorated(true); frame.getContentPane().setBackground(Color.WHITE); frame.setLocation(150, window.getHeight() - 140); frame.setSize(new Dimension(window.getWidth() - 160, 130)); frame.setName("Incoming Message"); frame.setBackground(Color.WHITE); frame.getRootPane().setBorder(new MatteBorder(4, 4, 4, 4, color)); frame.setLayout(new BorderLayout()); if (font != null) frame.setFont(font); JLabel icon = new JLabel(new ImageIcon(this.getClass().getResource("/images/button-ok.png"))); icon.setToolTipText("Cerrar"); icon.removeMouseListener(null); icon.addMouseListener(new Cerrar(frame, message_)); JLabel text = new JLabel(texto); text.setBackground(Color.WHITE); text.setForeground(Color.BLACK); frame.add(text, BorderLayout.WEST); frame.add(icon, BorderLayout.EAST); frame.setVisible(true); } }); }
From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java
/** * {@inheritDoc}// ww w .j ava 2 s . co m */ @Override protected void buildGUI() { setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Create the transaction and status labels Insets insets5 = new Insets(5, 5, 5, 5); add(bold(new JLabel("Transaction ID:")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); add(transactionTxt, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); add(bold(new JLabel("Latest status:")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0)); add(statusTxt, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); // Create the info panel JPanel infoPanel = createInfoPanel(); add(infoPanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0)); // Create the messages panel JScrollPane scrollPane = new JScrollPane(messagesPanel); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(new MatteBorder(1, 1, 1, 1, UIManager.getColor("Separator.shadow"))); messagesPanel.setBackground(UIManager.getColor("List.background")); add(scrollPane, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0)); }
From source file:com.juanhg.pattern.PatternApplet.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("O1:"); lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO1Value = new JLabel(); lblO1Value.setText("0"); lblO1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblO2 = new JLabel("O2:"); lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO2Value = new JLabel(); lblO2Value.setText("0"); lblO2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO3 = new JLabel("O3:"); lblO3.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO3Value = new JLabel(); lblO3Value.setText("0"); lblO3Value.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) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE) .addGap(26)/*w w w . ja va 2 s . co m*/ .addComponent(lblO3Value, GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(26)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addGap(29))) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblO2Value, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblO1Value, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))) .addGap(109))); 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(lblO1Value).addComponent(lblO1)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblO2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblO3Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(79))); 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(panelOutputs, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 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, 213, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 146, Short.MAX_VALUE) .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.TRAILING).addGroup(Alignment.LEADING, gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING, gl_panel_6.createSequentialGroup().addGap(80) .addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); JLabel LabelI1 = new JLabel("I1"); LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI2 = new JLabel("I2"); labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI3 = new JLabel("I3"); labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblI2Value = new JLabel("5"); lblI2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI3Value = new JLabel("5"); lblI3Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI1Value = new JLabel("5"); lblI1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderI1 = new JSlider(); sliderI1.setMaximum(10); sliderI1.setMinorTickSpacing(1); sliderI1.setValue(5); sliderI1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderI2 = new JSlider(); sliderI2.setMaximum(10); sliderI2.setMinorTickSpacing(1); sliderI2.setValue(5); sliderI2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); sliderI3 = new JSlider(); sliderI3.setMaximum(10); sliderI3.setValue(5); sliderI3.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); JLabel lblI4 = new JLabel("I4"); lblI4.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI4Value = new JLabel("5"); lblI4Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderI4 = new JSlider(); sliderI4.setMaximum(10); sliderI4.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderI4.setValue(5); sliderI4.setMinorTickSpacing(1); JLabel lblI5 = new JLabel("I5"); lblI5.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI5Value = new JLabel("5"); lblI5Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderI5 = new JSlider(); sliderI5.setMaximum(10); sliderI5.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI5Event(); } }); sliderI5.setValue(5); sliderI5.setMinorTickSpacing(1); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .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(lblI1Value, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblI2Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblI3Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addComponent(sliderI1, 0, 0, Short.MAX_VALUE) .addComponent(sliderI2, 0, 0, Short.MAX_VALUE).addComponent( sliderI3, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblI4Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(sliderI4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblI5, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblI5Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18).addComponent(sliderI5, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGap(19)) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 352, 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(lblI1Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderI1, 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(lblI2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderI2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3) .addComponent(lblI3Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderI3, 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(lblI4Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderI4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblI5, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblI5Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderI5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(429))); 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, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout .createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE)) .addGroup(groupLayout.createSequentialGroup().addGap(12).addComponent(panel_visualizar, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE))) .addContainerGap())); GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar); gl_panel_visualizar.setHorizontalGroup( gl_panel_visualizar.createParallelGroup(Alignment.LEADING).addGap(0, 845, Short.MAX_VALUE)); gl_panel_visualizar.setVerticalGroup( gl_panel_visualizar.createParallelGroup(Alignment.LEADING).addGap(0, 567, Short.MAX_VALUE)); panel_visualizar.setLayout(gl_panel_visualizar); getContentPane().setLayout(groupLayout); }
From source file:com.diversityarrays.kdxplore.field.FieldViewPanel.java
public FieldViewPanel(PlotVisitList plotVisitList, Map<Integer, Trait> traitMap, SeparatorVisibilityOption visible, SimplePlotCellRenderer plotRenderer, Component... extras) { super(new BorderLayout()); this.plotVisitList = plotVisitList; this.traitMap = traitMap; trial = plotVisitList.getTrial();/* w ww. j a va2s . co m*/ fieldLayoutTableModel.setTrial(trial); int rowHeight = fieldLayoutTable.getRowHeight(); fieldLayoutTable.setRowHeight(4 * rowHeight); fieldLayoutTable.setCellSelectionEnabled(true); fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE fieldLayoutTable.setAutoCreateRowSorter(false); Map<Integer, Plot> plotById = new HashMap<>(); FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(), trial.getPlotIdentSummary(), plotVisitList.getPlots(), plotById); KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId, plotIdLayout.xsize, plotIdLayout.ysize); kdxFieldLayout.warning = plotIdLayout.warning; String displayName = null; for (VisitOrder2D vo : VisitOrder2D.values()) { if (vo.imageId == plotIdLayout.imageId) { displayName = vo.displayName; break; } } // VisitOrder2D vo = plotVisitList.getVisitOrder(); KDClientUtils.initAction(plotIdLayout.imageId, changeCollectionOrder, displayName); hasUserPlotId = lookForUserPlotIdPresent(plotById, plotIdLayout, kdxFieldLayout); this.plotCellRenderer = plotRenderer; plotCellRenderer.setShowUserPlotId(hasUserPlotId); plotCellRenderer.setPlotXYprovider(getXYprovider()); plotCellRenderer.setPlotVisitList(plotVisitList); fieldLayoutTable.setDefaultRenderer(Plot.class, plotCellRenderer); fieldLayoutTable.setCellSelectionEnabled(true); fieldLayoutTableModel.setFieldLayout(kdxFieldLayout); if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) { warningMessage.setText(kdxFieldLayout.warning); } else { warningMessage.setText(""); } fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fieldLayoutTable.getTableHeader().setReorderingAllowed(false); fieldLayoutTable.setCellSelectionEnabled(true); StringBuilder naming = new StringBuilder(); String nameForRow = plotVisitList.getTrial().getNameForRow(); if (!Check.isEmpty(nameForRow)) { naming.append(nameForRow); } String nameForCol = plotVisitList.getTrial().getNameForColumn(); if (!Check.isEmpty(nameForCol)) { if (naming.length() > 0) { naming.append('/'); } naming.append(nameForCol); } fieldTableScrollPane = new JScrollPane(fieldLayoutTable); if (naming.length() > 0) { JLabel cornerLabel = new JLabel(naming.toString()); fieldTableScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, cornerLabel); } fieldTableScrollPane.setRowHeaderView(rowHeaderTable); // fieldLayoutTable.setRowHeaderTable(rowHeaderTable); // Box extra = Box.createHorizontalBox(); // extra.add(new JButton(changeCollectionOrder)); // if (extras != null && extras.length > 0) { // extra.add(Box.createHorizontalStrut(8)); // for (Component c : extras) { // extra.add(c); // } // } // extra.add(Box.createHorizontalGlue()); switch (visible) { case NOTVISIBLE: break; case VISIBLE: default: Box top = Box.createHorizontalBox(); top.setOpaque(true); top.setBackground(Color.LIGHT_GRAY); top.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); JLabel label = new JLabel("Field"); label.setForeground(Color.DARK_GRAY); label.setFont(label.getFont().deriveFont(Font.BOLD)); top.add(label); top.add(new JButton(changeCollectionOrder)); if (extras != null && extras.length > 0) { top.add(Box.createHorizontalStrut(8)); for (Component c : extras) { top.add(c); } } add(top, BorderLayout.NORTH); break; } add(fieldTableScrollPane, BorderLayout.CENTER); add(warningMessage, BorderLayout.SOUTH); }
From source file:es.emergya.ui.plugins.AdminPanel.java
/** * // ww w. j ava 2 s . c o m * @param columnNames * nombres de las columnas de la tabla * @param filterOptions * lista de opciones de un combobox. Si esta vacio entonces es un * textfield * @param noFiltrarAction * @param filtrarAction */ public void generateTable(String[] columnNames, Object[][] filterOptions, AdminPanel.NoFiltrarAction noFiltrarAction, AdminPanel.FiltrarAction filtrarAction) { if (columnNames == null) { columnNames = new String[] {}; } if (filterOptions == null) { filterOptions = new Object[][] {}; } String filterString = "["; for (Object[] o : filterOptions) { filterString += Arrays.toString(o) + " "; } filterString += "]"; log.debug("generateTable( columnNames = " + Arrays.toString(columnNames) + ", filterOptions = " + filterString + ")"); tablePanel.removeAll(); int columnNamesLength = columnNames.length; if (!getCanDelete()) columnNamesLength++; MyTableModel dataModel = new MyTableModel(1, columnNamesLength + 2) { private static final long serialVersionUID = 1348355328684460769L; @Override public boolean isCellEditable(int row, int column) { return column != 0 && !invisibleFilterCols.contains(column); } }; filters = new JTable(dataModel) { private static final long serialVersionUID = -8266991359840905405L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (isCellEditable(row, column) && column != getColumnCount() - 1) { if (c instanceof JTextField) { ((JTextField) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } else if (c instanceof JComboBox) { ((JComboBox) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } else if (c instanceof JLabel) { ((JLabel) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } } return c; } }; filters.setSurrendersFocusOnKeystroke(true); filters.setShowGrid(false); filters.setRowHeight(22); filters.setOpaque(false); for (Integer i = 0; i < filterOptions.length; i++) { final Object[] items = filterOptions[i]; if (items != null && items.length > 1) { setComboBoxEditor(i, items); } else { final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(new JTextField()); defaultCellEditor.setClickCountToStart(1); filters.getColumnModel().getColumn(i + 1).setCellEditor(defaultCellEditor); } } filters.setRowSelectionAllowed(false); filters.setDragEnabled(false); filters.setColumnSelectionAllowed(false); filters.setDefaultEditor(JButton.class, new JButtonCellEditor()); filters.setDefaultRenderer(Object.class, new DefaultTableRenderer() { private static final long serialVersionUID = -4811729559786534118L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (invisibleFilterCols.contains(column)) c = new JLabel(""); return c; } }); filters.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = (JButton) value; b.setBorderPainted(false); b.setContentAreaFilled(false); return b; } }); filters.setDefaultRenderer(JLabel.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return (JLabel) value; } }); filters.setDefaultEditor(JButton.class, new JButtonCellEditor()); filters.getModel().setValueAt(new JLabel(""), 0, 0); JButton jButton2 = new JButton(noFiltrarAction); JButton jButton = new JButton(filtrarAction); jButton.setBorderPainted(false); jButton2.setBorderPainted(false); jButton.setContentAreaFilled(false); jButton2.setContentAreaFilled(false); if (jButton.getIcon() != null) jButton.setPreferredSize( new Dimension(jButton.getIcon().getIconWidth(), jButton.getIcon().getIconHeight())); if (jButton2.getIcon() != null) jButton2.setPreferredSize( new Dimension(jButton2.getIcon().getIconWidth(), jButton2.getIcon().getIconHeight())); filters.getModel().setValueAt(jButton, 0, columnNamesLength - 1); filters.getColumnModel().getColumn(columnNamesLength - 1).setMinWidth(jButton.getWidth() + 24); filters.getModel().setValueAt(jButton2, 0, columnNamesLength); filters.getColumnModel().getColumn(columnNamesLength).setMinWidth(jButton2.getWidth() + 14); cuenta.setHorizontalAlignment(JLabel.CENTER); cuenta.setText("?/?"); filters.getModel().setValueAt(cuenta, 0, columnNamesLength + 1); tablePanel.add(filters, BorderLayout.NORTH); Vector<String> headers = new Vector<String>(); headers.add(""); headers.addAll(Arrays.asList(columnNames)); MyTableModel model = new MyTableModel(headers, 0); table = new JTable(model) { private static final long serialVersionUID = 949284378605881770L; private int highLightedRow = -1; private Rectangle dirtyRegion = null; public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); try { if (AdminPanel.this.myRendererColoring != null) c.setBackground(AdminPanel.this.myRendererColoring .getColor(AdminPanel.this.table.getValueAt(row, 1))); } catch (Throwable t) { log.error("Error al colorear la celda: " + t); } return c; } @Override protected void processMouseMotionEvent(MouseEvent e) { try { int row = rowAtPoint(e.getPoint()); Graphics g = getGraphics(); if (row == -1) { highLightedRow = -1; } // row changed if (highLightedRow != row) { if (null != dirtyRegion) { paintImmediately(dirtyRegion); } for (int j = 0; j < getRowCount(); j++) { if (row == j) { // highlight Rectangle firstRowRect = getCellRect(row, 0, false); Rectangle lastRowRect = getCellRect(row, getColumnCount() - 1, false); dirtyRegion = firstRowRect.union(lastRowRect); g.setColor(new Color(0xff, 0xff, 0, 100)); g.fillRect((int) dirtyRegion.getX(), (int) dirtyRegion.getY(), (int) dirtyRegion.getWidth(), (int) dirtyRegion.getHeight()); highLightedRow = row; } } } } catch (Exception ex) { } super.processMouseMotionEvent(e); } }; table.setRowHeight(22); table.setOpaque(false); // table.setAutoCreateRowSorter(true); table.setDragEnabled(false); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false); table.setDefaultEditor(JButton.class, new JButtonCellEditor()); table.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = (JButton) value; if (b != null) { b.setBorderPainted(false); b.setContentAreaFilled(false); } return b; } }); JScrollPane jScrollPane = new JScrollPane(table); jScrollPane.setOpaque(false); jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane.getViewport().setOpaque(false); tablePanel.add(jScrollPane, BorderLayout.CENTER); }
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//w w w .ja v a 2 s . 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); }