Inheritting from custom JPanel using NetBeans GUI Builder - java

ContainerPanel is a custom JPanel class using a BorderLayout. The SOUTH contains a JPanel with a button. I want the CENTER to be an instance of another custom JPanel, say AbstractPanel, which provides an abstract method which will be called when the button is clicked. I also want to set this JPanel programmatically (at run-time). So far, I can do all of this as you can see in the following code (some of which is generated by the NetBeans GUI Builder):
package jpaneldemo;
import java.awt.BorderLayout;
public class ContainerPanel extends javax.swing.JPanel {
public ContainerPanel() {
initComponents();
}
public ContainerPanel(AbstractPanel abPanel) {
initComponents();
this.abPanel = abPanel;
this.add(this.abPanel, BorderLayout.SOUTH);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
private void initComponents() {
buttonPanel = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
setLayout(new java.awt.BorderLayout());
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
buttonPanel.add(okButton);
add(buttonPanel, java.awt.BorderLayout.PAGE_END);
}
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
this.abPanel.abstractMethod();
}
// Variables declaration - do not modify
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton okButton;
// End of variables declaration
private AbstractPanel abPanel = null;
}
I also created the AbstractPanel class:
package jpaneldemo;
public abstract class AbstractPanel extends javax.swing.JPanel {
public AbstractPanel() {
initComponents();
}
protected abstract void abstractMethod();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}
// Variables declaration - do not modify
// End of variables declaration
}
Now I want to create subclasses of this AbstractPanel class which I can edit in the NetBeans GUI. Typically, I right-click on a package name in the Projects window and then navigate to "New -> JPanel..." to create a custom JPanel. How do I get AbstractPanel to appear in the "New" menu so that I can edit the new class with the NetBeansGUI Builder? Or is there another way to accomplish the same thing?

