List of usage examples for javax.swing GroupLayout setVerticalGroup
public void setVerticalGroup(Group group)
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GroupLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); GroupLayout groupLayout = new GroupLayout(contentPane); contentPane.setLayout(groupLayout);/*from w w w. ja v a 2 s.c o m*/ JLabel label = new JLabel("Label"); JButton b2 = new JButton("Second Button"); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup().addComponent(label).addComponent(b2)); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label).addComponent(b2)); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GroupLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); GroupLayout groupLayout = new GroupLayout(contentPane); contentPane.setLayout(groupLayout);/*w ww . j a v a 2 s.c o m*/ JLabel label = new JLabel("Label"); JButton b2 = new JButton("Second Button"); groupLayout.setHorizontalGroup( groupLayout.createSequentialGroup().addComponent(label).addGap(5, 10, 50).addComponent(b2)); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label).addComponent(b2)); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GroupLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); GroupLayout groupLayout = new GroupLayout(contentPane); groupLayout.setAutoCreateGaps(true); groupLayout.setAutoCreateContainerGaps(true); contentPane.setLayout(groupLayout);//from w w w .ja v a 2 s . c om JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button Second"); JButton b3 = new JButton("3"); JButton b4 = new JButton("4"); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(LEADING).addComponent(b1).addComponent(b3)) .addGroup(groupLayout.createParallelGroup(TRAILING).addComponent(b2).addComponent(b4))); groupLayout.setVerticalGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(BASELINE).addComponent(b1).addComponent(b2)) .addGroup(groupLayout.createParallelGroup(BASELINE).addComponent(b3).addComponent(b4))); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);// w w w .ja v a2s. c om JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);/*from w w w . j av a2 s .c o m*/ System.out.println(layout.getLayoutStyle()); JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);/* w w w. j a va2 s . c o m*/ System.out.println(layout.getAutoCreateGaps()); JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout);//from ww w. j a va 2 s . co m System.out.println(layout.getHonorsVisibility()); JButton buttonD = new JButton("D"); JButton buttonR = new JButton("R"); JButton buttonY = new JButton("Y"); JButton buttonO = new JButton("O"); JButton buttonT = new JButton("T"); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); leftToRight.addComponent(buttonD); GroupLayout.ParallelGroup columnMiddle = layout.createParallelGroup(); columnMiddle.addComponent(buttonR); columnMiddle.addComponent(buttonO); columnMiddle.addComponent(buttonT); leftToRight.addGroup(columnMiddle); leftToRight.addComponent(buttonY); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup rowTop = layout.createParallelGroup(); rowTop.addComponent(buttonD); rowTop.addComponent(buttonR); rowTop.addComponent(buttonY); topToBottom.addGroup(rowTop); topToBottom.addComponent(buttonO); topToBottom.addComponent(buttonT); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:org.xapagy.ui.tempdyn.tdVisualizationGenerator.java
/** * Generate a vertical list of JFreeCharts * /* w w w.j av a 2s .co m*/ * @param labels * - the labels for the values * @param index * - the index * @param values * @return */ public static String generateJFreeChart(List<String> labels, List<Double> index, List<List<Double>> values) { JPanel panel = new JPanel(); // create a layout GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup sgv = layout.createSequentialGroup(); layout.setVerticalGroup(sgv); ParallelGroup pgh = layout.createParallelGroup(); layout.setHorizontalGroup(pgh); for (int i = 0; i != labels.size(); i++) { XYSeries xys = new XYSeries(labels.get(i)); for (int j = 0; j != index.size(); j++) { xys.add(index.get(j), values.get(i).get(j)); } XYSeriesCollection xysc = new XYSeriesCollection(xys); JFreeChart chart = ChartFactory.createXYLineChart(labels.get(i), "Time", "Focus", xysc, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Tahoma", Font.BOLD, 14)); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); } JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); return null; }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Graphs the evolution of the links of all types (PRED, SUCC, SUMMARY, * CONTEXT etc) between two Vis./*from w w w.j a v a 2 s. c o m*/ * * @param fromVi * @param toVi * @param tdb * @param agent * @param index * - a list of time points which will be plotted on the x axis */ public static void graphLinksBetweenVis(tdComponent fromVi, tdComponent toVi, tdDataBase tdb, Agent agent, List<Double> index) { String label = "Links between " + fromVi.getIdentifier() + " and " + toVi.getIdentifier(); // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // add a series for each link type for (String linkName : agent.getLinks().getLinkTypeNames()) { XYSeries linkSeries = new XYSeries(linkName); xysc.addSeries(linkSeries); // now fill in the series with values for (Double time : index) { double dtime = time; double linkValue = tdb.getLinkValue(fromVi.getIdentifier(), toVi.getIdentifier(), linkName, time); linkSeries.add(dtime, linkValue); } } // // ok, now let us create a graph // JPanel panel = new JPanel(); // create a layout GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup sgv = layout.createSequentialGroup(); layout.setVerticalGroup(sgv); ParallelGroup pgh = layout.createParallelGroup(); layout.setHorizontalGroup(pgh); JFreeChart chart = ChartFactory.createXYLineChart(label, "Time", "Value", xysc, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesColorful); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Generates the graph which plots the three choice scores (independent, * dependent and mood) for the evolution of a choice in time. * /*from www.jav a 2 s .co m*/ * @param tdc * - encompasses the selected choice * @param database * - the database of values collected * @param agent * @param index * - a list of time points which will be plotted on the x axis * @param choiceRange * - the y axis will be [0, choiceRange] */ public static void graphChoiceEvolution(tdComponent tdc, tdDataBase database, Agent agent, List<Double> index, double choiceRange) { String label = PpChoice.ppConcise(tdc.getChoice(), agent); // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // focus and memory xysc.addSeries(new XYSeries("ChoiceScoreIndependent")); xysc.addSeries(new XYSeries("ChoiceScoreDependent")); xysc.addSeries(new XYSeries("ChoiceScoreMood")); // Fill in the values for (Double time : index) { double dtime = time; double valueChoiceScoreIndependent = database.getChoiceScoreDependent(tdc.getIdentifier(), time); xysc.getSeries("ChoiceScoreIndependent").add(dtime, valueChoiceScoreIndependent); double valueChoiceScoreDependent = database.getChoiceScoreDependent(tdc.getIdentifier(), time); xysc.getSeries("ChoiceScoreDependent").add(dtime, valueChoiceScoreDependent); double valueChoiceScoreMood = database.getChoiceScoreDependent(tdc.getIdentifier(), time); xysc.getSeries("ChoiceScoreMood").add(dtime, valueChoiceScoreMood); } // // ok, now let us create a graph // JPanel panel = new JPanel(); // create a layout GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); SequentialGroup sgv = layout.createSequentialGroup(); layout.setVerticalGroup(sgv); ParallelGroup pgh = layout.createParallelGroup(); layout.setHorizontalGroup(pgh); // // the graph with the focus and the memory // XYSeriesCollection xysFM = new XYSeriesCollection(); xysFM.addSeries(xysc.getSeries("ChoiceScoreIndependent")); xysFM.addSeries(xysc.getSeries("ChoiceScoreDependent")); xysFM.addSeries(xysc.getSeries("ChoiceScoreMood")); JFreeChart chart = ChartFactory.createXYLineChart(label + " - Choice", "Time", "Value", xysFM, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesColorful); ChartPanel cp = new ChartPanel(chart); sgv.addComponent(cp); pgh.addComponent(cp); JFrame frame = new JFrame(); frame.add(panel); frame.pack(); frame.setVisible(true); }