List of usage examples for java.awt Dimension Dimension
public Dimension(int width, int height)
From source file:Main.java
public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); JButton openDialog = new JButton("Click here"); JPanel myPanel = new JPanel(); myPanel.add(new JButton(new AbstractAction("Click here") { @Override/* w w w .j av a2s .c o m*/ public void actionPerformed(ActionEvent e) { JDialog dialog = new JDialog(myFrame, true); JTextField myField = new JTextField(10); JPanel innerPanel = new JPanel(); innerPanel.add(myField); dialog.add(innerPanel); dialog.pack(); dialog.setSize(new Dimension(160, 120)); dialog.setLocationRelativeTo(myFrame); dialog.setVisible(true); } })); add(myPanel); pack(); setSize(new Dimension(320, 240)); setLocationRelativeTo(null); setVisible(true); }
From source file:Main.java
Main(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); commandLine = new JTextField(); commandLine.addActionListener(this); getContentPane().add(commandLine, BorderLayout.NORTH); view = new JEditorPane(); view.setEditable(false);/*from w w w .j av a 2 s . com*/ view.setPreferredSize(new Dimension(400, 400)); view.addHyperlinkListener(this); getContentPane().add(view, BorderLayout.CENTER); pack(); setVisible(true); }
From source file:org.jfree.chart.demo.SubCategoryAxisDemo1.java
public SubCategoryAxisDemo1(String s) { super(s);/*from ww w .j av a2 s . co m*/ JPanel jpanel = createDemoPanel(); jpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(jpanel); }
From source file:MainClass.java
MainClass(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); commandLine = new JTextField(); commandLine.addActionListener(this); getContentPane().add(commandLine, BorderLayout.NORTH); view = new JEditorPane(); view.setEditable(false);//from w ww . j a va2 s .c om view.setPreferredSize(new Dimension(400, 400)); view.addHyperlinkListener(this); getContentPane().add(view, BorderLayout.CENTER); pack(); setVisible(true); }
From source file:org.jfree.chart.demo.StackedBarChartDemo7.java
public StackedBarChartDemo7(String s) { super(s);//from www . j av a2s. c om JPanel jpanel = createDemoPanel(); jpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(jpanel); }
From source file:org.jfree.chart.demo.DeviationRendererDemo1.java
public DeviationRendererDemo1(String s) { super(s);// w ww . j a v a2 s . co m JPanel jpanel = createDemoPanel(); jpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(jpanel); }
From source file:org.jfree.chart.demo.PopulationChartDemo1.java
public PopulationChartDemo1(String s) { super(s);//from w w w. ja v a 2s . c o m KeyedValues2DDataset keyedvalues2ddataset = createDataset(); org.jfree.chart.JFreeChart jfreechart = ChartFactory.createStackedBarChart("Population Chart Demo", "Age Group", "Population (millions)", keyedvalues2ddataset, PlotOrientation.HORIZONTAL, true, true, false); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); }
From source file:ded.model.SerializationTests.java
public void test1() throws Exception { // Build a simple diagram. Diagram d = new Diagram(); d.windowSize = new Dimension(1000, 2000); Entity e1 = new Entity(); e1.loc = new Point(5, 10); e1.size = new Dimension(30, 40); e1.shape = EntityShape.ES_ELLIPSE;//from ww w . j a v a2 s . c om e1.name = "e1"; e1.attributes = "attr1\nattr2\nattr3"; d.entities.add(e1); Entity e2 = new Entity(); e2.loc = new Point(15, 20); e2.size = new Dimension(130, 140); e2.shape = EntityShape.ES_NO_SHAPE; e2.name = "e2"; e2.attributes = "funny\"characters\\in\'this,string!"; d.entities.add(e2); // Relation from e1 to e2 with two control points. Relation r1 = new Relation(new RelationEndpoint(e1), new RelationEndpoint(e2)); r1.controlPts.add(new Point(71, 72)); r1.controlPts.add(new Point(73, 74)); r1.routingAlg = RoutingAlgorithm.RA_DIRECT; r1.label = "r1"; r1.end.arrowStyle = ArrowStyle.AS_FILLED_TRIANGLE; r1.start.arrowStyle = ArrowStyle.AS_DOUBLE_ANGLE; d.relations.add(r1); // Relation between two points. Relation r2 = new Relation(new RelationEndpoint(new Point(81, 82)), new RelationEndpoint(new Point(83, 84))); d.relations.add(r2); // Make e2 inherit from e1. Inheritance i1 = new Inheritance(e1, true /*open*/, new Point(31, 32)); d.inheritances.add(i1); Relation r3 = new Relation(new RelationEndpoint(e2), new RelationEndpoint(i1)); r3.routingAlg = RoutingAlgorithm.RA_MANHATTAN_VERT; d.relations.add(r3); // Make sure it is all consistent. d.selfCheck(); // Serialize it. String serialized = d.toJSON().toString(2); System.out.println(serialized); // Parse it. JSONObject o = new JSONObject(new JSONTokener(serialized)); Diagram d2 = new Diagram(o); d2.selfCheck(); // Check for structural equality. assert (d2.equals(d)); // Serialize and check that for equality too. String ser2 = d2.toJSON().toString(2); assert (ser2.equals(serialized)); }
From source file:ImageUtil.java
/** * returns a dimension where width and height are inside the bounds of the * maxWidth and maxHeight parameters<br> * and the aspect ratio is the same as sourceWidth and sourceHeight. * /*from w ww . j a v a2s . c om*/ * @param maxWidth * the maximum width of the target dimension * @param maxHeight * the maximum height of the target dimension * @param sourceWidth * the widht of the source image * @param sourceHeight * the height of the source image * @return the target dimension that will be the greatest dimension that * <ul> * <li>will keep the ratio of the source images dimension</li> * <li>fits in the bounds of the maximum dimension given</li> * </ul> */ public static Dimension scaleDimensions(int maxWidth, int maxHeight, int sourceWidth, int sourceHeight) { float vidH, vidW, maxH, maxW; vidW = Integer.valueOf(sourceWidth).floatValue(); vidH = Integer.valueOf(sourceHeight).floatValue(); maxW = Integer.valueOf(maxWidth).floatValue(); maxH = Integer.valueOf(maxHeight).floatValue(); // System.out.println("initial height / width ratio: " + vidH / vidW); // System.out.println(); // System.out.println("vidW "+vidW+", vidH "+vidH); // System.out.println("maxW "+maxW+", maxH "+maxH); // System.out.println(); float finalW, finalH; finalH = vidH / vidW * maxW; finalW = maxW; if (finalH > maxH) { float factor = maxH / finalH; finalH = maxH; finalW = finalW * factor; } int w = Float.valueOf(finalW).intValue(); int h = Float.valueOf(finalH).intValue(); Dimension d = new Dimension(w, h); // System.out.println(); // System.out.println("finalW "+finalW+", finalH "+finalH); // System.out.println("final height / width ratio: " + finalH / finalW); // System.out.println(); // System.out.println(d); return d; }
From source file:org.jfree.chart.demo.XYLineAndShapeRendererDemo2.java
public XYLineAndShapeRendererDemo2(String s) { super(s);//w w w .java 2 s. c o m JPanel jpanel = createDemoPanel(); jpanel.setPreferredSize(new Dimension(500, 300)); setContentPane(jpanel); }