If your intention is to provide a "template" component that can then be added to the palette and included in other containers, then yes you can.
Have a read through FaqFormCustomContainerBean
The basic idea (apart from creating a BeanDescriptor is you will need to provide a "content" panel of some kind, where additional content can be added at design time.
Now, if you're interested in providing a custom template, that's something I've not done before.
You could try reading through http://netbeans.org/competition/win-with-netbeans/customize-java-template.html. It may be a little out of date, but might help you in the right direction

Related

How to use autogenerated netbeans JFrame forms?

I want to develop a mini game and I struggle creating a Menu for this app. The Menu consists of 3 buttons (exit, rules, play) and I want to let the netbeans JFrame form designer to take care of it (you know, I just place the buttons, assign them functionality and style and the IDE creates the class code for me).
Now, the problem is that I do not know how to implement this code. It says that "This method is called from within the constructor to initialize the form.", so I guessed that I just had to do:
public Menu() {
create_and_show_menu();
}
private void create_and_show_menu() {
JFrame f = new JFrame("Menu");
new Sterge();
f.setExtendedState(JFrame.MAXIMIZED_BOTH);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
... but it didn't work out. Please tell me how to use that freakin' JFrame form, cause I haven't found anything online about that.
The auto-generated class code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* #author stoic
*/
public class Sterge extends javax.swing.JFrame {
/**
* Creates new form Sterge
*/
public Sterge() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton1MousePressed(evt);
}
});
jButton2.setText("jButton1");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton2MousePressed(evt);
}
});
jButton3.setText("jButton1");
jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton3MousePressed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(138, 138, 138)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jButton3))
.addContainerGap(189, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(75, 75, 75)
.addComponent(jButton1)
.addGap(42, 42, 42)
.addComponent(jButton2)
.addGap(46, 46, 46)
.addComponent(jButton3)
.addContainerGap(73, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void jButton2MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void jButton3MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
/**
* #param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Sterge.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Sterge.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Sterge.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Sterge.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Sterge().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
// End of variables declaration
}
The initcomponents() method initializes all of the Java swing components objects that your Front-End GUI uses, using the NetBeans GUI Builder. I see you are already using NetBeans GUI Builder and the IDE generated the code while you are designing,
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton1MousePressed(evt);
}
});
jButton2.setText("jButton1");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton2MousePressed(evt);
}
});
jButton3.setText("jButton1");
jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton3MousePressed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(138, 138, 138)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jButton3))
.addContainerGap(189, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(75, 75, 75)
.addComponent(jButton1)
.addGap(42, 42, 42)
.addComponent(jButton2)
.addGap(46, 46, 46)
.addComponent(jButton3)
.addContainerGap(73, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
So that is how the NetBeans IDE helping you to develop applications without typing more codes but with designing. Pretty easy huh :)
These swing components are automatically generated inside the above method whenever you make changes to the design of your GUI using the GUI builder.
You should not change any aspect of the above code within this method as this method is inextricably linked to the Front-End NetBeans GUI builder. If you change the code your Front-End also will be changed. But if you wish to change the code that is up to you to take care of it.
The initComponents(); method is called inside the constructor by default by NetBeans. And it is by default private. Running this initComponents(); method inside the Constructor will display the Front-End as soon as the application starts.
public Sterge() {
initComponents();
}
But you can call the initComponents(); method wherever you like (constructor or inside other methods). For Java, it is just like any other method.
When I come to your menu question, I don't see any JMenuBar and JMenuItems are used. If you need them you can read about how to use Menus from here. But I see there are 3 JButtons as you said there are three buttons in Menu. So I assume these are the 3 buttons that you are saying about.
Look at the following codes in your class.
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void jButton2MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void jButton3MousePressed(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
Suppose you need to print Hello World! in the console after you click the jButton1. Here is the place where you write the code. Inside the following method.
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
System.out.println("Hello World!");
}
Once you click the above button MouseEvent will be triggered and you will see the Hello World! text on the console. According to your details, there are 3 buttons for 3 functions (exit, rules, play). Writing the code is up to you. :)
private void jButton1MousePressed(java.awt.event.MouseEvent evt) {
// Code for exit the game writes here
}
private void jButton2MousePressed(java.awt.event.MouseEvent evt) {
// Code for show rules writes here
}
private void jButton3MousePressed(java.awt.event.MouseEvent evt) {
// Code for play the game writes here
}
If you look more carefully at the NetBeans-generated code, you will see that inside initComponents(); method there is this code,
jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jButton3MousePressed(evt);
}
});
NetBeans use this structure to prevent edits on the standard code that could lead to incorrect event handling, allowing you at the same time to write the code you need to be executed when that event happens.
As you have used MouseListener I suggest don't use a MouseListener. A JButton is designed to be used with an ActionListener.
public void jButton3ActionPerformed(ActionEvent e) {
// Your code here
}
The generated code ActionListener by the NetBeans GUI Builder will be,
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
So I will stop writing from here as I can't cover all the points within this. The following links provide a very good quick start guide to the essentials of NetBeans GUI builder.
Introduction to GUI Building
Designing a Swing GUI in NetBeans
Hope this helps you. Happy Coding!

Java Netbeans: How to open the JPanel from another class?

I have a main.java file which I like to use to call the GUI made in JPanel.
It's my first NetBeans experience though, so be gentle :-) ...
It fails to compile; the error i get is :Erroneous sym type: main.GUI.GUI (which makes sense as it is interpreted).
But now: HOW DO I FIX IT??
I've tried GUI.GUI(); as well, but without positive results..
(I'm used to programming C++, but since import is not a true option in java (or is it?).
My main.java:
package main;
public class Main {
public static void main(String[] args) {
GUI obj = new GUI();
obj.GUI();
}
}
My GUI.java file:
package main;
public class GUI extends javax.swing.JPanel {
public GUI() {
initComponents();
}
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}
}
If I understand your question correctly you want to display the GUI from your Main class. One thing to keep in mind is that a JPanel itself cannot be displayed. It must be added to a JFrame before it shows. Try something like:
package main;
public class Main {
public static void main(String[] args) {
GUI obj = new GUI(); // creates your panel
JFrame frame = new JFrame("some title"); // creates the frame
frame.add(obj);
frame.setSize(200,300);
frame.setVisible(true);
}
}
GUI obj = new GUI();
it created new object of GUI. So, the constructor is operated already. The constructor method is special method, that plays when new object is created from the class.

How to make JFrame same shape as Image with transparent Background?

I am a Beginner in Java using NetBeans as my IDE...
I am trying to make a custom shaped JFrame that is shaped like the Image I will be creating... I found a solution here and here but I can't figure out how to apply it in Netbeans..
Took me hours and hours of research but to no avail.. So I asked it here hoping someone would enlighten me... I also hope you explain the codes used and how it worked so I would also learn and just copy pasting...
I also hope you explain the codes used and how it worked
That is the benefit of a tutorial. Read the section from the Swing tutorial on How to Create Translucent and Shaped Windows for information and working examples.
I can't figure out how to apply it in Netbeans
Don't use the IDE to generate your code. If you ever switch IDE's then you need to learn a new one. Instead spend the time learning Java/Swing, not the IDE.
After a couple of hours Playing around with NetBeans after reading and watching couple of tutorials I have found, I finally got a simple solution...
Here is the code:
package testPack;
import java.awt.Color;
import javax.swing.*;
import java.awt.Dimension;
/**
*
* #author Karyuu Ouji
*/
public class TestPanel extends javax.swing.JPanel {
/**
* Creates new form TestPanel
*/
public TestPanel() {
initComponents();
this.setPreferredSize(new Dimension(704,182));
this.setOpaque(false);
this.setDoubleBuffered(true);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setLayout(null);
jButton1.setText("Close");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jButton1MouseReleased(evt);
}
});
add(jButton1);
jButton1.setBounds(593, 0, 110, 23);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/testPack/sao.png"))); // NOI18N
jLabel1.setText("jLabel1");
add(jLabel1);
jLabel1.setBounds(0, 0, 704, 180);
}// </editor-fold>
private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {
System.exit(0);
}
public static void main(String[] args) {
JFrame frmMain = new JFrame();
frmMain.setUndecorated(true);
frmMain.setBackground(new Color(0,0,0,0));
frmMain.add(new TestPanel());
frmMain.pack();
frmMain.setLocationRelativeTo(null);
frmMain.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
Note: Most of the code are generated by NetBeans
All I did was add a JLabel from the component pallet and set the size of the JPanel and JLabel the same as the image size.
Then I put on the image in the JLabel via the Icon property.
Setting Icon/Image
And here is what it looks like when I run the app.
Running
I hope this will help someone like me in the future... :)

