Cook book written in Java
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

143 lines
4.4 KiB

package ksiazka.kucharska;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JSplitPane;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JList;
import javax.swing.JTextPane;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.border.LineBorder;
import java.awt.SystemColor;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class FrmMain extends JFrame {
/**
*
*/
private static final long serialVersionUID = 2634383304749703669L;
private JPanel contentPane;
private JTextField txtSearch;
/**
* Create the frame.
*/
public FrmMain() {
setResizable(false);
setTitle("Książka Kucharska v1.0");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 800, 500);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JSplitPane splitPane = new JSplitPane();
splitPane.setDividerSize(5);
splitPane.setEnabled(false);
splitPane.setResizeWeight(0.2);
contentPane.add(splitPane, BorderLayout.CENTER);
JPanel panel = new JPanel();
splitPane.setLeftComponent(panel);
GridBagLayout gbl_panel = new GridBagLayout();
gbl_panel.columnWidths = new int[] {0, 30};
gbl_panel.rowHeights = new int[] {0, 0, 0};
gbl_panel.columnWeights = new double[]{1.0, 0.0};
gbl_panel.rowWeights = new double[]{0.0, 1.0, 0.0};
panel.setLayout(gbl_panel);
txtSearch = new JTextField();
txtSearch.setText("wpisz tytuł/tagi...");
GridBagConstraints gbc_txtSearch = new GridBagConstraints();
gbc_txtSearch.insets = new Insets(0, 0, 5, 5);
gbc_txtSearch.fill = GridBagConstraints.HORIZONTAL;
gbc_txtSearch.gridx = 0;
gbc_txtSearch.gridy = 0;
panel.add(txtSearch, gbc_txtSearch);
txtSearch.setColumns(10);
JButton btnSearch = new JButton("Szukaj");
GridBagConstraints gbc_btnSearch = new GridBagConstraints();
gbc_btnSearch.anchor = GridBagConstraints.NORTH;
gbc_btnSearch.fill = GridBagConstraints.HORIZONTAL;
gbc_btnSearch.insets = new Insets(0, 0, 5, 0);
gbc_btnSearch.gridx = 1;
gbc_btnSearch.gridy = 0;
panel.add(btnSearch, gbc_btnSearch);
JList recipesList = new JList();
GridBagConstraints gbc_recipesList = new GridBagConstraints();
gbc_recipesList.insets = new Insets(0, 0, 5, 0);
gbc_recipesList.gridwidth = 2;
gbc_recipesList.fill = GridBagConstraints.BOTH;
gbc_recipesList.gridx = 0;
gbc_recipesList.gridy = 1;
panel.add(recipesList, gbc_recipesList);
JPanel panel_1 = new JPanel();
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
gbc_panel_1.gridwidth = 2;
gbc_panel_1.gridheight = 0;
gbc_panel_1.insets = new Insets(0, 0, 0, 5);
gbc_panel_1.fill = GridBagConstraints.BOTH;
gbc_panel_1.gridx = 0;
gbc_panel_1.gridy = 2;
panel.add(panel_1, gbc_panel_1);
panel_1.setLayout(new GridLayout(0, 2, 0, 0));
JButton btnAddRecipe = new JButton("Dodaj");
btnAddRecipe.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel_1.add(btnAddRecipe);
JButton btnDelRecipe = new JButton("Usuń");
panel_1.add(btnDelRecipe);
JPanel panel_2 = new JPanel();
splitPane.setRightComponent(panel_2);
panel_2.setLayout(null);
JTextPane txtIngredients = new JTextPane();
txtIngredients.setEditable(false);
txtIngredients.setBounds(26, 88, 228, 126);
panel_2.add(txtIngredients);
JTextPane txtDescription = new JTextPane();
txtDescription.setEditable(false);
txtDescription.setBounds(26, 254, 410, 196);
panel_2.add(txtDescription);
JLabel lblRecipeTitle = new JLabel("Nazwa przepisu");
lblRecipeTitle.setFont(new Font("Dialog", Font.BOLD, 18));
lblRecipeTitle.setBounds(12, 12, 442, 22);
panel_2.add(lblRecipeTitle);
JLabel lblIngredients = new JLabel("Składniki:");
lblIngredients.setBounds(26, 61, 70, 15);
panel_2.add(lblIngredients);
JLabel lblDescription = new JLabel("Opis wykonania:");
lblDescription.setBounds(26, 227, 152, 15);
panel_2.add(lblDescription);
JLabel imgRecipe = new JLabel("");
imgRecipe.setBorder(new LineBorder(SystemColor.textHighlightText));
imgRecipe.setBounds(272, 88, 164, 126);
panel_2.add(imgRecipe);
}
}