List of usage examples for javax.swing JFrame setPreferredSize
public void setPreferredSize(Dimension preferredSize)
From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_GASP.java
public static void main(String[] args) { JFrame frame = new JFrame("LCD Text Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(630, 460)); frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_GASP)); frame.pack();//from w w w. j ava 2s. co m frame.setVisible(true); }
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setBackground(Color.red); frame.setPreferredSize(new Dimension(400, 300)); frame.pack();//from www. ja v a 2s.co m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); int treeSelectedRows[] = { 3, 1 }; tree.setSelectionRows(treeSelectedRows); TreeSelectionListener treeSelectionListener = new TreeSelectionListener() { @Override// www . j a va 2s . co m public void valueChanged(TreeSelectionEvent treeSelectionEvent) { JTree treeSource = (JTree) treeSelectionEvent.getSource(); System.out.println("Min: " + treeSource.getMinSelectionRow()); System.out.println("Max: " + treeSource.getMaxSelectionRow()); System.out.println("Lead: " + treeSource.getLeadSelectionRow()); System.out.println("Row: " + treeSource.getSelectionRows()[0]); } }; tree.addTreeSelectionListener(treeSelectionListener); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setPreferredSize(new Dimension(380, 320)); frame.setLocation(150, 150); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new Main()); frame.setPreferredSize(new Dimension(500, 400)); frame.pack();//w w w . j av a 2s .co m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); int treeSelectedRows[] = { 3, 1 }; tree.setSelectionRows(treeSelectedRows); TreeSelectionListener treeSelectionListener = new TreeSelectionListener() { @Override/*from w w w. j a v a2 s . c om*/ public void valueChanged(TreeSelectionEvent treeSelectionEvent) { JTree treeSource = (JTree) treeSelectionEvent.getSource(); System.out.println("Min: " + treeSource.getMinSelectionRow()); System.out.println("Max: " + treeSource.getMaxSelectionRow()); System.out.println("Lead: " + treeSource.getLeadSelectionRow()); System.out.println("Row: " + treeSource.getSelectionRows()[0]); } }; tree.addTreeSelectionListener(treeSelectionListener); JFrame frame = new JFrame("JTree With Multi-Discontiguous selection"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setPreferredSize(new Dimension(380, 320)); frame.setLocation(150, 150); frame.pack(); frame.setVisible(true); }
From source file:moviedatas.MovieDatas.java
public static void main(String[] args) { FilterController fpc = new FilterController(); SortController spc = new SortController(); //1. Create the frame. JFrame frame = new JFrame("Movies Open Datas by Harp-e"); frame.setPreferredSize(new Dimension(1280, 800)); //2. Optional: What happens when the frame closes? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MovieListView movieListView = new MovieListView(); JPanel movieListPanel = movieListView.createViewPanel(); TitledBorder moviesTitle;//from w w w.j a v a 2 s. c o m moviesTitle = BorderFactory.createTitledBorder("Movies"); movieListPanel.setBorder(moviesTitle); //3. Create components and put them in the frame. //---------------------------------------------------------------------- // Sort & Filter panel (right) //---------------------------------------------------------------------- SortPanelView sortFilterView = new SortPanelView(); FilterPanelView filterPanelView = new FilterPanelView(); JPanel sortPanel = sortFilterView.createSortPanel(); JPanel filterPanel = filterPanelView.createFilterPanel(); JPanel sortFilterPanel = new JPanel(); sortFilterPanel.setLayout(new BoxLayout(sortFilterPanel, BoxLayout.PAGE_AXIS)); sortFilterPanel.add(sortPanel); sortFilterPanel.add(filterPanel); frame.getContentPane().add(sortFilterPanel, BorderLayout.WEST); //---------------------------------------------------------------------- // Movie Info Panel (left) //---------------------------------------------------------------------- MovieInfoController movieInfoController = new MovieInfoController(); JPanel movieInfoView = movieInfoController.initView(); TitledBorder infoTitle; infoTitle = BorderFactory.createTitledBorder("Informations"); movieInfoView.setBorder(infoTitle); //---------------------------------------------------------------------- // Movie List Panel (middle) //---------------------------------------------------------------------- JPanel listPanel = new JPanel(); listPanel.setLayout(new BorderLayout()); listPanel.setPreferredSize(new Dimension(1280, 400)); listPanel.add(sortFilterPanel, BorderLayout.WEST); listPanel.add(movieInfoView, BorderLayout.EAST); listPanel.add(movieListPanel, BorderLayout.CENTER); frame.getContentPane().add(listPanel, BorderLayout.NORTH); //---------------------------------------------------------------------- // Charts Panel (bottom) //---------------------------------------------------------------------- JPanel chartPanel = new JPanel(); // Spider chart Panel //______________________________________________________________________ // Create the panel JPanel spiderPanel = new JPanel(); // Create the view SpiderChartView spiderChartView = new SpiderChartView(); // Create a tilte TitledBorder spiderTitle; // Put a border around the title spiderTitle = BorderFactory.createTitledBorder("Spider chart"); // Put the border on the panel spiderPanel.setBorder(spiderTitle); // Put the view on the panel spiderPanel.add(spiderChartView.initView()); // Put the spider panel on the global panel chartPanel.add(spiderPanel); //______________________________________________________________________ // Bar chart Panel //______________________________________________________________________ JPanel barPanel = new JPanel(); BarChartView barChartView = new BarChartView(); TitledBorder barTitle; barTitle = BorderFactory.createTitledBorder("Bar chart"); barPanel.setBorder(barTitle); barPanel.add(barChartView.initView()); chartPanel.add(barPanel); //______________________________________________________________________ // Global chart Panel //______________________________________________________________________ JPanel globalChartPanel = new JPanel(); GlobalChart globalChartView = new GlobalChart(); TitledBorder globalTitle; globalTitle = BorderFactory.createTitledBorder("Global chart"); globalChartPanel.setBorder(globalTitle); globalChartPanel.add(globalChartView.initView()); chartPanel.add(globalChartPanel); //______________________________________________________________________ frame.getContentPane().add(chartPanel, BorderLayout.CENTER); //---------------------------------------------------------------------- //4. Size the frame. frame.pack(); //5. Show it. frame.setVisible(true); //ArrayList<Movie> movies = new ArrayList<>(); //FilterController.filter(10,SortController.byTitle(movies)); }
From source file:com.amazonaws.services.kinesis.leases.impl.LeaseCoordinatorExerciser.java
public static void main(String[] args) throws InterruptedException, DependencyException, InvalidStateException, ProvisionedThroughputException, IOException { int numCoordinators = 9; int numLeases = 73; int leaseDurationMillis = 10000; int epsilonMillis = 100; AWSCredentialsProvider creds = new DefaultAWSCredentialsProviderChain(); AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(creds); ILeaseManager<KinesisClientLease> leaseManager = new KinesisClientLeaseManager("nagl_ShardProgress", ddb); if (leaseManager.createLeaseTableIfNotExists(10L, 50L)) { LOG.info("Waiting for newly created lease table"); if (!leaseManager.waitUntilLeaseTableExists(10, 300)) { LOG.error("Table was not created in time"); return; }//from w w w . j ava 2s .c o m } CWMetricsFactory metricsFactory = new CWMetricsFactory(creds, "testNamespace", 30 * 1000, 1000); final List<LeaseCoordinator<KinesisClientLease>> coordinators = new ArrayList<LeaseCoordinator<KinesisClientLease>>(); for (int i = 0; i < numCoordinators; i++) { String workerIdentifier = "worker-" + Integer.toString(i); LeaseCoordinator<KinesisClientLease> coord = new LeaseCoordinator<KinesisClientLease>(leaseManager, workerIdentifier, leaseDurationMillis, epsilonMillis, metricsFactory); coordinators.add(coord); } leaseManager.deleteAll(); for (int i = 0; i < numLeases; i++) { KinesisClientLease lease = new KinesisClientLease(); lease.setLeaseKey(Integer.toString(i)); lease.setCheckpoint(new ExtendedSequenceNumber("checkpoint")); leaseManager.createLeaseIfNotExists(lease); } final JFrame frame = new JFrame("Test Visualizer"); frame.setPreferredSize(new Dimension(800, 600)); final JPanel panel = new JPanel(new GridLayout(coordinators.size() + 1, 0)); final JLabel ticker = new JLabel("tick"); panel.add(ticker); frame.getContentPane().add(panel); final Map<String, JLabel> labels = new HashMap<String, JLabel>(); for (final LeaseCoordinator<KinesisClientLease> coord : coordinators) { JPanel coordPanel = new JPanel(); coordPanel.setLayout(new BoxLayout(coordPanel, BoxLayout.X_AXIS)); final Button button = new Button("Stop " + coord.getWorkerIdentifier()); button.setMaximumSize(new Dimension(200, 50)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (coord.isRunning()) { coord.stop(); button.setLabel("Start " + coord.getWorkerIdentifier()); } else { try { coord.start(); } catch (LeasingException e) { LOG.error(e); } button.setLabel("Stop " + coord.getWorkerIdentifier()); } } }); coordPanel.add(button); JLabel label = new JLabel(); coordPanel.add(label); labels.put(coord.getWorkerIdentifier(), label); panel.add(coordPanel); } frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); new Thread() { // Key is lease key, value is green-ness as a value from 0 to 255. // Great variable name, huh? private Map<String, Integer> greenNesses = new HashMap<String, Integer>(); // Key is lease key, value is last owning worker private Map<String, String> lastOwners = new HashMap<String, String>(); @Override public void run() { while (true) { for (LeaseCoordinator<KinesisClientLease> coord : coordinators) { String workerIdentifier = coord.getWorkerIdentifier(); JLabel label = labels.get(workerIdentifier); List<KinesisClientLease> asgn = new ArrayList<KinesisClientLease>(coord.getAssignments()); Collections.sort(asgn, new Comparator<KinesisClientLease>() { @Override public int compare(KinesisClientLease arg0, KinesisClientLease arg1) { return arg0.getLeaseKey().compareTo(arg1.getLeaseKey()); } }); StringBuilder builder = new StringBuilder(); builder.append("<html>"); builder.append(workerIdentifier).append(":").append(asgn.size()).append(" "); for (KinesisClientLease lease : asgn) { String leaseKey = lease.getLeaseKey(); String lastOwner = lastOwners.get(leaseKey); // Color things green when they switch owners, decay the green-ness over time. Integer greenNess = greenNesses.get(leaseKey); if (greenNess == null || lastOwner == null || !lastOwner.equals(lease.getLeaseOwner())) { greenNess = 200; } else { greenNess = Math.max(0, greenNess - 20); } greenNesses.put(leaseKey, greenNess); lastOwners.put(leaseKey, lease.getLeaseOwner()); builder.append(String.format("<font color=\"%s\">%03d</font>", String.format("#00%02x00", greenNess), Integer.parseInt(leaseKey))).append(" "); } builder.append("</html>"); label.setText(builder.toString()); label.revalidate(); label.repaint(); } if (ticker.getText().equals("tick")) { ticker.setText("tock"); } else { ticker.setText("tick"); } try { Thread.sleep(200); } catch (InterruptedException e) { } } } }.start(); frame.pack(); frame.setVisible(true); for (LeaseCoordinator<KinesisClientLease> coord : coordinators) { coord.start(); } }
From source file:ua.com.fielden.platform.example.swing.schedule.ScheduleChartPanelExample.java
public static void main(final String[] args) { SwingUtilitiesEx.invokeLater(new Runnable() { @Override/*from w w w.ja v a 2 s . c o m*/ public void run() { for (final LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(laf.getName())) { try { UIManager.setLookAndFeel(laf.getClassName()); } catch (final Exception e) { e.printStackTrace(); } } } com.jidesoft.utils.Lm.verifyLicense("Fielden Management Services", "Rollingstock Management System", "xBMpKdqs3vWTvP9gxUR4jfXKGNz9uq52"); LookAndFeelFactory.installJideExtension(); final JFrame frame = new JFrame("Scedule chart demo"); final JLabel label = new JLabel("None"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new MigLayout("fill, insets 0", "[grow, fill]", "[grow, fill][]")); frame.add(createScheduleChartPanel(label), "wrap"); frame.add(label); frame.setPreferredSize(new Dimension(640, 480)); frame.pack(); frame.setVisible(true); } }); }
From source file:edu.gmu.isa681.client.Main.java
public static void main(String[] args) { log.info("Setting look and feel..."); try {//w ww. j ava 2 s .co m for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex1) { log.warn(ex1.getMessage(), ex1); log.warn("Nimbus is not available."); log.warn("Switching to system look and feel"); log.warn("Some GUI discrepancies may occur!"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex2) { log.error(ex2.getMessage(), ex2); log.error("Could not setup a look and feel."); System.exit(1); } } log.info("Initializing GUI..."); final JFrame frame = new JFrame(); frame.setTitle("GoForward"); frame.setBackground(new Color(0, 100, 0)); UIManager.put("nimbusBase", new Color(0, 100, 0)); //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0)); UIManager.put("control", new Color(0, 100, 0)); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { frame.setPreferredSize(frame.getSize()); } }); Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); if (dim.width < 1366) { frame.setPreferredSize(new Dimension(800, 600)); } else { frame.setPreferredSize(new Dimension(1200, 700)); } //frame.setResizable(false); frame.setLocationByPlatform(true); frame.pack(); Client client = new Client("localhost", Constants.SERVER_PORT); Controller controller = new Controller(client, frame); controller.applicationStarted(); frame.setLocationRelativeTo(null); frame.setVisible(true); log.info("Started"); }
From source file:ua.com.fielden.platform.example.swing.booking.BookingChartPanelExample.java
public static void main(final String[] args) { SwingUtilitiesEx.invokeLater(new Runnable() { @Override/*from w w w .j a va 2 s . c om*/ public void run() { for (final LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(laf.getName())) { try { UIManager.setLookAndFeel(laf.getClassName()); } catch (final Exception e) { e.printStackTrace(); } } } com.jidesoft.utils.Lm.verifyLicense("Fielden Management Services", "Rollingstock Management System", "xBMpKdqs3vWTvP9gxUR4jfXKGNz9uq52"); LookAndFeelFactory.installJideExtension(); final JFrame frame = new JFrame("Booking chart demo"); final JLabel label = new JLabel("None"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new MigLayout("fill, insets 0", "[grow, fill]", "[grow, fill][]")); frame.add(createBookingChartPanel(label), "wrap"); frame.add(label); frame.setPreferredSize(new Dimension(640, 480)); frame.pack(); frame.setVisible(true); } }); }