How to Hide JPanel and Open another one in other Java FIle?

I'm newbie in java GUI , so i'm facing a problem right now ...
i've created a GUI using Netbeans GUI Builder ..
i've Created a file called MainUI.java and gdUI.Java
the MainUI.java contains the frame and buttons in which if a button is clicked the Jpanel Hides and opens the Panel from gdUI.java
here's the code i've done so far :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel1.setVisible(false);
}
and gdUI code is :
package GUI;
public class gdUI extends javax.swing.JPanel {
/**
* Creates new form gdUI
*/
public gdUI() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setBackground(new java.awt.Color(255, 153, 51));
setMaximumSize(new java.awt.Dimension(600, 500));
setMinimumSize(new java.awt.Dimension(600, 500));
setPreferredSize(new java.awt.Dimension(600, 500));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 600, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 500, Short.MAX_VALUE)
);
}// </editor-fold>
// Variables declaration - do not modify
// End of variables declaration
}
when i click the button , i successfully hided the current JPanel , how can i add the other files new one ?
Thanks In Advance
The way you want to accomplish this task is using a CardLayout as pointed out by trashgod. This will allow you to switch between views, with simple Cardayout commands like next(), previous() and show(), the last allowing to show any particular component/view by name.
You can see the Oracle tutorial on How to Use CardLayout
You can see How to Use CardLayout with Netbeans GUI Builder
You can see how to drag and drop other panel forms here

Prevent JComboBox's Text Field to be Override

I realize, if I didn't not include line
jComboBox1.addItem("Cause Text Field To Override");
When I type in "A" in JComboBox's text field, "A" will shown in JComboBox's text field.
However, If I include the addItem code, JComboBox's text field will be override. (The lower boundary line also dissapear, not sure why)
I wish to able to addItem, and showPopup without override the content in JCombBoBox's text field. May I know how I can do so?
package javaapplication5;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
*
* #author yccheok
*/
public class NewJDialog extends javax.swing.JDialog {
/** Creates new form NewJDialog */
public NewJDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
jComboBox1.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
#Override
public void keyReleased(KeyEvent e) {
jComboBox1.addItem("Cause Text Field To Override");
jComboBox1.showPopup();
}
});
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jComboBox1.setEditable(true);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Hello", "World", "Bye" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(124, 124, 124)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(92, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(76, 76, 76)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(204, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
/**
* #param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
NewJDialog dialog = new NewJDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1;
// End of variables declaration
}
It's been a long time since I've done Swing, but I suspect that when you do your AddItem is causing a contentsChanged callback as the combo box is ListDataListener, and that based on that the combo-box is re-setting the selected item to the first item in its model.
I'd suggest you look at what JComboBox does in its implementation of ListDataListener and debug a bit.
However it looks like what you're trying to do goes against the natural swing of swing a bit - i.e. typing a key changes what is in the model by adding to the model.
Rather than using keyEvents on the combo-box, you would be better off adding listeners to the model that then manipulate results in the way you need.

Categories