Pessoas programo a 1 ano em java manipulo frames botoes jtable painels etc mas vi um programa com um eskema de tela muito interesante e nao faco a minha ideia de como isso trabalha e como isso funciona e como fazer isso! de uma olhada na foto abaixo
Existe um conjunto de componentes opensource http://l2fprod.com/ que possui um componente que faz exatamente isso que vc precisa, eu já usei é muito bom… recomendo
Amigao dei uma olhada no que vc me passoe achei muito interesante mas so meio grosso no ingles to aprendendo ainda poderia me dizer como insiro esse pacote de libs no meu projeto? e como usar?
sei como adiciona um jar nas libs do meu netbeans se for so isso eu sei como importa o jar!
mas o problema e como inserir os paineis no meu form?
up
[quote]silviogs amigao agradeco sua ajuda consegui instala o oswing mas qual eh o painel que preciso? poderia me informar o nome do componente? pois quando adicionei o jar no meu projeto ele aparece um monte de componente mas n tem icone e esta dificikl para saber qual eh vc sabe qual nome ? agradeco!
e quando tento arrastar qualquer componente para o meu frame veja o q acontece
Impossivel carregar a classe de componente demo14.FirstPanel da Biblioteca do IDE:
OpenSwing. A classe so deve ser compilada e deve esta no caminho de classe o projeto ao qual este formulario pertence!!!
OBS: ja compilei ! e nao ta indo !
Olá amigo
nesta pasta do OpenSwing tem vários exemplos que vc pode verificar e usar:
OpenSwing2.0.4/srcdemo
e nesta vc executa
OpenSwing2.0.4/classes
runDemo14.bat caso seja win32.
runDemo14.sh linux.
e quanto a arrastar e soltar o componente, neste caso achei mais fácil de usar diretamente no código.
Silvio Guedes
Mais facil criar o componente via codigo do q apenas clicar e arrastar? nossa deve ser muito facil entao poderia me falar como insiro o painel via codigo no meu projeto?
gostei deste
runDemo.
Horas… easy.
panel.setLayout(new MigLayout());
panel.add(esseComponente, "span 1 2");//c1
panel.add(umPainel, "wrap");//c2
panel.add(bottom,"center");//c3
Usando o MigLayout com essse código o Layout desses componentes seriam algo assim.
_______
| | c2 |
|c1 |----|
| | c3 |
----------
Olá amigo
exemplo de um detail frame usando Open Swing:
package comap;
import javax.swing.*;
import java.awt.*;
import org.openswing.swing.client.*;
import java.util.*;
import org.openswing.swing.util.client.ClientSettings;
import org.openswing.swing.internationalization.java.EnglishOnlyResourceFactory;
import org.openswing.swing.form.model.client.VOModel;
import org.openswing.swing.form.client.Form;
import org.openswing.swing.form.client.FormController;
import org.openswing.swing.util.java.Consts;
import java.sql.*;
import org.openswing.swing.message.receive.java.*;
import org.openswing.swing.lookup.client.LookupController;
import org.openswing.swing.lookup.client.LookupDataLocator;
import org.openswing.swing.internationalization.java.Resources;
import org.openswing.swing.mdi.client.InternalFrame;
import javax.swing.border.*;
import org.openswing.swing.table.columns.client.*;
/**
* <p>Title: OpenSwing Framework</p>
* <p>Description: Demo Application: detail employee frame.</p>
* <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
* <p> </p>
* @author Mauro Carniel
* @version 1.0
*/
public class PatrimonioDetailFrame extends InternalFrame {
JPanel buttonsPanel = new JPanel();
DateControl controlDate = new DateControl();
GridBagLayout gridBagLayout1 = new GridBagLayout();
LabelControl labelDate = new LabelControl();
ComboBoxControl controlSex = new ComboBoxControl();
LabelControl labelEmpCode = new LabelControl();
CurrencyControl controlCurrency = new CurrencyControl();
TextControl controlempCode = new TextControl();
private Form mainPanel = new Form();
InsertButton insertButton = new InsertButton();
FlowLayout flowLayout1 = new FlowLayout();
EditButton editButton = new EditButton();
ReloadButton reloadButton = new ReloadButton();
SaveButton saveButton = new SaveButton();
DeleteButton deleteButton = new DeleteButton();
CodLookupControl controlLookup = new CodLookupControl();
TextControl controlDeptDescr = new TextControl();
private Connection conn = null;
CopyButton copyButton = new CopyButton();
TextAreaControl controlNote = new TextAreaControl();
TitledBorder titledBorder1;
TitledBorder titledBorder2;
LabelControl labelFName = new LabelControl();
LabelControl labelLName = new LabelControl();
TextControl controlFName = new TextControl();
TextControl controlLName = new TextControl();
LabelControl labelSex = new LabelControl();
LabelControl labelSalary = new LabelControl();
LabelControl labelTask = new LabelControl();
LabelControl labelDeptCode = new LabelControl();
CodLookupControl controlCodTask = new CodLookupControl();
TextControl controlTaskDescr = new TextControl();
JPanel whPanel = new JPanel();
TitledBorder titledBorder3;
TitledBorder titledBorder4;
BorderLayout borderLayout1 = new BorderLayout();
JPanel buttons2Panel = new JPanel();
FlowLayout flowLayout2 = new FlowLayout();
EditButton editButton1 = new EditButton();
SaveButton saveButton1 = new SaveButton();
ReloadButton reloadButton1 = new ReloadButton();
GridControl grid = new GridControl();
ComboColumn colDay = new ComboColumn();
TimeColumn colStartMorningHour = new TimeColumn();
TimeColumn colEndMorningHour = new TimeColumn();
TimeColumn colStartAfternoonHour = new TimeColumn();
TimeColumn colEndAfternoonHour = new TimeColumn();
NavigatorBar navigatorBar = new NavigatorBar();
ExportButton exportButton1 = new ExportButton();
LabelControl labelItem = new LabelControl();
LabelControl labelDescricao = new LabelControl();
LabelControl labelData = new LabelControl();
LabelControl labelSetor = new LabelControl();
LabelControl labelObservacao = new LabelControl();
LabelControl labelIdSetor = new LabelControl();
NumericControl controlItem = new NumericControl();
TextControl controlDescricao = new TextControl();
DateControl controlData = new DateControl();
TextControl controlSetor = new TextControl();
TextControl controlObservacao = new TextControl();
CodLookupControl controlIdSetorLookup = new CodLookupControl();
TextControl controlSetorDescr = new TextControl();
public PatrimonioDetailFrame(Connection conn,PatrimonioDetailFrameController dataController) {
try {
this.conn = conn;
jbInit();
mainPanel.setFormController(dataController);
//WorkingDaysInFormController gridController = new WorkingDaysInFormController(this,conn);
//grid.setGridDataLocator(gridController);
//grid.setController(gridController);
// link the parent grid to the current Form...
HashSet pk = new HashSet();
pk.add("id"); // pk for Form is based on one only attribute...
mainPanel.linkGrid(dataController.getGridFrame().getGrid(),pk,true,true,true,navigatorBar);
setSize(590,600);
setMinimumSize(new Dimension(590,600));
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
setTitle("Cadastro Patrimônio");
titledBorder1 = new TitledBorder("");
titledBorder2 = new TitledBorder("");
titledBorder3 = new TitledBorder("");
titledBorder4 = new TitledBorder("");
mainPanel.setVOClassName("comap.PatrimonioVO");
mainPanel.setLayout(gridBagLayout1);
buttonsPanel.setLayout(flowLayout1);
flowLayout1.setAlignment(FlowLayout.LEFT);
mainPanel.setBorder(titledBorder1);
mainPanel.setInsertButton(insertButton);
mainPanel.setCopyButton(copyButton);
mainPanel.setEditButton(editButton);
mainPanel.setReloadButton(reloadButton);
mainPanel.setDeleteButton(deleteButton);
mainPanel.setSaveButton(saveButton);
saveButton.setEnabled(false);
labelItem.setText("itemTombamento");
labelDescricao.setText("descricaoTombamento");
labelData.setText("dataTombamento");
labelSetor.setText("setorTombamento");
labelObservacao.setText("observacaoTombamento");
labelIdSetor.setText("idSetorTombamento");
controlItem.setMaxCharacters(8);
controlItem.setEnabledOnEdit(false);
controlItem.setAttributeName("itemTombamento");
controlDescricao.setMaxCharacters(100);
controlDescricao.setTrimText(true);
controlDescricao.setUpperCase(true);
controlDescricao.setEnabledOnEdit(true);
controlDescricao.setRequired(true);
controlDescricao.setAttributeName("descricaoTombamento");
controlData.setCanCopy(true);
controlData.setRequired(true);
controlData.setAttributeName("dataTombamento");
controlSetor.setMaxCharacters(100);
controlSetor.setTrimText(true);
controlSetor.setUpperCase(true);
controlSetor.setEnabledOnEdit(true);
controlSetor.setAttributeName("setorTombamento");
controlObservacao.setMaxCharacters(100);
controlObservacao.setTrimText(true);
controlObservacao.setUpperCase(true);
controlObservacao.setEnabledOnEdit(true);
controlObservacao.setAttributeName("observacaoTombamento");
controlIdSetorLookup.setAttributeName("");
controlIdSetorLookup.setCanCopy(true);
controlIdSetorLookup.setMaxCharacters(5);
controlIdSetorLookup.setRequired(true);
controlIdSetorLookup.setAttributeName("idSetorTombamento");
controlSetorDescr.setAttributeName("descricaoSetor");
controlSetorDescr.setCanCopy(true);
controlSetorDescr.setEnabledOnInsert(false);
controlSetorDescr.setEnabledOnEdit(false);
copyButton.setText("copyButton1");
controlNote.setAttributeName("note");
titledBorder1.setTitle("Dados");
titledBorder1.setTitleColor(Color.blue);
labelFName.setRequestFocusEnabled(true);
whPanel.setBorder(titledBorder2);
whPanel.setPreferredSize(new Dimension(132, 250));
whPanel.setLayout(borderLayout1);
titledBorder2.setTitleColor(Color.blue);
// titledBorder2.setTitle("Working hours");
buttons2Panel.setLayout(flowLayout2);
flowLayout2.setAlignment(FlowLayout.LEFT);
editButton1.setText("editButton1");
saveButton1.setText("saveButton1");
reloadButton1.setText("reloadButton1");
grid.setEditButton(editButton1);
grid.setExportButton(exportButton1);
grid.setReloadButton(reloadButton1);
grid.setSaveButton(saveButton1);
grid.setValueObjectClassName("comap.WorkingDayVO");
grid.setAutoLoadData(false);
grid.setVisibleStatusPanel(false);
colDay.setDomainId("DAYS");
colDay.setColumnName("day");
colDay.setColumnSortable(false);
colDay.setSortVersus(org.openswing.swing.util.java.Consts.ASC_SORTED);
colDay.setSortingOrder(1);
colStartMorningHour.setColumnName("startMorningHour");
colStartMorningHour.setColumnRequired(false);
colStartMorningHour.setEditableOnEdit(true);
colEndMorningHour.setColumnName("endMorningHour");
colEndMorningHour.setColumnRequired(false);
colEndMorningHour.setEditableOnEdit(true);
colStartAfternoonHour.setColumnName("startAfternoonHour");
colStartAfternoonHour.setColumnRequired(false);
colStartAfternoonHour.setEditableOnEdit(true);
colEndAfternoonHour.setColumnName("endAfternoonHour");
colEndAfternoonHour.setColumnRequired(false);
colEndAfternoonHour.setEditableOnEdit(true);
this.getContentPane().add(buttonsPanel, BorderLayout.NORTH);
buttonsPanel.add(insertButton, null);
buttonsPanel.add(copyButton, null);
buttonsPanel.add(editButton, null);
buttonsPanel.add(reloadButton, null);
buttonsPanel.add(saveButton, null);
buttonsPanel.add(exportButton1, null);
buttonsPanel.add(deleteButton, null);
buttonsPanel.add(navigatorBar, null);
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.add(labelItem, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(controlItem, new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(labelDescricao, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(controlDescricao, new GridBagConstraints(1, 1, 6, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(labelData, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(controlData, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(labelSetor, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(controlSetor, new GridBagConstraints(1, 3, 6, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(labelSetor, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(controlIdSetorLookup, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(controlSetorDescr, new GridBagConstraints(2, 4, 1, 1, 6.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(labelObservacao, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(controlObservacao, new GridBagConstraints(1, 6, 7, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0));
mainPanel.add(controlNote, new GridBagConstraints(0, 8, 10, 1, 1.0, 1.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
this.getContentPane().add(whPanel, BorderLayout.SOUTH);
whPanel.add(buttons2Panel, BorderLayout.NORTH);
// buttons2Panel.add(editButton1, null);
// buttons2Panel.add(reloadButton1, null);
// buttons2Panel.add(saveButton1, null);
// whPanel.add(grid, BorderLayout.CENTER);
// grid.getColumnContainer().add(colDay, null);
// grid.getColumnContainer().add(colStartMorningHour, null);
// grid.getColumnContainer().add(colEndMorningHour, null);
// grid.getColumnContainer().add(colStartAfternoonHour, null);
// grid.getColumnContainer().add(colEndAfternoonHour, null);
LookupController lookupController = new SetorLookupController(conn);
controlIdSetorLookup.setLookupController(lookupController);
controlIdSetorLookup.setAutoCompletitionWaitTime(1000);
}
public Form getMainPanel() {
return mainPanel;
}
public SaveButton getSaveButton() {
return saveButton;
}
public DeleteButton getDeleteButton() {
return deleteButton;
}
public EditButton getEditButton() {
return editButton;
}
public CurrencyControl getControlCurrency() {
return controlCurrency;
}
public GridControl getGrid() {
return grid;
}
public void setEnableGridButtons(boolean enabled) {
if (enabled) {
editButton1.setEnabled(enabled);
reloadButton1.setEnabled(enabled);
}
else {
editButton1.setEnabled(enabled);
saveButton1.setEnabled(enabled);
reloadButton1.setEnabled(enabled);
}
}
}
dê uma olhada neste tópico:
Boa sorte
Silvio Guedes
Silvio obrigado por sua atencao vou analizar o codigo de cabo a rabo!
Mark Ameba aonde baixo o miglayout amigo para mim poder testar dei uma olhada no tutorial que vc mando e achei super simples!
Obrigado aos 2!!
http://www.migcalendar.com/miglayout/versions/
Realmente também prefiro fazer as telas na mão. E com o MigLayout isso fica mais facil.
Até hoje eu não aprendi usa esse migLayout…
Sempre começo aprender mas paro.
Idem a eu !