Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31903
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.datemas.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Image rotation part 2 |
| Date | Tue, 30 Jun 2015 16:36:46 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 43 |
| Message-ID | <mmv93r$6j9$1@dont-email.me> (permalink) |
| References | <mmuhle$gp1$1@dont-email.me> <mmv7cc$l2$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Tue, 30 Jun 2015 23:35:24 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="eae36f4d568939f99ca21bcceebb0602"; logging-data="6761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xN0A76dgvwRoNK8ScUvf0" |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 |
| In-Reply-To | <mmv7cc$l2$1@dont-email.me> |
| Cancel-Lock | sha1:Mfcfj29gVngbULbqvXFliiBIr3M= |
| Xref | csiph.com comp.lang.java.programmer:31903 |
Show key headers only | View raw
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test4 extends JComponent {
private final String message = "VERTICAL TEXT";
private final int width = 20;
private final int height = 220;
public test4() {
setFont(new Font("Monospaced",Font.BOLD,16));
setPreferredSize(new Dimension(width,height));
}
public void paintComponent(Graphics g2d) {
Graphics2D g = (Graphics2D)g2d;
g.setColor(Color.BLACK);
g.fillRect(0,0,width,height);
g.setColor(Color.WHITE);
char[] chars = message.toCharArray();
FontMetrics metrics = g.getFontMetrics();
double charHeight = metrics.getHeight() * 0.7;
g.translate(
(width - metrics.charWidth(' '))/2.0,
(height - charHeight * chars.length)/2.0 + charHeight);
for (int i=0; i<chars.length; i++) {
g.drawChars(chars,i,1,0,0);
g.translate(0,charHeight);
}
}
public static void main(String... args) {
EventQueue.invokeLater(() -> {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.add(new test4(),BorderLayout.CENTER);
f.pack();
f.setVisible(true);
});
}
}
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 16:55 +0000
Re: Image rotation part 2 Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-06-30 14:03 -0400
Re: Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 20:04 +0000
Re: Image rotation part 2 Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-06-30 16:20 -0400
Re: Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 20:52 +0000
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-06-30 12:07 -0700
Re: Image rotation part 2 Martin Gregorie <martin@address-in-sig.invalid> - 2015-06-30 20:18 +0000
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-06-30 19:04 -0400
Re: Image rotation part 2 Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-06-30 16:36 -0700
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-06-30 20:17 -0400
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-06-30 20:09 -0400
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-07-01 06:06 -0700
Re: Image rotation part 2 FredK <fred.l.kleinschmidt@gmail.com> - 2015-07-01 10:57 -0700
Re: Image rotation part 2 Jeff Higgins <jeff@invalid.invalid> - 2015-07-01 18:13 -0400
Re: Image rotation part 2 Arne Vajhøj <arne@vajhoej.dk> - 2015-07-27 22:28 -0400
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-07-28 04:58 -0700
Re: Image rotation part 2 Arne Vajhøj <arne@vajhoej.dk> - 2015-07-28 18:58 -0400
Re: Image rotation part 2 e.d.programmer@gmail.com - 2015-07-29 05:35 -0700
csiph-web