Swing plugin for Eclipse

J

Jaba

What is a good Swing plugin for Eclipse that is open source? I'm
looking for a plugin that will aid in the development of GUIs in a drag

and drop manner.


Thanks for the help!
 
Joined
Dec 18, 2008
Messages
1
Reaction score
0
Chakri

package com.applabs.exams.scjpmock;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class QuestionScreen extends JPanel{
private JLabel lblName;
private JLabel lblExam;
private JTextField txtName;
private JTextField txtExam;
private JButton btnPrevious;
private JButton btnNext;
private JTextArea question;
private JCheckBox[] ckbOptions;
private static String NAME = "Name :";
private static String EXAM = "Exam :";
private static String PREVIOUS ="<-Previous";
private static String NEXT = "NEXT->";
private static String QUESTION = "Question";
private static String COLON = ": ";
private static int NO_OF_CHOICES = 4;
private static String[] CHOICES = {"Option One","Option two","Option three","Option four"};
private static String FILE = "File";
private static String EXIT = "Exit";
private static String HELP = "Help";
private static String OF = "of";

//TODO Add timer component
// private JLabel timeLeft;
// private JSpinner time;
// private static String TIMELEFT = "Time Left :";
// timeLeft = new JLabel(TIMELEFT);
// time = new JSpinner(new SpinnerDateModel());

public QuestionScreen()
{
init();
// createControls();
addControls();

}
private void init() {
// TODO Auto-generated method stub
lblName = new JLabel(NAME);
lblExam = new JLabel(EXAM);

txtName = new JTextField(20);
txtName.setEditable(false);
txtName.setOpaque(false);
txtExam = new JTextField(20);
txtExam.setEditable(false);
txtExam.setOpaque(false);

btnPrevious = new JButton(PREVIOUS);
btnNext = new JButton(NEXT);

question = new JTextArea(5,60);

/*optnOne = new JCheckBox();
optnTwo = new JCheckBox();
optnThree = new JCheckBox();
optnFour = new JCheckBox();*/
}
public void addControls()
{
// JPanel mainPanle = new JPanel();
// mainPanle.setLayout(new BorderLayout());

JPanel topLeftPane = new JPanel();
topLeftPane.add(lblName);
topLeftPane.add(txtName);

JPanel topRightPane = new JPanel();
topRightPane.add(lblExam);
topRightPane.add(txtExam);

JPanel topPane = new JPanel(new BorderLayout());
topPane.add(topLeftPane,BorderLayout.WEST);
topPane.add(topRightPane,BorderLayout.EAST);
topPane.add(new JLabel(QUESTION + COLON), BorderLayout.SOUTH);

JPanel midPane = new JPanel(new BorderLayout());

JPanel questionPnl = new JPanel(new BorderLayout());
questionPnl.add(question,BorderLayout.CENTER);

//TODO get the total choices of the question and place it here
//For temp purpose we are using 4 as default
ckbOptions = new JCheckBox[NO_OF_CHOICES];

JPanel optionPnl = new JPanel();
optionPnl.setLayout(new BoxLayout(optionPnl, BoxLayout.Y_AXIS));

int idx=0;

for(int i=0;i< NO_OF_CHOICES; i++)
{
ckbOptions = new JCheckBox(CHOICES);
optionPnl.add(Box.createHorizontalGlue());
optionPnl.add(ckbOptions);

}
// JPanel leftMidSouth = new JPanel(new BorderLayout());
// leftMidSouth.add(optnOne, BorderLayout.NORTH);
// leftMidSouth.add(optnThree, BorderLayout.SOUTH);
//
// JPanel rtMidSouth = new JPanel(new BorderLayout());
// rtMidSouth.add(optnTwo, BorderLayout.NORTH);
// rtMidSouth.add(optnFour,BorderLayout.SOUTH);

// multipleChoicesPnl.add(leftMidSouth,BorderLayout.WEST);
// multipleChoicesPnl.add(rtMidSouth,BorderLayout.EAST);

midPane.add(questionPnl, BorderLayout.CENTER);
midPane.add(optionPnl, BorderLayout.SOUTH);

JPanel generalInfo = new JPanel(new BorderLayout());
//TODO replace 5 and 10 with the actual values
generalInfo.add(new JLabel(QUESTION + "5" + OF + "10"),BorderLayout.WEST);
generalInfo.add(new JLabel("Display time component"),BorderLayout.EAST);

JPanel buttonsPnl = new JPanel(new BorderLayout());
buttonsPnl.add(btnPrevious, BorderLayout.WEST);
buttonsPnl.add(btnNext, BorderLayout.EAST);
buttonsPnl.add(generalInfo, BorderLayout.SOUTH);

this.setLayout(new BorderLayout());
this.add(topPane,BorderLayout.NORTH);
this.add(midPane, BorderLayout.CENTER);
this.add(buttonsPnl, BorderLayout.SOUTH);

// this.setLayout(new BorderLayout());
// this.add(mainPanle, BorderLayout.CENTER);
// return pane;

}

public JMenuBar addMenu()
{
JMenuItem newItem,openItem,exitItem,saveItem;
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(FILE);
fileMenu.setMnemonic(KeyEvent.VK_F);

exitItem = new JMenuItem(EXIT);
exitItem.setMnemonic(KeyEvent.VK_X);
fileMenu.add(exitItem);
exitItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.exit(0);
}
});

JMenu helpMenu = new JMenu(HELP);
helpMenu.setMnemonic(KeyEvent.VK_H);



menuBar.add(fileMenu);
menuBar.add(helpMenu);
return menuBar;
}

public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(600, 450);
frame.setTitle("SCJP Mock Exam");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

QuestionScreen questionUI = new QuestionScreen();
frame.add(questionUI);
frame.setJMenuBar(questionUI.addMenu());
frame.setVisible(true);

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top